1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00
ezstream/tests/check_log.c

93 lines
2.0 KiB
C
Raw Permalink Normal View History

2015-05-24 05:29:42 -04:00
#include <check.h>
#include <errno.h>
#include "log.h"
Suite * log_suite(void);
void setup_checked(void);
void teardown_checked(void);
START_TEST(test_log)
{
unsigned int verbosity;
ck_assert_int_eq(log_syserr(ALERT, 0, "alert"), 0);
verbosity = 0;
2018-01-19 05:48:57 -05:00
log_set_verbosity(verbosity);
2015-05-24 05:29:42 -04:00
ck_assert_int_ne(log_alert("alert"), 0);
ck_assert_int_ne(log_syserr(ALERT, EINVAL, "alert"), 0);
ck_assert_int_ne(log_syserr(ALERT, EINVAL, NULL), 0);
ck_assert_int_ne(log_error("error"), 0);
ck_assert_int_ne(log_syserr(ERROR, EINVAL, "error"), 0);
ck_assert_int_ne(log_warning("warning"), 0);
ck_assert_int_ne(log_syserr(WARNING, EINVAL, "warning"), 0);
ck_assert_int_eq(log_notice("notice"), 0);
ck_assert_int_eq(log_syserr(NOTICE, EINVAL, "notice"), 0);
2018-01-19 05:48:57 -05:00
log_set_verbosity(++verbosity);
2015-05-24 05:29:42 -04:00
ck_assert_int_ne(log_notice("notice"), 0);
ck_assert_int_ne(log_syserr(NOTICE, EINVAL, "notice"), 0);
ck_assert_int_eq(log_info("info"), 0);
ck_assert_int_eq(log_syserr(INFO, EINVAL, "info"), 0);
2018-01-19 05:48:57 -05:00
log_set_verbosity(++verbosity);
2015-05-24 05:29:42 -04:00
ck_assert_int_ne(log_info("info"), 0);
ck_assert_int_ne(log_syserr(INFO, EINVAL, "info"), 0);
ck_assert_int_eq(log_debug("debug"), 0);
ck_assert_int_eq(log_syserr(DEBUG, EINVAL, "debug"), 0);
2018-01-19 05:48:57 -05:00
log_set_verbosity(++verbosity);
2015-05-24 05:29:42 -04:00
ck_assert_int_ne(log_debug("debug"), 0);
ck_assert_int_ne(log_syserr(DEBUG, EINVAL, "debug"), 0);
}
END_TEST
Suite *
log_suite(void)
{
Suite *s;
2015-05-24 05:33:24 -04:00
TCase *tc_log;
2015-05-24 05:29:42 -04:00
s = suite_create("Log");
2015-05-24 05:33:24 -04:00
tc_log = tcase_create("Log");
tcase_add_checked_fixture(tc_log, setup_checked, teardown_checked);
tcase_add_test(tc_log, test_log);
suite_add_tcase(s, tc_log);
2015-05-24 05:29:42 -04:00
return (s);
}
void
setup_checked(void)
{
2018-01-19 05:48:57 -05:00
if (0 < log_init("check_log"))
2015-05-24 05:29:42 -04:00
ck_abort_msg("setup_checked failed");
}
void
teardown_checked(void)
{
log_exit();
}
int
main(void)
{
2017-10-04 09:23:21 -04:00
int num_failed;
Suite *s;
SRunner *sr;
2015-05-24 05:29:42 -04:00
s = log_suite();
sr = srunner_create(s);
srunner_run_all(sr, CK_NORMAL);
num_failed = srunner_ntests_failed(sr);
srunner_free(sr);
if (num_failed)
return (1);
return (0);
}