From cbf1ba38794ab6a323441dcc3b0e5e942f7ab386 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 1 Jan 2023 14:53:05 +0100 Subject: Added CompiledSQL class, Test coverage --- tests/Makefile | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/Makefile b/tests/Makefile index 1f912c3..e36198b 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,18 @@ +CXXFLAGS=-g -O0 + +ifeq ($(CXX),clang++-14) +CXXFLAGS+=-fprofile-instr-generate -fcoverage-mapping +else +# GCC +CXXFLAGS+=--coverage +endif + include ../common.mk +LDFLAGS+=-fprofile-instr-generate -fcoverage-mapping + +UNITS=storage.cpp config.cpp file.cpp compiledsql.cpp qrcode.cpp whiteboard.cpp + UNITTESTS=test-config.cpp \ test-storage.cpp @@ -11,14 +24,40 @@ CXXFLAGS+=\ -I.. test: unittests - ./unittests + # https://clang.llvm.org/docs/SourceBasedCodeCoverage.html +ifeq ($(CXX),clang++-14) + LLVM_PROFILE_FILE="unittests.profraw" ./unittests + llvm-profdata-14 merge -sparse unittests.profraw -o unittests.profdata + llvm-cov-14 report --ignore-filename-regex='google' --ignore-filename-regex='test-' --show-region-summary=0 -instr-profile unittests.profdata unittests +endif + +coverage: + llvm-cov-14 show -instr-profile unittests.profdata $(UNITS:.cpp=.o) -unittests: libgmock.a $(UNITTESTS:.cpp=.o) ../config.o ../file.o ../storage.o +unittests: libgmock.a $(UNITTESTS:.cpp=.o) $(UNITS:.cpp=.o) $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@ %.o: %.cpp $(CXX) $(CXXFLAGS) -o $@ -c $< +config.o: ../config.cpp + $(CXX) $(CXXFLAGS) -o $@ -c $< + +file.o: ../file.cpp + $(CXX) $(CXXFLAGS) -o $@ -c $< + +storage.o: ../storage.cpp + $(CXX) $(CXXFLAGS) -o $@ -c $< + +compiledsql.o: ../compiledsql.cpp + $(CXX) $(CXXFLAGS) -o $@ -c $< + +whiteboard.o: ../whiteboard.cpp + $(CXX) $(CXXFLAGS) -o $@ -c $< + +qrcode.o: ../qrcode.cpp + $(CXX) $(CXXFLAGS) -o $@ -c $< + libgmock.a: $(CXX) $(CXXFLAGS) -c /usr/src/googletest/googletest/src/gtest-all.cc $(CXX) $(CXXFLAGS) -c /usr/src/googletest/googlemock/src/gmock-all.cc @@ -26,4 +65,4 @@ libgmock.a: ar -rv libgmock.a gmock-all.o gtest-all.o gmock_main.o clean: - -rm -f *.o *.a unittests + -rm -f *.o *.a unittests *.gcno *.profraw *.profdata -- cgit v1.2.3