Skip to content

Commit

Permalink
Make an automake testsuite
Browse files Browse the repository at this point in the history
Add the existing tests and the examples. The testsuite is then run with
"make check".
  • Loading branch information
fzago-cray committed Mar 19, 2015
1 parent 3b49e01 commit 0b2e8ca
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
13 changes: 5 additions & 8 deletions examples/c++/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@

noinst_PROGRAMS = example1 example2 example3 example4
check_PROGRAMS = example1 example2 example3 example4
AM_DEFAULT_SOURCE_EXT = .cpp

example1_SOURCES = example1.cpp

example2_SOURCES = example2.cpp

example3_SOURCES = example3.cpp

example4_SOURCES = example4.cpp
noinst_PROGRAMS=$(check_PROGRAMS)
TESTS = $(check_PROGRAMS)
XFAIL_TESTS = example4

AM_CPPFLAGS = -I $(top_srcdir)/lib

Expand Down
9 changes: 3 additions & 6 deletions examples/c/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@

noinst_PROGRAMS = example1 example2 example3
check_PROGRAMS = example1 example2 example3
noinst_PROGRAMS=$(check_PROGRAMS)

example1_SOURCES = example1.c

example2_SOURCES = example2.c

example3_SOURCES = example3.c
TESTS = $(check_PROGRAMS)

AM_CPPFLAGS = -I $(top_srcdir)/lib

Expand Down
4 changes: 3 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

noinst_PROGRAMS = libconfig_tests
check_PROGRAMS = libconfig_tests
noinst_PROGRAMS=$(check_PROGRAMS)
TESTS = $(check_PROGRAMS)

libconfig_tests_SOURCES = tests.c

Expand Down
8 changes: 7 additions & 1 deletion tests/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,18 @@ TT_TEST(ParseInvalidStrings)

int main(int argc, char **argv)
{
int failures;

TT_SUITE_START(LibConfigTests);
TT_SUITE_TEST(LibConfigTests, ParsingAndFormatting);
TT_SUITE_TEST(LibConfigTests, ParseInvalidFiles);
TT_SUITE_TEST(LibConfigTests, ParseInvalidStrings);
TT_SUITE_RUN(LibConfigTests);
failures = TT_SUITE_NUM_FAILURES(LibConfigTests);
TT_SUITE_END(LibConfigTests);

return(0);
if (failures)
return EXIT_FAILURE;

return EXIT_SUCCESS;
}
2 changes: 2 additions & 0 deletions tinytest/tinytest.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,5 +532,7 @@ extern void tt_test_ptr(const char *file, int line, const char *aexpr,
#define TT_SUITE_RUN(S) \
tt_suite_run(__suite__ ## S)

#define TT_SUITE_NUM_FAILURES(S) \
__suite__ ## S->num_failures

#endif // __tinytest_h

0 comments on commit 0b2e8ca

Please sign in to comment.