This source file includes following definitions.
- null_scheduler
- null_cib
- previous_cib_null
- previous_cib_nonnull
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/scheduler.h>
13 #include <crm/common/unittest_internal.h>
14
15 static void
16 null_scheduler(void **state)
17 {
18 xmlNode *cib = pcmk__xe_create(NULL, "test");
19
20 assert_int_equal(pcmk_set_scheduler_cib(NULL, NULL), EINVAL);
21 assert_int_equal(pcmk_set_scheduler_cib(NULL, cib), EINVAL);
22
23 free_xml(cib);
24 }
25
26 static void
27 null_cib(void **state)
28 {
29 pcmk_scheduler_t scheduler = {
30 .input = NULL,
31 };
32
33 assert_int_equal(pcmk_set_scheduler_cib(&scheduler, NULL), pcmk_rc_ok);
34 assert_null(scheduler.input);
35 }
36
37 static void
38 previous_cib_null(void **state)
39 {
40 pcmk_scheduler_t scheduler = {
41 .input = NULL,
42 };
43 xmlNode *cib = pcmk__xe_create(NULL, "test");
44
45 assert_int_equal(pcmk_set_scheduler_cib(&scheduler, cib), pcmk_rc_ok);
46 assert_ptr_equal(scheduler.input, cib);
47
48 free_xml(cib);
49 }
50
51 static void
52 previous_cib_nonnull(void **state)
53 {
54 xmlNode *old_cib = pcmk__xe_create(NULL, "old");
55 xmlNode *new_cib = pcmk__xe_create(NULL, "new");
56 pcmk_scheduler_t scheduler = {
57 .input = old_cib,
58 };
59
60 assert_int_equal(pcmk_set_scheduler_cib(&scheduler, new_cib), pcmk_rc_ok);
61 assert_ptr_equal(scheduler.input, new_cib);
62
63 free_xml(old_cib);
64 free_xml(new_cib);
65 }
66
67 PCMK__UNIT_TEST(NULL, NULL,
68 cmocka_unit_test(null_scheduler),
69 cmocka_unit_test(null_cib),
70 cmocka_unit_test(previous_cib_null),
71 cmocka_unit_test(previous_cib_nonnull))