This source file includes following definitions.
- nodes_equal
- node1_first
- node2_first
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13 #include <crm/pengine/internal.h>
14
15 struct pe_node_shared_s node1_details;
16 struct pe_node_shared_s node2_details;
17
18 pe_node_t node1 = {.details = &node1_details};
19 pe_node_t node2 = {.details = &node2_details};
20
21 static void
22 nodes_equal(void **state)
23 {
24 assert_int_equal(pe__cmp_node_name(NULL, NULL), 0);
25
26 node1.details->uname = "node10";
27 node2.details->uname = "node10";
28 assert_int_equal(pe__cmp_node_name(&node1, &node2), 0);
29 }
30
31 static void
32 node1_first(void **state)
33 {
34 assert_int_equal(pe__cmp_node_name(NULL, &node2), -1);
35
36
37 node1.details->uname = "node9";
38 node2.details->uname = "node10";
39 assert_int_equal(pe__cmp_node_name(&node1, &node2), -1);
40 }
41
42 static void
43 node2_first(void **state)
44 {
45 assert_int_equal(pe__cmp_node_name(&node1, NULL), 1);
46
47 node1.details->uname = "node10";
48 node2.details->uname = "node9";
49 assert_int_equal(pe__cmp_node_name(&node1, &node2), 1);
50 }
51
52 PCMK__UNIT_TEST(NULL, NULL,
53 cmocka_unit_test(nodes_equal),
54 cmocka_unit_test(node1_first),
55 cmocka_unit_test(node2_first))