15 #include <sys/resource.h> 16 #include <sys/types.h> 24 #ifndef CRM_COMMON_UNITTEST_INTERNAL__H 25 #define CRM_COMMON_UNITTEST_INTERNAL__H 29 #if (PCMK__WITH_COVERAGE == 1) 113 #define pcmk__assert_asserts(stmt) \ 117 struct rlimit cores = { 0, 0 }; \ 118 setrlimit(RLIMIT_CORE, &cores); \ 122 } else if (p > 0) { \ 124 if (waitpid(p, &wstatus, 0) == -1) { \ 125 fail_msg("waitpid failed"); \ 127 if (!(WIFSIGNALED(wstatus) && WTERMSIG(wstatus) == SIGABRT)) { \ 128 fail_msg("statement terminated in child without asserting"); \ 131 fail_msg("unable to fork for assert test"); \ 142 #define pcmk__assert_aborts(stmt) pcmk__assert_asserts(stmt) 159 #define pcmk__assert_exits(rc, stmt) \ 163 struct rlimit cores = { 0, 0 }; \ 164 setrlimit(RLIMIT_CORE, &cores); \ 167 _exit(CRM_EX_NONE); \ 168 } else if (p > 0) { \ 170 if (waitpid(p, &wstatus, 0) == -1) { \ 171 fail_msg("waitpid failed"); \ 173 if (!WIFEXITED(wstatus)) { \ 174 fail_msg("statement terminated abnormally"); \ 175 } else if (WEXITSTATUS(wstatus) != rc) { \ 176 fail_msg("statement exited with %d, not expected %d", WEXITSTATUS(wstatus), rc); \ 179 fail_msg("unable to fork for assert test"); \ 188 #define PCMK__UNIT_TEST(group_setup, group_teardown, ...) \ 190 main(int argc, char **argv) \ 192 const struct CMUnitTest t[] = { \ 195 cmocka_set_message_output(CM_OUTPUT_TAP); \ 196 return cmocka_run_group_tests(t, group_setup, group_teardown); \
void pcmk__test_init_logging(const char *name, const char *filename)
int pcmk__xml_test_setup_group(void **state)
Wrappers for and extensions to libxml2.
int pcmk__xml_test_teardown_group(void **state)
void pcmk__cib_test_cleanup(char *out_path)
void pcmk__assert_validates(xmlNode *xml)
char * pcmk__cib_test_copy_cib(const char *in_file)