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)
45 unsetenv(
"PCMK_schema_directory");
50 invalid_name(
void **state)
52 GList *already_included = NULL;
56 assert_null(
parent->children);
57 assert_null(already_included);
62 single_schema(
void **state)
64 GList *already_included = NULL;
66 xmlNode *schema_node = NULL;
67 xmlNode *file_node = NULL;
72 assert_non_null(already_included);
73 assert_non_null(
parent->children);
86 assert_string_equal(
"pacemaker-3.0",
90 while (file_node != NULL &&
rngs1[i] != NULL) {
91 assert_string_equal(
rngs1[i],
93 assert_int_equal(pcmk__xml_first_child(file_node)->
type, XML_CDATA_SECTION_NODE);
95 file_node = pcmk__xe_next(file_node);
99 g_list_free_full(already_included, free);
104 multiple_schemas(
void **state)
106 GList *already_included = NULL;
108 xmlNode *schema_node = NULL;
109 xmlNode *file_node = NULL;
115 assert_non_null(already_included);
116 assert_non_null(
parent->children);
122 assert_string_equal(
"pacemaker-2.0",
126 while (file_node != NULL &&
rngs2[i] != NULL) {
127 assert_string_equal(
rngs2[i],
129 assert_int_equal(pcmk__xml_first_child(file_node)->
type, XML_CDATA_SECTION_NODE);
131 file_node = pcmk__xe_next(file_node);
135 schema_node = pcmk__xe_next(schema_node);
136 assert_string_equal(
"pacemaker-2.1",
142 while (file_node != NULL &&
rngs3[i] != NULL) {
143 assert_string_equal(
rngs3[i],
145 assert_int_equal(pcmk__xml_first_child(file_node)->
type, XML_CDATA_SECTION_NODE);
147 file_node = pcmk__xe_next(file_node);
151 g_list_free_full(already_included, free);
156 cmocka_unit_test(invalid_name),
157 cmocka_unit_test(single_schema),
158 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)
void pcmk__build_schema_xml_node(xmlNode *parent, const char *name, GList **already_included)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)