Make an automake testsuite
authorFrank Zago <fzago@cray.com>
Thu, 19 Mar 2015 18:40:29 +0000 (13:40 -0500)
committerFrank Zago <fzago@cray.com>
Thu, 19 Mar 2015 21:07:57 +0000 (16:07 -0500)
Add the existing tests and the examples. The testsuite is then run with
"make check".

examples/c++/Makefile.am
examples/c/Makefile.am
tests/Makefile.am
tests/tests.c
tinytest/tinytest.h

index 5e0ae0d..8b62024 100644 (file)
@@ -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
 
index abbcdae..783e255 100644 (file)
@@ -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
 
index cd64cc1..0b7fafc 100644 (file)
@@ -1,5 +1,7 @@
 
-noinst_PROGRAMS = libconfig_tests
+check_PROGRAMS = libconfig_tests
+noinst_PROGRAMS=$(check_PROGRAMS)
+TESTS = $(check_PROGRAMS)
 
 libconfig_tests_SOURCES = tests.c
 
index e13e67f..a8cb5b8 100644 (file)
@@ -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;
 }
index 562600e..10c63c2 100644 (file)
@@ -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