From: Davin McCall Date: Fri, 16 Jun 2017 20:13:36 +0000 (+0100) Subject: Allow "make check" to run tests. X-Git-Tag: v0.06~56 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a6e90067ebf8aaa4567cad9db3574029fd871320;p=oweals%2Fdinit.git Allow "make check" to run tests. --- diff --git a/Makefile b/Makefile index e764dee..187794e 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,9 @@ all: $(MAKE) -C src all +check: + $(MAKE) -C src check + install: $(MAKE) -C src install $(MAKE) -C doc/manpages install diff --git a/src/Makefile b/src/Makefile index 338deb2..e308ec6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -22,6 +22,9 @@ shutdown: shutdown.o $(objects): %.o: %.cc $(CXX) $(CXXOPTS) -Idasynq -c $< -o $@ +check: $(objects) + $(MAKE) -C tests check + install: all install -d $(DESTDIR)/sbin install -s dinit dinitctl $(SHUTDOWN) $(DESTDIR)/sbin @@ -30,8 +33,9 @@ ifeq ($(BUILD_SHUTDOWN),yes) endif clean: - rm -f *.o + rm -f *.o *.d rm -f dinit dinitctl shutdown + $(MAKE) -C tests clean $(objects:.o=.d): %.d: %.cc $(CXX) $(CXXOPTS) -Idasynq -MM -MG -MF $@ $< diff --git a/src/tests/Makefile b/src/tests/Makefile index 5e12ac0..dea221a 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile @@ -3,6 +3,9 @@ objects = tests.o parent_objs = ../service.o ../control.o ../dinit-log.o ../load_service.o ../dinit.o +check: build-tests + ./tests + build-tests: tests tests: $(objects) @@ -12,7 +15,7 @@ $(objects): %.o: %.cc $(CXX) $(CXXOPTS) -I.. -I../dasynq -c $< -o $@ clean: - rm -f *.o + rm -f *.o *.d $(objects:.o=.d): %.d: %.cc $(CXX) $(CXXOPTS) -I.. -I../dasynq -MM -MG -MF $@ $< diff --git a/src/tests/tests.cc b/src/tests/tests.cc index 93e701b..12e2095 100644 --- a/src/tests/tests.cc +++ b/src/tests/tests.cc @@ -1,4 +1,6 @@ #include +#include + #include "service.h" void test1() @@ -73,6 +75,11 @@ void test2() int main(int argc, char **argv) { + std::cout << "test1... "; test1(); + std::cout << "PASSED" << std::endl; + + std::cout << "test2... "; test2(); + std::cout << "PASSED" << std::endl; }