From 0a60c39c32e9403b114ef2398f023cdeadfdf7be Mon Sep 17 00:00:00 2001 From: Ruben Laguna Date: Fri, 6 Feb 2015 17:10:11 +0100 Subject: [PATCH] Example 'make check' --- .gitignore | 12 ++++++++---- Makefile.am | 11 +++++++++++ configure.ac | 2 ++ tests/test.c | 10 ++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 tests/test.c diff --git a/.gitignore b/.gitignore index 769505c..4a2a888 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -INSTALL +.deps +.dirstamp Makefile Makefile.in aclocal.m4 @@ -12,7 +13,6 @@ configure depcomp install-sh missing -src/.deps/ src/Makefile src/Makefile.in src/*.o @@ -20,5 +20,9 @@ src/myexecutable stamp-h1 *~ myexecutable -.dirstamp - +test-driver +test-suite.log +tests/*.o +testsuite +testsuite.log +testsuite.trs diff --git a/Makefile.am b/Makefile.am index 859e9ae..996bdb6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,3 +4,14 @@ bin_PROGRAMS = myexecutable myexecutable_SOURCES = \ src/main.c myexecutable_CFLAGS = #--std=c11 # CFLAGS applicable to myexecutable_SOURCES + +# Tests +# 'check' comes from 'make check' +check_PROGRAMS = testsuite # will generate and run testsuite exec + +testsuite_CFLAGS = $(DEPS_CFLAGS) # DEPS_* are filled by PKG_CHECK_MODULES +testsuite_LIBS = $(DEPS_LIBS) # in configure.ac + +testsuite_SOURCES = tests/test.c +TESTS = testsuite + diff --git a/configure.ac b/configure.ac index 41671df..40de5bd 100644 --- a/configure.ac +++ b/configure.ac @@ -44,5 +44,7 @@ AC_CHECK_HEADER([stdlib.h]) # Checks for library functions. +PKG_CHECK_MODULES([DEPS], [glib-2.0 >= 2.24.1]) # use pkg-config to fill DEPS_CFLAGS and DEPS_LIBS + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/tests/test.c b/tests/test.c new file mode 100644 index 0000000..9e6a421 --- /dev/null +++ b/tests/test.c @@ -0,0 +1,10 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + printf("Write some tests!!! Failing!\n"); + exit(EXIT_FAILURE); + return 0; +}