This source file includes following definitions.
- null_args
- shutdown_absent
- shutdown_present
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <stdio.h>
13 #include <libxml/tree.h>
14
15 #include <crm/common/nodes.h>
16 #include <crm/common/unittest_internal.h>
17
18
19 #define CIB_XML \
20 "<" PCMK_XE_CIB ">" \
21 "<" PCMK_XE_STATUS ">" \
22 "<" PCMK__XE_NODE_STATE " " PCMK_XA_UNAME "='node1'>" \
23 "<" PCMK__XE_TRANSIENT_ATTRIBUTES ">" \
24 "<" PCMK_XE_INSTANCE_ATTRIBUTES ">" \
25 "<" PCMK_XE_NVPAIR " " \
26 PCMK_XA_NAME "='" PCMK__NODE_ATTR_SHUTDOWN "' " \
27 PCMK_XA_VALUE "='999'/>" \
28 "</" PCMK_XE_INSTANCE_ATTRIBUTES ">" \
29 "</" PCMK__XE_TRANSIENT_ATTRIBUTES ">" \
30 "</" PCMK__XE_NODE_STATE ">" \
31 "</" PCMK_XE_STATUS ">" \
32 "</" PCMK_XE_CIB ">"
33
34 static void
35 null_args(void **state)
36 {
37 xmlNode *xml = pcmk__xml_parse(CIB_XML);
38
39 assert_non_null(xml);
40 assert_null(pcmk_cib_node_shutdown(NULL, NULL));
41 assert_null(pcmk_cib_node_shutdown(xml, NULL));
42 assert_null(pcmk_cib_node_shutdown(NULL, "node1"));
43 free_xml(xml);
44 }
45
46 static void
47 shutdown_absent(void **state)
48 {
49 xmlNode *xml = pcmk__xml_parse(CIB_XML);
50
51 assert_non_null(xml);
52 assert_null(pcmk_cib_node_shutdown(xml, "node"));
53 assert_null(pcmk_cib_node_shutdown(xml, "node10"));
54 free_xml(xml);
55 }
56
57 static void
58 shutdown_present(void **state)
59 {
60 xmlNode *xml = pcmk__xml_parse(CIB_XML);
61
62 assert_non_null(xml);
63 assert_string_equal(pcmk_cib_node_shutdown(xml, "node1"), "999");
64 free_xml(xml);
65 }
66
67 PCMK__UNIT_TEST(NULL, NULL,
68 cmocka_unit_test(null_args),
69 cmocka_unit_test(shutdown_absent),
70 cmocka_unit_test(shutdown_present))