From: Davin McCall Date: Fri, 12 Jan 2018 20:21:07 +0000 (+0000) Subject: tests: infrastructure for implementing mock headers. X-Git-Tag: v0.08~48 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=77ef4236c4b59e1bb0a0b874755fee381b757191;p=oweals%2Fdinit.git tests: infrastructure for implementing mock headers. We need to duplicate the header directory entirely in order to be able to replace header 'xyz.h' (so that 'include "xyz.h"' in other, real, headers resolves to the mock). --- diff --git a/.gitignore b/.gitignore index 00101ac..f838254 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ test shutdown dinit-reboot src/tests/tests +src/tests/includes \ No newline at end of file diff --git a/src/tests/Makefile b/src/tests/Makefile index 3769557..1688ac0 100644 --- a/src/tests/Makefile +++ b/src/tests/Makefile @@ -1,26 +1,33 @@ -include ../../mconfig objects = tests.o test-dinit.o -parent_objs = service.o baseproc-service.o proc-service.o control.o dinit-log.o load_service.o # dinit.o +parent_objs = service.o baseproc-service.o proc-service.o dinit-log.o load_service.o check: build-tests ./tests -build-tests: tests +build-tests: prepare-incdir tests + +# Create an "includes" directory populated with a combination of real and mock headers: +prepare-incdir: + mkdir -p includes + rm -rf includes/*.h + cd includes; ln -sf ../../includes/*.h . + cd includes; ln -sf ../test-includes/*.h . tests: $(objects) $(parent_objs) $(CXX) $(SANITIZEOPTS) -o tests $(objects) $(parent_objs) $(EXTRA_LIBS) $(objects): %.o: %.cc - $(CXX) $(CXXOPTS) $(SANITIZEOPTS) -I../includes -I../dasynq -c $< -o $@ + $(CXX) $(CXXOPTS) $(SANITIZEOPTS) -Iincludes -I../dasynq -c $< -o $@ $(parent_objs): %.o: ../%.cc - $(CXX) $(CXXOPTS) $(SANITIZEOPTS) -I../includes -I../dasynq -c $< -o $@ + $(CXX) $(CXXOPTS) $(SANITIZEOPTS) -Iincludes -I../dasynq -c $< -o $@ clean: rm -f *.o *.d $(objects:.o=.d): %.d: %.cc - $(CXX) $(CXXOPTS) -I../includes -I../dasynq -MM -MG -MF $@ $< + $(CXX) $(CXXOPTS) -Iincludes -I../dasynq -MM -MG -MF $@ $< include $(objects:.o=.d) diff --git a/src/tests/test-includes/control.h b/src/tests/test-includes/control.h new file mode 100644 index 0000000..4a8c36e --- /dev/null +++ b/src/tests/test-includes/control.h @@ -0,0 +1,14 @@ +// dummy control.h + +#include "dinit.h" + +class service_set; + +class control_conn_t +{ + public: + control_conn_t(eventloop_t &loop, service_set * services_p, int fd) + { + // active_control_conns++; + } +};