Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. -include ../../../mconfig
  2. objects = cptests.o
  3. parent_test_objects = ../test-bpsys.o ../test-dinit.o
  4. parent_objs = control.o dinit-log.o service.o load-service.o proc-service.o baseproc-service.o run-child-proc.o
  5. check: build-tests run-tests
  6. build-tests: prepare-incdir cptests
  7. run-tests: cptests
  8. ./cptests
  9. # Create an "includes" directory populated with a combination of real and mock headers:
  10. prepare-incdir:
  11. mkdir -p includes
  12. rm -rf includes/*.h
  13. cd includes; ln -f ../../../includes/*.h .
  14. cd includes; ln -f ../../test-includes/dinit.h .
  15. cd includes; ln -f ../../test-includes/baseproc-sys.h .
  16. cptests: cptests.o $(parent_objs) $(parent_test_objs)
  17. $(CXX) $(SANITIZEOPTS) -o cptests cptests.o $(parent_test_objects) $(parent_objs) $(CXXOPTS) $(LDFLAGS)
  18. $(objects): %.o: %.cc
  19. $(CXX) $(CXXOPTS) $(SANITIZEOPTS) -MMD -MP -Iincludes -I../../../dasynq/include -I../../../build/includes -c $< -o $@
  20. $(parent_objs): %.o: ../../%.cc
  21. $(CXX) $(CXXOPTS) $(SANITIZEOPTS) -MMD -MP -Iincludes -I../../../dasynq/include -I../../../build/includes -c $< -o $@
  22. clean:
  23. rm -f *.o *.d cptests
  24. # Experimental LLVM-libFuzzer based fuzzer. "make fuzz" to build; "fuzz corpus" to run (and store
  25. # interesting test data in "corpus" directory).
  26. fuzz_parent_test_objects = $(foreach obj,$(notdir $(parent_test_objects)),fuzz-$(obj))
  27. fuzz_objects = $(foreach obj,$(parent_objs),fuzz-$(obj))
  28. fuzz: fuzz.cc $(fuzz_parent_test_objects) $(fuzz_objects)
  29. clang++ -std=c++11 -g -O1 -Iincludes -I../../dasynq -fsanitize=fuzzer,address,undefined,leak fuzz.cc $(fuzz_parent_test_objects) $(fuzz_objects) -o fuzz
  30. $(fuzz_parent_test_objects): fuzz-%.o: ../%.cc
  31. clang -O1 -fsanitize=address,undefined,fuzzer-no-link,leak -MMD -MP -I../includes -I../../dasynq -c $< -o $@
  32. $(fuzz_objects): fuzz-%.o: ../../%.cc
  33. clang -O1 -fsanitize=address,undefined,fuzzer-no-link,leak -MMD -MP -Iincludes -I../../dasynq -c $< -o $@
  34. -include $(objects:.o=.d)
  35. -include $(parent_objects:.o=.d)