pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
copy_in_properties_test.c
Go to the documentation of this file.
1  /*
2  * Copyright 2022 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU General Public License version 2
7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
13 
14 #include <glib.h>
15 
16 static void
17 target_is_NULL(void **state)
18 {
19  xmlNode *test_xml_1 = create_xml_node(NULL, "test_xml_1");
20  xmlNode *test_xml_2 = NULL;
21 
22  pcmk__xe_set_props(test_xml_1, "test_prop", "test_value", NULL);
23 
24  copy_in_properties(test_xml_2, test_xml_1);
25 
26  assert_ptr_equal(test_xml_2, NULL);
27 }
28 
29 static void
30 src_is_NULL(void **state)
31 {
32  xmlNode *test_xml_1 = NULL;
33  xmlNode *test_xml_2 = create_xml_node(NULL, "test_xml_2");
34 
35  copy_in_properties(test_xml_2, test_xml_1);
36 
37  assert_ptr_equal(test_xml_2->properties, NULL);
38 }
39 
40 static void
41 copying_is_successful(void **state)
42 {
43  const char *xml_1_value;
44  const char *xml_2_value;
45 
46  xmlNode *test_xml_1 = create_xml_node(NULL, "test_xml_1");
47  xmlNode *test_xml_2 = create_xml_node(NULL, "test_xml_2");
48 
49  pcmk__xe_set_props(test_xml_1, "test_prop", "test_value", NULL);
50 
51  copy_in_properties(test_xml_2, test_xml_1);
52 
53  xml_1_value = crm_element_value(test_xml_1, "test_prop");
54  xml_2_value = crm_element_value(test_xml_2, "test_prop");
55 
56  assert_string_equal(xml_1_value, xml_2_value);
57 }
58 
59 PCMK__UNIT_TEST(NULL, NULL,
60  cmocka_unit_test(target_is_NULL),
61  cmocka_unit_test(src_is_NULL),
62  cmocka_unit_test(copying_is_successful))
void copy_in_properties(xmlNode *target, const xmlNode *src)
Definition: xml.c:456
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:447
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:638
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
Definition: xml.c:2654