From 9f390a356ea464183cc11ef44c48968ccdcd36ac Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 25 May 2011 20:22:46 +0200 Subject: [PATCH] unit tests: build adjustment Also define UNITTESTS macro when building unit test sources. Fixing compiler warning: external definition with no prior declaration --- tests/libtest/first.c | 3 +++ tests/libtest/test.h | 3 +++ tests/unit/Makefile.am | 8 ++++---- tests/unit/Makefile.inc | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/libtest/first.c b/tests/libtest/first.c index a6f8e3cc26..205d3943ff 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -49,7 +49,10 @@ char *libtest_arg2=NULL; char *libtest_arg3=NULL; int test_argc; char **test_argv; + +#ifdef UNITTESTS int unitfail; /* for unittests */ +#endif int main(int argc, char **argv) { diff --git a/tests/libtest/test.h b/tests/libtest/test.h index e9638a240a..33d7bed836 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -73,3 +73,6 @@ extern int select_test(int num_fds, fd_set *rd, fd_set *wr, fd_set *exc, extern int test(char *URL); /* the actual test function provided by each individual libXXX.c file */ +#ifdef UNITTESTS +extern int unitfail; +#endif diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index bdee6c102f..cdd32a5e15 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -40,7 +40,7 @@ INCLUDES = -I$(top_builddir)/include/curl \ -I$(top_srcdir)/include \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib \ - -I$(top_srcdir)/tests/libtest \ + -I$(top_srcdir)/tests/libtest \ -I$(top_builddir)/ares \ -I$(top_srcdir)/ares else @@ -49,16 +49,16 @@ INCLUDES = -I$(top_builddir)/include/curl \ -I$(top_srcdir)/include \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib \ - -I$(top_srcdir)/tests/libtest + -I$(top_srcdir)/tests/libtest endif if CURLDEBUG EXTRA_DIST = Makefile.inc -LDADD = $(top_builddir)/tests/libtest/first.o $(top_builddir)/lib/libcurlu.la \ - @CURL_LIBS@ +LDADD = $(top_builddir)/lib/libcurlu.la @CURL_LIBS@ DEPENDENCIES = $(top_builddir)/lib/libcurlu.la +CFLAGS += -DUNITTESTS # Makefile.inc provides the source defines (TESTUTIL, SUPPORTFILES, # noinst_PROGRAMS, lib*_SOURCES, and lib*_CFLAGS) diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index aef6871130..ff85e7b374 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -1,6 +1,8 @@ # these files are used in every single unit test program -UNITFILES = curlcheck.h +UNITFILES = curlcheck.h \ + $(top_srcdir)/tests/libtest/test.h \ + $(top_srcdir)/tests/libtest/first.c # These are all unit test programs noinst_PROGRAMS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307