pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
Macros | Functions
unittest_internal.h File Reference
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <setjmp.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <cmocka.h>
#include <crm/common/xml.h>
Include dependency graph for unittest_internal.h:

Go to the source code of this file.

Macros

#define __gcov_dump()
 
#define pcmk__assert_asserts(stmt)
 
#define pcmk__assert_aborts(stmt)   pcmk__assert_asserts(stmt)
 
#define pcmk__assert_exits(rc, stmt)
 
#define PCMK__UNIT_TEST(group_setup, group_teardown, ...)
 

Functions

void pcmk__assert_validates (xmlNode *xml)
 
int pcmk__xml_test_setup_group (void **state)
 
char * pcmk__cib_test_copy_cib (const char *in_file)
 
void pcmk__cib_test_cleanup (char *out_path)
 
void pcmk__test_init_logging (const char *name, const char *filename)
 

Macro Definition Documentation

◆ __gcov_dump

#define __gcov_dump ( )

Definition at line 35 of file unittest_internal.h.

◆ pcmk__assert_aborts

#define pcmk__assert_aborts (   stmt)    pcmk__assert_asserts(stmt)

Definition at line 150 of file unittest_internal.h.

◆ pcmk__assert_asserts

#define pcmk__assert_asserts (   stmt)
Value:
do { \
pid_t p = fork(); \
if (p == 0) { \
struct rlimit cores = { 0, 0 }; \
setrlimit(RLIMIT_CORE, &cores); \
stmt; \
__gcov_dump(); \
_exit(0); \
} else if (p > 0) { \
int wstatus = 0; \
if (waitpid(p, &wstatus, 0) == -1) { \
fail_msg("waitpid failed"); \
} \
if (!(WIFSIGNALED(wstatus) && WTERMSIG(wstatus) == SIGABRT)) { \
fail_msg("statement terminated in child without asserting"); \
} \
} else { \
fail_msg("unable to fork for assert test"); \
} \
} while (0);

Definition at line 121 of file unittest_internal.h.

◆ pcmk__assert_exits

#define pcmk__assert_exits (   rc,
  stmt 
)
Value:
do { \
pid_t p = fork(); \
if (p == 0) { \
struct rlimit cores = { 0, 0 }; \
setrlimit(RLIMIT_CORE, &cores); \
stmt; \
__gcov_dump(); \
_exit(CRM_EX_NONE); \
} else if (p > 0) { \
int wstatus = 0; \
if (waitpid(p, &wstatus, 0) == -1) { \
fail_msg("waitpid failed"); \
} \
if (!WIFEXITED(wstatus)) { \
fail_msg("statement terminated abnormally"); \
} else if (WEXITSTATUS(wstatus) != rc) { \
fail_msg("statement exited with %d, not expected %d", WEXITSTATUS(wstatus), rc); \
} \
} else { \
fail_msg("unable to fork for assert test"); \
} \
} while (0);
No exit status available.
Definition: results.h:318

Definition at line 167 of file unittest_internal.h.

◆ PCMK__UNIT_TEST

#define PCMK__UNIT_TEST (   group_setup,
  group_teardown,
  ... 
)
Value:
int \
main(int argc, char **argv) \
{ \
const struct CMUnitTest t[] = { \
__VA_ARGS__ \
}; \
cmocka_set_message_output(CM_OUTPUT_TAP); \
return cmocka_run_group_tests(t, group_setup, group_teardown); \
}

Definition at line 196 of file unittest_internal.h.

Function Documentation

◆ pcmk__assert_validates()

void pcmk__assert_validates ( xmlNode *  xml)

Definition at line 20 of file unittest.c.

◆ pcmk__cib_test_cleanup()

void pcmk__cib_test_cleanup ( char *  out_path)

Definition at line 121 of file unittest.c.

◆ pcmk__cib_test_copy_cib()

char* pcmk__cib_test_copy_cib ( const char *  in_file)

Definition at line 86 of file unittest.c.

◆ pcmk__test_init_logging()

void pcmk__test_init_logging ( const char *  name,
const char *  filename 
)

Definition at line 138 of file unittest.c.

◆ pcmk__xml_test_setup_group()

int pcmk__xml_test_setup_group ( void **  state)

Definition at line 74 of file unittest.c.