From f6ec4e1aeb19216fadebe911d3d35fd1d821e21f Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Wed, 6 May 2015 23:45:52 +0200 Subject: [PATCH] Add check unit testing framework w/ 2 dummy tests --- .gitignore | 1 + Makefile.am | 2 +- configure.ac | 8 ++++++++ src/Makefile.am | 22 ++++++++++++-------- tests/Makefile.am | 27 +++++++++++++++++++++++++ tests/check_cfg.c | 12 +++++++++++ tests/check_ezstream.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 tests/Makefile.am create mode 100644 tests/check_cfg.c create mode 100644 tests/check_ezstream.c diff --git a/.gitignore b/.gitignore index 6561464..24869d5 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ ltsugar.m4 ltversion.m4 lt~obsolete.m4 missing +test-driver diff --git a/Makefile.am b/Makefile.am index c480e09..eb1a21b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = build-aux compat doc examples m4 src +SUBDIRS = build-aux compat doc examples m4 src tests dist_doc_DATA = COPYING NEWS README diff --git a/configure.ac b/configure.ac index c3fb9a6..04581f8 100644 --- a/configure.ac +++ b/configure.ac @@ -45,11 +45,18 @@ if test x"${ez_enable_debug}" = "xyes"; then fi AC_MSG_RESULT([$ez_enable_debug]) +AC_PROG_LIBTOOL +AC_SUBST([LIBTOOL_DEPS]) + EZ_CFLAGS="" EZ_CPPFLAGS="" EZ_LDFLAGS="" EZ_LIBS="" +AC_SYS_LARGEFILE + +PKG_CHECK_MODULES([CHECK], [check >= 0.9.4]) + dnl ############## dnl ## COMPILER ######################################################## @@ -290,6 +297,7 @@ AC_CONFIG_FILES([ src/Makefile src/attr_config.h src/ezstream-file.sh + tests/Makefile ]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 929fc5e..09bca46 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,8 +1,6 @@ AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects -bin_PROGRAMS = ezstream -bin_SCRIPTS = ezstream-file.sh - +noinst_LTLIBRARIES = libezstream.la noinst_HEADERS = \ attributes.h \ cfg.h \ @@ -17,22 +15,30 @@ noinst_HEADERS = \ playlist.h \ util.h \ xalloc.h -ezstream_SOURCES = \ +libezstream_la_SOURCES = \ cfg.c \ cfg_decoder.c \ cfg_encoder.c \ cfg_xmlfile.c \ cmdline.c \ - ezstream.c \ log.c \ metadata.c \ playlist.c \ util.c \ xalloc.c -ezstream_LDADD = @LIBOBJS@ @EZ_LIBS@ +libezstream_la_DEPENDENCIES = +libezstream_la_LIBADD = @LIBOBJS@ @EZ_LIBS@ \ + $(libezstream_la_DEPENDENCIES) + +bin_SCRIPTS = ezstream-file.sh +bin_PROGRAMS = ezstream + +ezstream_SOURCES = ezstream.c +ezstream_DEPENDENCIES = libezstream.la +ezstream_LDADD = $(ezstream_DEPENDENCIES) -AM_CFLAGS = @EZ_CFLAGS@ AM_CPPFLAGS = @EZ_CPPFLAGS@ -I$(top_srcdir)/compat -AM_LDFLAGS = @EZ_LDFLAGS@ +AM_CFLAGS = @EZ_CFLAGS@ +AM_LDFLAGS = @EZ_LDFLAGS@ -avoid-version CLEANFILES = core *.core *~ .*~ diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..8d0a5e5 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,27 @@ +AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects + +TESTS = \ + check_ezstream \ + check_cfg +check_PROGRAMS = $(TESTS) + +check_ezstream_SOURCES = \ + check_ezstream.c +check_ezstream_DEPENDENCIES = $(top_builddir)/src/libezstream.la +check_ezstream_LDADD = $(check_ezstream_DEPENDENCIES) @CHECK_LIBS@ + +check_cfg_SOURCES = \ + check_cfg.c +check_cfg_DEPENDENCIES = $(top_builddir)/src/libezstream.la +check_cfg_LDADD = $(check_cfg_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@ +AM_LDFLAGS = @EZ_LDFLAGS@ + +EXTRA_DIST = compat.h + +CLEANFILES = *~ *.core core diff --git a/tests/check_cfg.c b/tests/check_cfg.c new file mode 100644 index 0000000..bca8186 --- /dev/null +++ b/tests/check_cfg.c @@ -0,0 +1,12 @@ +#include + +START_TEST(test_cfg) +{ +} +END_TEST + +int +main(void) +{ + return (0); +} diff --git a/tests/check_ezstream.c b/tests/check_ezstream.c new file mode 100644 index 0000000..9fdfd44 --- /dev/null +++ b/tests/check_ezstream.c @@ -0,0 +1,46 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include "compat.h" + +#include + +START_TEST(test_ezstream) +{ +} +END_TEST + +Suite * +ezstream_suite(void) +{ + Suite *s; + TCase *tc_core; + + s = suite_create("Ezstream"); + + tc_core = tcase_create("Core"); + tcase_add_test(tc_core, test_ezstream); + suite_add_tcase(s, tc_core); + + return (s); +} + +int +main(void) +{ + unsigned int num_failed; + Suite *s; + SRunner *sr; + + s = ezstream_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); +}