1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Split out tests for cfg_xmlfile.c and use it to check the examples

This commit is contained in:
Moritz Grimm 2015-05-22 00:40:21 +02:00
parent d71886a0e6
commit 65200182f9
3 changed files with 102 additions and 24 deletions

View File

@ -1,7 +1,8 @@
AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects
TESTS = \
check_cfg
check_cfg \
check_cfg_xmlfile
check_PROGRAMS = $(TESTS)
check_cfg_SOURCES = \
@ -9,11 +10,18 @@ check_cfg_SOURCES = \
check_cfg_DEPENDENCIES = $(top_builddir)/src/libezstream.la
check_cfg_LDADD = $(check_cfg_DEPENDENCIES) @CHECK_LIBS@
check_cfg_xmlfile_SOURCES = \
check_cfg_xmlfile.c
check_cfg_xmlfile_DEPENDENCIES = $(top_builddir)/src/libezstream.la
check_cfg_xmlfile_LDADD = $(check_cfg_xmlfile_DEPENDENCIES) @CHECK_LIBS@
AM_CPPFLAGS = @EZ_CPPFLAGS@ \
-I$(top_srcdir)/compat \
-I$(top_srcdir)/src \
-I$(top_builddir)/src
AM_CFLAGS = @EZ_CFLAGS@ @CHECK_CFLAGS@ -DSRCDIR="\"$(srcdir)\""
AM_CFLAGS = @EZ_CFLAGS@ @CHECK_CFLAGS@ \
-DSRCDIR="\"$(srcdir)\"" \
-DEXAMPLESDIR="\"$(top_srcdir)/examples\""
AM_LDFLAGS = @EZ_LDFLAGS@
EXTRA_DIST = \

View File

@ -100,27 +100,6 @@ Suite * cfg_suite(void);
void setup_checked(void);
void teardown_checked(void);
START_TEST(test_reload)
{
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-ok.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), 0);
ck_assert_int_eq(cfg_reload(), 0);
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-bad.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), -1);
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-bad2.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), -1);
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-bad3.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), -1);
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-bad4.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), -1);
}
END_TEST
START_TEST(test_stream_str2fmt)
{
enum cfg_stream_format fmt;
@ -746,7 +725,6 @@ cfg_suite(void)
tc_core = tcase_create("Core");
tcase_add_checked_fixture(tc_core, setup_checked, teardown_checked);
tcase_add_test(tc_core, test_reload);
tcase_add_test(tc_core, test_stream_str2fmt);
tcase_add_test(tc_core, test_stream_fmt2str);
tcase_add_test(tc_core, test_file_check);

92
tests/check_cfg_xmlfile.c Normal file
View File

@ -0,0 +1,92 @@
#include <check.h>
#include "cfg_private.h"
#include "log.h"
Suite * cfg_xmlfile_suite(void);
void setup_checked(void);
void teardown_checked(void);
START_TEST(test_reload)
{
ck_assert_int_eq(cfg_set_program_config_file(EXAMPLESDIR "/ezstream-file_template.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), 0);
ck_assert_int_eq(cfg_set_program_config_file(EXAMPLESDIR "/ezstream-full.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), 0);
ck_assert_int_eq(cfg_set_program_config_file(EXAMPLESDIR "/ezstream-minimal.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), 0);
ck_assert_int_eq(cfg_set_program_config_file(EXAMPLESDIR "/ezstream-video.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), 0);
ck_assert_int_eq(cfg_reload(), 0);
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-bad.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), -1);
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-bad2.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), -1);
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-bad3.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), -1);
ck_assert_int_eq(cfg_set_program_config_file(SRCDIR "/config-bad4.xml",
NULL), 0);
ck_assert_int_eq(cfg_reload(), -1);
}
END_TEST
Suite *
cfg_xmlfile_suite(void)
{
Suite *s;
TCase *tc_xmlcfg;
s = suite_create("XmlConfig");
tc_xmlcfg = tcase_create("Reload");
tcase_add_checked_fixture(tc_xmlcfg, setup_checked, teardown_checked);
tcase_add_test(tc_xmlcfg, test_reload);
suite_add_tcase(s, tc_xmlcfg);
return (s);
}
void
setup_checked(void)
{
if (0 < cfg_init() ||
0 < cfg_decoder_init() ||
0 < cfg_encoder_init() ||
0 < log_init())
ck_abort_msg("setup_checked failed");
}
void
teardown_checked(void)
{
log_exit();
cfg_encoder_exit();
cfg_decoder_exit();
cfg_exit();
}
int
main(void)
{
unsigned int num_failed;
Suite *s;
SRunner *sr;
s = cfg_xmlfile_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);
}