18 const char *
rngs1[] = {
"pacemaker-3.0.rng",
"status-1.0.rng",
"alerts-2.10.rng",
19 "nvset-2.9.rng",
"score.rng",
"rule-2.9.rng",
20 "tags-1.3.rng",
"acls-2.0.rng",
"fencing-2.4.rng",
21 "constraints-3.0.rng",
"resources-3.0.rng",
"nvset-3.0.rng",
22 "nodes-3.0.rng",
"options-3.0.rng", NULL };
24 const char *
rngs2[] = {
"pacemaker-2.0.rng",
"status-1.0.rng",
"tags-1.3.rng",
25 "acls-2.0.rng",
"fencing-1.2.rng",
"constraints-1.2.rng",
26 "rule.rng",
"score.rng",
"resources-1.3.rng",
27 "nvset-1.3.rng",
"nodes-1.3.rng",
"options-1.0.rng",
28 "nvset.rng",
"cib-1.2.rng", NULL };
30 const char *
rngs3[] = {
"pacemaker-2.1.rng",
"constraints-2.1.rng", NULL };
35 setenv(
"PCMK_schema_directory", PCMK__TEST_SCHEMA_DIR, 1);
42 teardown(
void **state)
46 unsetenv(
"PCMK_schema_directory");
51 invalid_name(
void **state)
53 GList *already_included = NULL;
57 assert_null(
parent->children);
58 assert_null(already_included);
63 single_schema(
void **state)
65 GList *already_included = NULL;
67 xmlNode *schema_node = NULL;
68 xmlNode *file_node = NULL;
73 assert_non_null(already_included);
74 assert_non_null(
parent->children);
87 assert_string_equal(
"pacemaker-3.0",
91 while (file_node != NULL &&
rngs1[i] != NULL) {
92 assert_string_equal(
rngs1[i],
94 assert_int_equal(pcmk__xml_first_child(file_node)->
type, XML_CDATA_SECTION_NODE);
96 file_node = pcmk__xe_next(file_node);
100 g_list_free_full(already_included, free);
105 multiple_schemas(
void **state)
107 GList *already_included = NULL;
109 xmlNode *schema_node = NULL;
110 xmlNode *file_node = NULL;
116 assert_non_null(already_included);
117 assert_non_null(
parent->children);
123 assert_string_equal(
"pacemaker-2.0",
127 while (file_node != NULL &&
rngs2[i] != NULL) {
128 assert_string_equal(
rngs2[i],
130 assert_int_equal(pcmk__xml_first_child(file_node)->
type, XML_CDATA_SECTION_NODE);
132 file_node = pcmk__xe_next(file_node);
136 schema_node = pcmk__xe_next(schema_node);
137 assert_string_equal(
"pacemaker-2.1",
143 while (file_node != NULL &&
rngs3[i] != NULL) {
144 assert_string_equal(
rngs3[i],
146 assert_int_equal(pcmk__xml_first_child(file_node)->
type, XML_CDATA_SECTION_NODE);
148 file_node = pcmk__xe_next(file_node);
152 g_list_free_full(already_included, free);
157 cmocka_unit_test(invalid_name),
158 cmocka_unit_test(single_schema),
159 cmocka_unit_test(multiple_schemas))
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
void crm_schema_init(void)
enum crm_ais_msg_types type
void crm_schema_cleanup(void)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
int pcmk__xml_test_setup_group(void **state)
Wrappers for and extensions to libxml2.
void free_xml(xmlNode *child)
int pcmk__xml_test_teardown_group(void **state)
void pcmk__build_schema_xml_node(xmlNode *parent, const char *name, GList **already_included)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)