pacemaker 2.1.5-a3f44794f94
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 Lesser General Public License
7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8 */
9
10#include <crm_internal.h>
11
13
14#include <glib.h>
15
16static void
17target_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
29static void
30src_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
40static void
41copying_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
59PCMK__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))
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:517
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
void copy_in_properties(xmlNode *target, xmlNode *src)
Definition: xml.c:545
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:749
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
Definition: xml.c:3103