20 static char *remote_schema_dir = NULL;
23 symlink_schema(
const char *tmpdir,
const char *target_file,
const char *link_file)
32 rc = symlink(oldpath, newpath);
40 rm_files(
const char *pathname,
const struct stat *sbuf,
int type,
struct FTW *ftwb)
42 return remove(pathname);
46 rmtree(
const char *dir)
48 return nftw(dir, rm_files, 10, FTW_DEPTH|FTW_MOUNT|FTW_PHYS);
61 remote_schema_dir = mkdtemp(dir);
63 if (remote_schema_dir == NULL) {
73 if (symlink_schema(dir,
"pacemaker-3.0.rng",
"pacemaker-3.1.rng") != 0) {
79 if (symlink_schema(dir,
"pacemaker-3.0.rng",
"pacemaker-3.2.rng") != 0) {
85 setenv(
"PCMK_remote_schema_directory", remote_schema_dir, 1);
86 setenv(
"PCMK_schema_directory", PCMK__TEST_SCHEMA_DIR, 1);
97 teardown(
void **state)
103 unsetenv(
"PCMK_remote_schema_directory");
104 unsetenv(
"PCMK_schema_directory");
106 rc = rmtree(remote_schema_dir);
108 free(remote_schema_dir);
114 assert_schema(
const char *schema_name,
int schema_index)
120 assert_non_null(entry);
122 schema = entry->data;
123 assert_non_null(schema);
129 extra_schema_files(
void **state)
137 assert_schema(
"pacemaker-1.0", 0);
138 assert_schema(
"pacemaker-1.2", 1);
139 assert_schema(
"pacemaker-2.0", 3);
140 assert_schema(
"pacemaker-3.0", 14);
141 assert_schema(
"pacemaker-3.1", 15);
142 assert_schema(
"pacemaker-3.2", 16);
145 assert_schema(
"pacemaker-next", 17);
152 cmocka_unit_test(extra_schema_files));
void crm_schema_init(void)
enum crm_ais_msg_types type
void crm_schema_cleanup(void)
PCMK__UNIT_TEST(setup, teardown, cmocka_unit_test(extra_schema_files))
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
GList * pcmk__get_schema(const char *name)
Wrappers for and extensions to libxml2.
const char * pcmk__get_tmpdir(void)