Codebase list realmd / f6b33bf
Cherry-pick patch from upstream to fix test failure Closes: #935294 Andreas Henriksson 4 years ago
2 changed file(s) with 85 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
00 01_freeipa_section.patch
11 02_cross.patch
22 tests-use-python3.patch
3 tests-ignore-order.patch
0 From b6753bd048b4012b11d60c094d1ab6ca181ee50d Mon Sep 17 00:00:00 2001
1 From: Sumit Bose <sbose@redhat.com>
2 Date: Thu, 21 Feb 2019 21:16:26 +0100
3 Subject: tests: ignore order in test_update_domain
4
5 Individual options of a domain or in general for a section in an ini
6 file are stored by realmd in a hash table. When writing out the ini file
7 the options can show up in any order and the unit tests should be aware
8 of it.
9
10 Resolves: https://gitlab.freedesktop.org/realmd/realmd/issues/19
11 ---
12 tests/test-sssd-config.c | 41 +++++++++++++++++++++++++++++++++++++++--
13 1 file changed, 39 insertions(+), 2 deletions(-)
14
15 (limited to 'tests')
16
17 diff --git a/tests/test-sssd-config.c b/tests/test-sssd-config.c
18 index 59eab75..8f3fec5 100644
19 --- a/tests/test-sssd-config.c
20 +++ b/tests/test-sssd-config.c
21 @@ -163,12 +163,49 @@ test_add_domain_only (Test *test,
22 g_free (output);
23 }
24
25 +static void check_for_test_update_domain (char *new)
26 +{
27 + char *token;
28 + char *saveptr;
29 + size_t c;
30 + int result = 0;
31 +
32 + token = strtok_r (new, "\n", &saveptr);
33 + g_assert_nonnull (token);
34 + g_assert_cmpstr (token, ==, "[domain/one]");
35 +
36 + for (c = 0; c < 3; c++) {
37 + token = strtok_r (NULL, "\n", &saveptr);
38 + g_assert_nonnull (token);
39 + if (strcmp (token, "val=1") == 0) {
40 + result += 1;
41 + } else if (strcmp (token, "uno = 1") == 0) {
42 + result += 2;
43 + } else if (strcmp (token, "eins = one") == 0) {
44 + result += 4;
45 + } else {
46 + g_assert_not_reached ();
47 + }
48 + }
49 + g_assert_cmpint (result, ==, 7);
50 +
51 + token = strtok_r (NULL, "\n", &saveptr);
52 + g_assert_nonnull (token);
53 + g_assert_cmpstr (token, ==, "[sssd]");
54 +
55 + token = strtok_r (NULL, "\n", &saveptr);
56 + g_assert_nonnull (token);
57 + g_assert_cmpstr (token, ==, "domains=one");
58 +
59 + token = strtok_r (NULL, "\n", &saveptr);
60 + g_assert_null (token);
61 +}
62 +
63 static void
64 test_update_domain (Test *test,
65 gconstpointer unused)
66 {
67 const gchar *data = "[domain/one]\nval=1\n[sssd]\ndomains=one";
68 - const gchar *check = "[domain/one]\nval=1\nuno = 1\neins = one\n[sssd]\ndomains=one";
69 GError *error = NULL;
70 gchar *output;
71 gboolean ret;
72 @@ -190,7 +227,7 @@ test_update_domain (Test *test,
73 g_assert_no_error (error);
74 g_assert (ret == TRUE);
75
76 - g_assert_cmpstr (check, ==, output);
77 + check_for_test_update_domain (output);
78 g_free (output);
79 }
80
81 --
82 cgit v1.1
83