Add tests for the csync_util functions.

This commit is contained in:
Andreas Schneider 2008-05-09 09:26:12 +02:00
parent be57b79d6c
commit 9f887635b2
2 changed files with 56 additions and 0 deletions

View File

@ -34,6 +34,7 @@ macro_add_check_test(check_csync_config csync_tests/check_csync_config.c ${TEST_
macro_add_check_test(check_csync_exclude csync_tests/check_csync_exclude.c ${TEST_TARGET_LIBRARIES})
macro_add_check_test(check_csync_journal csync_tests/check_csync_journal.c ${TEST_TARGET_LIBRARIES})
macro_add_check_test(check_csync_time csync_tests/check_csync_time.c ${TEST_TARGET_LIBRARIES})
macro_add_check_test(check_csync_util csync_tests/check_csync_util.c ${TEST_TARGET_LIBRARIES})
# vio
macro_add_check_test(check_vio_handle vio_tests/check_vio_handle.c ${TEST_TARGET_LIBRARIES})

View File

@ -0,0 +1,55 @@
#include "support.h"
#include "csync_util.h"
START_TEST (check_csync_instruction_str)
{
const char *str = NULL;
str = csync_instruction_str(CSYNC_INSTRUCTION_ERROR);
fail_unless(strcmp(str, "CSYNC_INSTRUCTION_ERROR") == 0, NULL);
str = csync_instruction_str(0xFFFF);
fail_unless(strcmp(str, "ERROR!") == 0, NULL);
}
END_TEST
START_TEST (check_csync_memstat)
{
csync_memstat_check();
}
END_TEST
static Suite *make_csync_suite(void) {
Suite *s = suite_create("csync_lock");
create_case(s, "check_csync_instruction_str", check_csync_instruction_str);
create_case(s, "check_csync_memstat", check_csync_memstat);
return s;
}
int main(int argc, char **argv) {
Suite *s = NULL;
SRunner *sr = NULL;
struct argument_s arguments;
int nf;
ZERO_STRUCT(arguments);
cmdline_parse(argc, argv, &arguments);
s = make_csync_suite();
sr = srunner_create(s);
if (arguments.nofork) {
srunner_set_fork_status(sr, CK_NOFORK);
}
srunner_run_all(sr, CK_VERBOSE);
nf = srunner_ntests_failed(sr);
srunner_free(sr);
return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}