10#ifndef PCMK__CRM_COMMON_UNITTEST_INTERNAL__H
11#define PCMK__CRM_COMMON_UNITTEST_INTERNAL__H
17#include <sys/resource.h>
32#if (PCMK__WITH_COVERAGE == 1)
127#define pcmk__assert_asserts(stmt) \
131 struct rlimit cores = { 0, 0 }; \
132 setrlimit(RLIMIT_CORE, &cores); \
136 } else if (p > 0) { \
138 if (waitpid(p, &wstatus, 0) == -1) { \
139 fail_msg("waitpid failed"); \
141 if (!(WIFSIGNALED(wstatus) && WTERMSIG(wstatus) == SIGABRT)) { \
142 fail_msg("statement terminated in child without asserting"); \
145 fail_msg("unable to fork for assert test"); \
156#define pcmk__assert_aborts(stmt) pcmk__assert_asserts(stmt)
173#define pcmk__assert_exits(rc, stmt) \
177 struct rlimit cores = { 0, 0 }; \
178 setrlimit(RLIMIT_CORE, &cores); \
181 _exit(CRM_EX_NONE); \
182 } else if (p > 0) { \
184 if (waitpid(p, &wstatus, 0) == -1) { \
185 fail_msg("waitpid failed"); \
187 if (!WIFEXITED(wstatus)) { \
188 fail_msg("statement terminated abnormally"); \
189 } else if (WEXITSTATUS(wstatus) != rc) { \
190 fail_msg("statement exited with %d, not expected %d", WEXITSTATUS(wstatus), rc); \
193 fail_msg("unable to fork for assert test"); \
202#define PCMK__UNIT_TEST(group_setup, group_teardown, ...) \
204main(int argc, char **argv) \
206 const struct CMUnitTest t[] = { \
209 cmocka_set_message_output(CM_OUTPUT_TAP); \
210 return cmocka_run_group_tests(t, group_setup, group_teardown); \
void pcmk__test_init_logging(const char *name, const char *filename)
void pcmk__cib_test_cleanup(char *out_path)
int pcmk__xml_test_teardown_group(void **state)
int pcmk__xml_test_setup_group(void **state)
void pcmk__assert_validates(xmlNode *xml)
char * pcmk__cib_test_copy_cib(const char *in_file)
Wrappers for and extensions to libxml2.