mirror of
https://gitlab.xiph.org/xiph/ezstream.git
synced 2024-11-03 04:17:18 -05:00
Start to test cmdline
This commit is contained in:
parent
111f219f17
commit
9ffc726ad7
@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects
|
||||
TESTS = \
|
||||
check_cfg \
|
||||
check_cfg_xmlfile \
|
||||
check_cmdline \
|
||||
check_log \
|
||||
check_xalloc
|
||||
check_PROGRAMS = $(TESTS)
|
||||
@ -17,6 +18,11 @@ check_cfg_xmlfile_SOURCES = \
|
||||
check_cfg_xmlfile_DEPENDENCIES = $(top_builddir)/src/libezstream.la
|
||||
check_cfg_xmlfile_LDADD = $(check_cfg_xmlfile_DEPENDENCIES) @CHECK_LIBS@
|
||||
|
||||
check_cmdline_SOURCES = \
|
||||
check_cmdline.c
|
||||
check_cmdline_DEPENDENCIES = $(top_builddir)/src/libezstream.la
|
||||
check_cmdline_LDADD = $(check_cmdline_DEPENDENCIES) @CHECK_LIBS@
|
||||
|
||||
check_log_SOURCES = \
|
||||
check_log.c
|
||||
check_log_DEPENDENCIES = $(top_builddir)/src/libezstream.la
|
||||
|
67
tests/check_cmdline.c
Normal file
67
tests/check_cmdline.c
Normal file
@ -0,0 +1,67 @@
|
||||
#include <check.h>
|
||||
|
||||
#include "cfg.h"
|
||||
#include "cmdline.h"
|
||||
|
||||
Suite * cmdline_suite(void);
|
||||
void setup_checked(void);
|
||||
void teardown_checked(void);
|
||||
|
||||
START_TEST(test_help)
|
||||
{
|
||||
char *argv[] = { "check_cmdline", "-h", NULL };
|
||||
int argc = (int)(sizeof(argv) / sizeof(argv[0])) - 1;
|
||||
int ret;
|
||||
|
||||
ck_assert_int_ne(cmdline_parse(argc, argv, &ret), 0);
|
||||
ck_assert_int_eq(ret, 0);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite *
|
||||
cmdline_suite(void)
|
||||
{
|
||||
Suite *s;
|
||||
TCase *tc_cmdline;
|
||||
|
||||
s = suite_create("CmdLine");
|
||||
|
||||
tc_cmdline = tcase_create("CmdLine");
|
||||
tcase_add_checked_fixture(tc_cmdline, setup_checked, teardown_checked);
|
||||
tcase_add_test(tc_cmdline, test_help);
|
||||
suite_add_tcase(s, tc_cmdline);
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
void
|
||||
setup_checked(void)
|
||||
{
|
||||
if (0 < cfg_init())
|
||||
ck_abort_msg("setup_checked failed");
|
||||
}
|
||||
|
||||
void
|
||||
teardown_checked(void)
|
||||
{
|
||||
cfg_exit();
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
unsigned int num_failed;
|
||||
Suite *s;
|
||||
SRunner *sr;
|
||||
|
||||
s = cmdline_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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user