[icinga-checkins] icinga.org: icinga-core/rbartels/1.3: t-tap: Make test Makefile readable and sane (Andreas Ericsson)

git at icinga.org git at icinga.org
Thu Nov 11 19:54:25 CET 2010


Module: icinga-core
Branch: rbartels/1.3
Commit: 2e6fa78e6e4650185e38280321aba52c8f18a17c
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=2e6fa78e6e4650185e38280321aba52c8f18a17c

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Mon Oct 25 15:46:05 2010 +0200

t-tap: Make test Makefile readable and sane (Andreas Ericsson)

We get rid of the ridiculously long lines and break things up a
little. We also utilize the Makefile auto-variable $^ when linking
and rely on the internal %.o: %.c buildrule to create the object
files for us.

In order to make this work, we have to sanitize test_checks so that
it doesn't #include the entire sourcefile it links to. Since one
still has to build Nagios (and the cgi's) before running the tests,
we can avoid double-building by linking to the build-product instead.

Signed-off-by: Andreas Ericsson <ae at op5.se>

Author: Andreas Ericsson <ae at op5.se>

---

 t-tap/Makefile.in   |   46 ++++++++++++++++++++++++++++++----------------
 t-tap/test_checks.c |   10 +++++++++-
 2 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/t-tap/Makefile.in b/t-tap/Makefile.in
index 4770cd7..88a6d0b 100644
--- a/t-tap/Makefile.in
+++ b/t-tap/Makefile.in
@@ -12,9 +12,23 @@ CC=@CC@
 CFLAGS=@CFLAGS@ @DEFS@ -DNSCORE -I../include -I../tap/src
 TAPOBJ=../tap/src/tap.o
 
-TESTS = test_logging test_events test_timeperiods test_icinga_config test_xsddefault test_checks
+TESTS = test_logging test_events test_timeperiods test_icinga_config
+TESTS += test_xsddefault test_checks
+
+XSD_OBJS = $(SRC_CGI)/statusdata-cgi.o $(SRC_CGI)/xstatusdata-cgi.o
+XSD_OBJS += $(SRC_CGI)/objects-cgi.o $(SRC_CGI)/xobjects-cgi.o
+XSD_OBJS += $(SRC_CGI)/comments-cgi.o $(SRC_CGI)/downtime-cgi.o
+XSD_OBJS += $(SRC_CGI)/cgiutils.o $(SRC_CGI)/skiplist.o ../common/shared.o
+
+TP_OBJS = $(SRC_BASE)/utils.o $(SRC_BASE)/config.o $(SRC_BASE)/macros-base.o
+TP_OBJS += $(SRC_BASE)/objects-base.o $(SRC_BASE)/xobjects-base.o
+TP_OBJS += $(SRC_BASE)/skiplist.o ../common/shared.o
+
+CFG_OBJS = $(TP_OBJS)
+CFG_OBJS += $(SRC_BASE)/comments-base.o $(SRC_BASE)/xcomments-base.o
+CFG_OBJS += $(SRC_BASE)/downtime-base.o $(SRC_BASE)/xdowntime-base.o
+CFG_OBJS += $(SRC_BASE)/retention-base.o $(SRC_BASE)/xretention-base.o
 
-test_xsddefault_OBJS = ${SRC_CGI}/xstatusdata-cgi.o ${SRC_CGI}/cgiutils.o ${SRC_CGI}/comments-cgi.o ${SRC_CGI}/objects-cgi.o ${SRC_CGI}/skiplist.o ${SRC_CGI}/statusdata-cgi.o ${SRC_CGI}/downtime-cgi.o ${SRC_CGI}/xobjects-cgi.o
 
 LDFLAGS=@LDFLAGS@
 LIBS=@LIBS@
@@ -71,26 +85,26 @@ all: $(TESTS)
 
 ########## TESTS ##########
 
-test_logging: test_logging.c $(SRC_BASE)/logging.o
-	$(CC) $(CFLAGS) -o $@ test_logging.c $(SRC_BASE)/logging.o $(TAPOBJ) $(LDFLAGS)
+test_logging: test_logging.o $(SRC_BASE)/logging.o $(TAPOBJ)
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 
-test_events: test_events.c $(SRC_BASE)/events.o
-	$(CC) $(CFLAGS) -o $@ test_events.c $(SRC_BASE)/events.o $(TAPOBJ) $(LDFLAGS) $(MATHLIBS)
+test_events: test_events.o $(SRC_BASE)/events.o $(TAPOBJ)
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(MATHLIBS) $(LIBS)
 
-test_checks: test_checks.c $(SRC_BASE)/checks.c
-	$(CC) $(CFLAGS) -o $@ test_checks.c $(TAPOBJ) $(LDFLAGS) $(MATHLIBS) $(LIBS)
+test_checks: test_checks.o $(SRC_BASE)/checks.o $(TAPOBJ)
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(MATHLIBS) $(LIBS)
 
-test_freshness: test_freshness.o $(SRC_BASE)/freshness.o
-	$(CC) $(CFLAGS) -o $@ test_freshness.c $(SRC_BASE)/freshness.o
+test_freshness: test_freshness.o $(SRC_BASE)/freshness.o $(TAPOBJ)
+	$(CC) $(CFLAGS) -o $@ $^
 
-test_icinga_config: test_icinga_config.c $(SRC_BASE)/utils.o ${SRC_BASE}/config.o ${SRC_BASE}/macros-base.o ${SRC_BASE}/objects-base.o ${SRC_BASE}/skiplist.o ${SRC_BASE}/xobjects-base.o
-	$(CC) $(CFLAGS) -o $@ test_icinga_config.c $(SRC_BASE)/utils.o ${SRC_BASE}/config.o ${SRC_BASE}/macros-base.o ${SRC_BASE}/objects-base.o ${SRC_BASE}/skiplist.o ${SRC_BASE}/xobjects-base.o $(TAPOBJ) $(BROKER_LDFLAGS) $(LDFLAGS) $(MATHLIBS) $(SOCKETLIBS) $(THREADLIBS) $(BROKERLIBS) $(LIBS)
+test_icinga_config: test_icinga_config.o $(CFG_OBJS) $(TAPOBJ)
+	$(CC) $(CFLAGS) -o $@ $^ $(BROKER_LDFLAGS) $(LDFLAGS) $(MATHLIBS) $(SOCKETLIBS) $(THREADLIBS) $(BROKERLIBS) $(LIBS)
 
-test_timeperiods: test_timeperiods.c $(SRC_BASE)/utils.o ${SRC_BASE}/config.o ${SRC_BASE}/macros-base.o ${SRC_BASE}/objects-base.o ${SRC_BASE}/skiplist.o ${SRC_BASE}/xobjects-base.o
-	$(CC) $(CFLAGS) -o $@ test_timeperiods.c $(SRC_BASE)/utils.o ${SRC_BASE}/config.o ${SRC_BASE}/macros-base.o ${SRC_BASE}/objects-base.o ${SRC_BASE}/skiplist.o ${SRC_BASE}/xobjects-base.o $(TAPOBJ) $(BROKER_LDFLAGS) $(LDFLAGS) $(MATHLIBS) $(SOCKETLIBS) $(THREADLIBS) $(BROKERLIBS) $(LIBS)
+test_timeperiods: test_timeperiods.o $(TP_OBJS) $(TAPOBJ)
+	$(CC) $(CFLAGS) -o $@ $^ $(BROKER_LDFLAGS) $(LDFLAGS) $(MATHLIBS) $(SOCKETLIBS) $(THREADLIBS) $(BROKERLIBS) $(LIBS)
 
-test_xsddefault: test_xsddefault.c ${test_xsddefault_OBJS}
-	$(CC) $(CFLAGS) -o $@ test_xsddefault.c $(TAPOBJ) ${test_xsddefault_OBJS}
+test_xsddefault: test_xsddefault.o $(XSD_OBJS) $(TAPOBJ)
+	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 
 test: $(TESTS)
 	HARNESS_PERL=./test_each.t perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(@ARGV)' $(TESTS)
diff --git a/t-tap/test_checks.c b/t-tap/test_checks.c
index d46460e..59517e3 100644
--- a/t-tap/test_checks.c
+++ b/t-tap/test_checks.c
@@ -17,7 +17,15 @@
 *****************************************************************************/
 
 #define NSCORE 1
-#include "../base/checks.c"
+#include "config.h"
+#include "comments.h"
+#include "common.h"
+#include "statusdata.h"
+#include "downtime.h"
+#include "macros.h"
+#include "icinga.h"
+#include "broker.h"
+#include "perfdata.h"
 #include "tap.h"
 
 /* Test specific functions + variables */





More information about the icinga-checkins mailing list