1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00
This commit is contained in:
Moritz Grimm 2015-05-24 11:29:42 +02:00
parent b4fe40532a
commit 8357b854d8
2 changed files with 102 additions and 1 deletions

View File

@ -2,7 +2,8 @@ AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects
TESTS = \ TESTS = \
check_cfg \ check_cfg \
check_cfg_xmlfile check_cfg_xmlfile \
check_log
check_PROGRAMS = $(TESTS) check_PROGRAMS = $(TESTS)
check_cfg_SOURCES = \ check_cfg_SOURCES = \
@ -15,6 +16,11 @@ check_cfg_xmlfile_SOURCES = \
check_cfg_xmlfile_DEPENDENCIES = $(top_builddir)/src/libezstream.la check_cfg_xmlfile_DEPENDENCIES = $(top_builddir)/src/libezstream.la
check_cfg_xmlfile_LDADD = $(check_cfg_xmlfile_DEPENDENCIES) @CHECK_LIBS@ check_cfg_xmlfile_LDADD = $(check_cfg_xmlfile_DEPENDENCIES) @CHECK_LIBS@
check_log_SOURCES = \
check_log.c
check_log_DEPENDENCIES = $(top_builddir)/src/libezstream.la
check_log_LDADD = $(check_cfg_xmlfile_DEPENDENCIES) @CHECK_LIBS@
AM_CPPFLAGS = @EZ_CPPFLAGS@ \ AM_CPPFLAGS = @EZ_CPPFLAGS@ \
-I$(top_srcdir)/compat \ -I$(top_srcdir)/compat \
-I$(top_srcdir)/src \ -I$(top_srcdir)/src \

95
tests/check_log.c Normal file
View File

@ -0,0 +1,95 @@
#include <check.h>
#include <errno.h>
#include "cfg.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;
ck_assert_int_eq(cfg_set_program_verbosity(verbosity, NULL), 0);
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);
ck_assert_int_eq(cfg_set_program_verbosity(++verbosity, NULL), 0);
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);
ck_assert_int_eq(cfg_set_program_verbosity(++verbosity, NULL), 0);
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);
ck_assert_int_eq(cfg_set_program_verbosity(++verbosity, NULL), 0);
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;
TCase *tc_core;
s = suite_create("Log");
tc_core = tcase_create("Core");
tcase_add_checked_fixture(tc_core, setup_checked, teardown_checked);
tcase_add_test(tc_core, test_log);
suite_add_tcase(s, tc_core);
return (s);
}
void
setup_checked(void)
{
if (0 < cfg_init() ||
0 < log_init())
ck_abort_msg("setup_checked failed");
}
void
teardown_checked(void)
{
log_exit();
cfg_exit();
}
int
main(void)
{
unsigned int num_failed;
Suite *s;
SRunner *sr;
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);
}