diff --git a/.gitHooks/pre-commit b/.gitHooks/pre-commit index 208f0ea..307746d 100644 --- a/.gitHooks/pre-commit +++ b/.gitHooks/pre-commit @@ -4,7 +4,7 @@ # availabilty of python py=$(which py || which python || which python3) if [[ -z $py ]] -then +then echo "No python found" exit 0 fi @@ -15,22 +15,22 @@ cd $(git rev-parse --show-toplevel) # path to sompy python scripts sompy=$(pwd)/submodules/sompy/somutil -# files regarded as text files to be cleaned -txts= -# extensions of text files sorted by likeliness -xtxt="h cpp cmd py md lua sh yml" +# files to skip +skips="make/*" + +txts=() for file in $(git diff-index --cached --name-only HEAD); do - if [[ -f $file ]] - then - for ext in $xtxt; do - if [[ $file == *.$ext ]]; then txts="$txts $file"; break; fi + if [ -f $file ]; then + ok=true + for s in $skips; do + if [[ $file == $s ]]; then ok=false; break; fi done + if $ok; then txts+=($file); fi fi done -if [[ -n $txts ]]; then - echo cleaning text files - $py $sompy/cleanTxt.py -l $txts -fi -for file in $txts; do git add $file; done +echo txt: ${#txts[@]} +done=$($py $sompy/cleanTxt.py -le ${txts[@]}) + +for file in $done; do git add $file; done diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index e5013f1..c4972fb 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -20,4 +20,4 @@ jobs: uses: actions/checkout@v3 - name: ci - run: cd make; chmod +x ci.sh; ./ci.sh + run: cd scripts; chmod +x ci.sh; ./ci.sh diff --git a/.gitignore b/.gitignore index eacaffe..5d2df0e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,11 @@ MON.* *.log tmp* *.ctc +vs + +# python +*.pyc +__pycache__ # Prerequisites *.d @@ -50,4 +55,3 @@ tmp* *.exe *.out *.app - diff --git a/README.md b/README.md index b9b31bc..0c1ea4c 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,4 @@ C++ code collection to evaluate coverage tools - headers - sources - test execution code -- [make and run section](make/README.md) for Bullseye and CTC++ +- [make and run section](scripts/README.md) for Bullseye and CTC++ diff --git a/code/CoverageMacro.h b/code/CoverageMacro.h index 2894650..26cc9db 100644 --- a/code/CoverageMacro.h +++ b/code/CoverageMacro.h @@ -3,41 +3,30 @@ #define COVERAGE_MACRO_H #include -#include -#define MODULE_TEST +#define MAX(V1, V2) (((V1) > (V2)) ? (V1) : (V2)) -// private members and public getters +// private members, public getters and setters #define MEMBER(TYPE, NAME, VAL) \ private: TYPE m ## NAME = VAL; \ -public: inline TYPE get ## NAME() const { return m ## NAME; } - -// in module test also public setters -#ifdef MODULE_TEST -#define SETTER(TYPE, NAME) \ -public: inline void set ## NAME(const TYPE val) { m ## NAME = val; } -#else -#define SETTER(TYPE, NAME) -#endif +public: \ +inline TYPE get ## NAME() const { return m ## NAME; } \ +inline void set ## NAME(const TYPE val) { m ## NAME = val; } class CoverageMacro { public: INSTANCE_DEC(CoverageMacro) + inline CoverageMacro(int i1=1, int i2=2): + mInt(MAX(i1, i2)) + {} + // members and getters MEMBER(bool, Bool1, false) MEMBER(int, Int1, 11) - // test code setters: no coverage - BULLSEY_PAUSE - #pragma CTC SKIP - - SETTER(bool, Bool1) - SETTER(int, Int1) - - #pragma CTC ENDSKIP - BULLSEY_RESUME + const int mInt; }; #endif // _H diff --git a/code/CoverageMcpp.h b/code/CoverageMcpp.h index ee07f20..5b3d0b9 100644 --- a/code/CoverageMcpp.h +++ b/code/CoverageMcpp.h @@ -69,4 +69,57 @@ class CoverageMcpp const SomeStruct mStruct; }; +template +class CoverageInline +{ +public: + CoverageInline() = delete; + inline static bool isNeg() { return IsNeg or I < 0; } + inline static int val() { return IsNeg ? Val : -Val; } + inline static bool func() + { + if constexpr (I < 0) + { + return true; + } + else + { + return false; + } + } + +private: + // static const bool and + const static bool IsNeg = B and I < 0; + // static const int ternary + const static int Val = IsNeg ? I : -I; +}; + +template +class CoverageConstExpr +{ +public: + CoverageConstExpr() = delete; + constexpr static bool isNeg() { return IsNeg or I < 0; } + constexpr static int val() { return IsNeg ? Val : -Val; } + constexpr static bool func() + { + if constexpr (I < 0) + { + return true; + } + else + { + return false; + } + } +private: + // static const bool and + constexpr static bool IsNeg = B and I < 0; + // static const int ternary + constexpr static int Val = IsNeg ? I : -I; +}; + + + #endif // _H diff --git a/code/CoverageTpl.h b/code/CoverageTpl.h index 3b52c4d..3f8d870 100644 --- a/code/CoverageTpl.h +++ b/code/CoverageTpl.h @@ -18,16 +18,24 @@ class CoverageTpl #define MAX(V1, V2) (((V1) > (V2)) ? (V1) : (V2)) template -class ByteBuffer +class ByteBufferHeap { public: - inline ByteBuffer(): + inline ByteBufferHeap(): mBytes(new unsigned char[MAX(sizeof(T1), sizeof(T2))]) {} - inline ~ByteBuffer() { delete[] mBytes; } + inline ~ByteBufferHeap() { delete[] mBytes; } private: unsigned char* mBytes; }; +template +class ByteBufferStack +{ +public: + inline ByteBufferStack() = default; +private: + unsigned char mBytes[MAX(sizeof(T1), sizeof(T2))]; +}; #endif // _H diff --git a/make/Bullseye_msbuild.cmd b/make/Bullseye_msbuild.cmd deleted file mode 100644 index 3c0a0c7..0000000 --- a/make/Bullseye_msbuild.cmd +++ /dev/null @@ -1,32 +0,0 @@ -@echo off -rem Bullsyey build, run & report -rem using msbuild, docopts, covbr2html -rem solution generated by premake5 - -SETLOCAL - -set _me=%~nx0 -set tool=bullseye -call %~dp0setup.cmd %* -if %errorlevel% NEQ 0 exit /b 0 - -set runSub=%myDir%\be_build_n_run.cmd -set covReport=%reportsDir%\coverage.txt -echo %DATE% %TIME% > %covReport% - -rem rebase to source dir -rem enable macros -set covcopt=--srcdir %srcDir% --macro - -if "%_args%"=="" ( - for %%f in (%testsDir%\*.cpp) do call %runSub% %%~nf -) else ( - for %%f in (%_args%) do call %runSub% %%f -) - -echo finish -%pyDir%\covbr2html\covbr2html.py -co %reportsDir% %buildDir%\todo_*.txt -echo report: %covReport% -echo. -echo %start% -echo %time% diff --git a/make/CTC_msbuild.cmd b/make/CTC_msbuild.cmd deleted file mode 100644 index 70b2e82..0000000 --- a/make/CTC_msbuild.cmd +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -rem CTC build, run & report -rem using ctclaunch msbuild, docopts -rem solution generated by premake5 - -SETLOCAL -set _me=%~nx0 -set tool=ctc -call %~dp0setup.cmd %* -if %errorlevel% NEQ 0 exit /b 0 - -call %myDir%\be_off.cmd - -set runSub=%myDir%\ctc_build_n_run.cmd -set ctclaunchParams=-C "NO_EXCLUDE+*\code\*" -C "CONST_INSTR = ON" -i m -set ctcreportParams=-t 98 -nsb -shorten-path %rootDir%\ -include-justifications -restrict-to-files "*/code/*" -measures f,mcdc -set msbuildParams=-p:TrackFileAccess=false -m -set monFile=%myDir%\MON.sym -set datFile=%myDir%\MON.dat - -if "%_args%"=="" ( - for %%f in (%testsDir%\*.cpp) do call %runSub% %%~nf -) else ( - for %%f in (%_args%) do call %runSub% %%f -) - -del /Q %monFile% %datFile% 2>NUL - -echo %start% -echo %time% diff --git a/make/Makefile b/make/Makefile index bb49fb4..2d88883 100644 --- a/make/Makefile +++ b/make/Makefile @@ -1,29 +1,30 @@ -# Alternative GNU Make workspace makefile autogenerated by Premake +# GNU Make workspace makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose SILENT = @ endif -ifeq ($(config),ci) - Test_Standard_config = ci - Test_Standard_Part_config = ci - Test_B_Macro_config = ci - Test_Count_config = ci - Test_Exclude_config = ci - Test_FD_SET_Macro_config = ci - Test_Macro_config = ci - Test_Mod_Cpp_config = ci - testlib_config = ci +ifeq ($(config),release) + Test_Standard_config = release + Test_Standard_Part_config = release + Test_B_Macro_config = release + Test_Count_config = release + Test_Exclude_config = release + Test_FD_SET_Macro_config = release + Test_Macro_config = release + Test_Mod_Cpp_config = release + Test_All_config = release + testlib_config = release else $(error "invalid configuration $(config)") endif -PROJECTS := Test_Standard Test_Standard_Part Test_B_Macro Test_Count Test_Exclude Test_FD_SET_Macro Test_Macro Test_Mod_Cpp testlib +PROJECTS := Test_Standard Test_Standard_Part Test_B_Macro Test_Count Test_Exclude Test_FD_SET_Macro Test_Macro Test_Mod_Cpp Test_All testlib .PHONY: all clean help $(PROJECTS) @@ -77,6 +78,12 @@ ifneq (,$(Test_Mod_Cpp_config)) @${MAKE} --no-print-directory -C . -f Test_Mod_Cpp.make config=$(Test_Mod_Cpp_config) endif +Test_All: testlib +ifneq (,$(Test_All_config)) + @echo "==== Building Test_All ($(Test_All_config)) ====" + @${MAKE} --no-print-directory -C . -f Test_All.make config=$(Test_All_config) +endif + testlib: ifneq (,$(testlib_config)) @echo "==== Building testlib ($(testlib_config)) ====" @@ -92,13 +99,14 @@ clean: @${MAKE} --no-print-directory -C . -f Test_FD_SET_Macro.make clean @${MAKE} --no-print-directory -C . -f Test_Macro.make clean @${MAKE} --no-print-directory -C . -f Test_Mod_Cpp.make clean + @${MAKE} --no-print-directory -C . -f Test_All.make clean @${MAKE} --no-print-directory -C . -f testlib.make clean help: @echo "Usage: make [config=name] [target]" @echo "" @echo "CONFIGURATIONS:" - @echo " ci" + @echo " release" @echo "" @echo "TARGETS:" @echo " all (default)" @@ -111,6 +119,7 @@ help: @echo " Test_FD_SET_Macro" @echo " Test_Macro" @echo " Test_Mod_Cpp" + @echo " Test_All" @echo " testlib" @echo "" @echo "For more information, see https://github.com/premake/premake-core/wiki" \ No newline at end of file diff --git a/make/README.md b/make/README.md deleted file mode 100644 index 900e51f..0000000 --- a/make/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# make and run section -## windows msbuild -### required tools for all scripts -- msbuild -- [premake5](https://premake.github.io/) -### prebuild -- call premake5 with your VS version to generate solution -- call premake5 --help to find out how -### build and run scripts -#### Bullseye_msbuild.cmd -- requires Bullseye coverage -- generates reports_bullseye folder - - coverage summary (covsrc) - - .cov files for coverage browser - - todo html files (covbr / covbr2html**) - - optional html folders -#### CTC_msbuild.cmd -- requires CTC++ -- generates reports_ctc folder - - simple html reports - - optional html folders -#### usage -call scripts with **-h** -## linux -currently only build and run script for github CI -- no tools required - -## covbr2html -** for information about covbr2html see [covbr2html repo](https://github.com/sorgom/covbr2html) diff --git a/make/Tests_Standard.make b/make/Test_All.make similarity index 53% rename from make/Tests_Standard.make rename to make/Test_All.make index 7bf466a..331b07e 100644 --- a/make/Tests_Standard.make +++ b/make/Test_All.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,20 +18,29 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build -TARGET = $(TARGETDIR)/Tests_Standard -OBJDIR = ../build/linux/ci/ci/Tests_Standard -DEFINES += -DNDEBUG +TARGETDIR = ../build/linux +TARGET = $(TARGETDIR)/Test_All +OBJDIR = ../build/linux/release/Test_All +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) -LIBS += -LDDEPS += -ALL_LDFLAGS += $(LDFLAGS) -s +LIBS += ../build/linux/lib/libtestlib.a +LDDEPS += ../build/linux/lib/libtestlib.a +ALL_LDFLAGS += $(LDFLAGS) -L../build/linux/lib -s LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) define PREBUILDCMDS endef @@ -50,14 +59,26 @@ endef GENERATED := OBJECTS := +GENERATED += $(OBJDIR)/CoverageMacro.o GENERATED += $(OBJDIR)/CoverageSrc.o -GENERATED += $(OBJDIR)/Tests_Standard.o -GENERATED += $(OBJDIR)/testMain.o -GENERATED += $(OBJDIR)/testlib.o +GENERATED += $(OBJDIR)/Test_B_Macro.o +GENERATED += $(OBJDIR)/Test_Count.o +GENERATED += $(OBJDIR)/Test_Exclude.o +GENERATED += $(OBJDIR)/Test_FD_SET_Macro.o +GENERATED += $(OBJDIR)/Test_Macro.o +GENERATED += $(OBJDIR)/Test_Mod_Cpp.o +GENERATED += $(OBJDIR)/Test_Standard.o +GENERATED += $(OBJDIR)/Test_Standard_Part.o +OBJECTS += $(OBJDIR)/CoverageMacro.o OBJECTS += $(OBJDIR)/CoverageSrc.o -OBJECTS += $(OBJDIR)/Tests_Standard.o -OBJECTS += $(OBJDIR)/testMain.o -OBJECTS += $(OBJDIR)/testlib.o +OBJECTS += $(OBJDIR)/Test_B_Macro.o +OBJECTS += $(OBJDIR)/Test_Count.o +OBJECTS += $(OBJDIR)/Test_Exclude.o +OBJECTS += $(OBJDIR)/Test_FD_SET_Macro.o +OBJECTS += $(OBJDIR)/Test_Macro.o +OBJECTS += $(OBJDIR)/Test_Mod_Cpp.o +OBJECTS += $(OBJDIR)/Test_Standard.o +OBJECTS += $(OBJDIR)/Test_Standard_Part.o # Rules # ############################################# @@ -67,7 +88,7 @@ all: $(TARGET) $(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR) $(PRELINKCMDS) - @echo Linking Tests_Standard + @echo Linking Test_All $(SILENT) $(LINKCMD) $(POSTBUILDCMDS) @@ -88,7 +109,7 @@ else endif clean: - @echo Cleaning Tests_Standard + @echo Cleaning Test_All ifeq (posix,$(SHELLTYPE)) $(SILENT) rm -f $(TARGET) $(SILENT) rm -rf $(GENERATED) @@ -121,16 +142,34 @@ endif # File Rules # ############################################# +$(OBJDIR)/CoverageMacro.o: ../code/CoverageMacro.cpp + @echo "$(notdir $<)" + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/CoverageSrc.o: ../code/CoverageSrc.cpp @echo "$(notdir $<)" $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/testMain.o: ../testlib/testMain.cpp +$(OBJDIR)/Test_B_Macro.o: ../tests/Test_B_Macro.cpp + @echo "$(notdir $<)" + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/Test_Count.o: ../tests/Test_Count.cpp + @echo "$(notdir $<)" + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/Test_Exclude.o: ../tests/Test_Exclude.cpp + @echo "$(notdir $<)" + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/Test_FD_SET_Macro.o: ../tests/Test_FD_SET_Macro.cpp + @echo "$(notdir $<)" + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/Test_Macro.o: ../tests/Test_Macro.cpp + @echo "$(notdir $<)" + $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/Test_Mod_Cpp.o: ../tests/Test_Mod_Cpp.cpp @echo "$(notdir $<)" $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/testlib.o: ../testlib/testlib.cpp +$(OBJDIR)/Test_Standard.o: ../tests/Test_Standard.cpp @echo "$(notdir $<)" $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/Tests_Standard.o: ../tests/Tests_Standard.cpp +$(OBJDIR)/Test_Standard_Part.o: ../tests/Test_Standard_Part.cpp @echo "$(notdir $<)" $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" diff --git a/make/Test_B_Macro.make b/make/Test_B_Macro.make index 3c47ed2..e3af172 100644 --- a/make/Test_B_Macro.make +++ b/make/Test_B_Macro.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build +TARGETDIR = ../build/linux TARGET = $(TARGETDIR)/Test_B_Macro -OBJDIR = ../build/linux/ci/Test_B_Macro -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/Test_B_Macro +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += ../build/linux/lib/libtestlib.a LDDEPS += ../build/linux/lib/libtestlib.a diff --git a/make/Test_Count.make b/make/Test_Count.make index 0392fe5..249db0a 100644 --- a/make/Test_Count.make +++ b/make/Test_Count.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build +TARGETDIR = ../build/linux TARGET = $(TARGETDIR)/Test_Count -OBJDIR = ../build/linux/ci/Test_Count -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/Test_Count +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += ../build/linux/lib/libtestlib.a LDDEPS += ../build/linux/lib/libtestlib.a diff --git a/make/Test_Exclude.make b/make/Test_Exclude.make index bb37ba8..77ce116 100644 --- a/make/Test_Exclude.make +++ b/make/Test_Exclude.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build +TARGETDIR = ../build/linux TARGET = $(TARGETDIR)/Test_Exclude -OBJDIR = ../build/linux/ci/Test_Exclude -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/Test_Exclude +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += ../build/linux/lib/libtestlib.a LDDEPS += ../build/linux/lib/libtestlib.a diff --git a/make/Test_FD_SET_Macro.make b/make/Test_FD_SET_Macro.make index 0dc5a96..96a86bd 100644 --- a/make/Test_FD_SET_Macro.make +++ b/make/Test_FD_SET_Macro.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build +TARGETDIR = ../build/linux TARGET = $(TARGETDIR)/Test_FD_SET_Macro -OBJDIR = ../build/linux/ci/Test_FD_SET_Macro -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/Test_FD_SET_Macro +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += ../build/linux/lib/libtestlib.a LDDEPS += ../build/linux/lib/libtestlib.a diff --git a/make/Test_Macro.make b/make/Test_Macro.make index 07934d7..ba24bee 100644 --- a/make/Test_Macro.make +++ b/make/Test_Macro.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build +TARGETDIR = ../build/linux TARGET = $(TARGETDIR)/Test_Macro -OBJDIR = ../build/linux/ci/Test_Macro -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/Test_Macro +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += ../build/linux/lib/libtestlib.a LDDEPS += ../build/linux/lib/libtestlib.a diff --git a/make/Test_Mod_Cpp.make b/make/Test_Mod_Cpp.make index 2e5f97f..11f57d4 100644 --- a/make/Test_Mod_Cpp.make +++ b/make/Test_Mod_Cpp.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build +TARGETDIR = ../build/linux TARGET = $(TARGETDIR)/Test_Mod_Cpp -OBJDIR = ../build/linux/ci/Test_Mod_Cpp -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/Test_Mod_Cpp +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += ../build/linux/lib/libtestlib.a LDDEPS += ../build/linux/lib/libtestlib.a diff --git a/make/Test_Runner.make b/make/Test_Runner.make deleted file mode 100644 index b428efe..0000000 --- a/make/Test_Runner.make +++ /dev/null @@ -1,135 +0,0 @@ -# Alternative GNU Make project makefile autogenerated by Premake - -ifndef config - config=ci -endif - -ifndef verbose - SILENT = @ -endif - -.PHONY: clean prebuild - -SHELLTYPE := posix -ifeq ($(shell echo "test"), "test") - SHELLTYPE := msdos -endif - -# Configurations -# ############################################# - -RESCOMP = windres -TARGETDIR = ../build -TARGET = $(TARGETDIR)/Test_Runner -OBJDIR = ../build/linux/ci/ci/Test_Runner -DEFINES += -DNDEBUG -INCLUDES += -I../testlib -I../code -FORCE_INCLUDE += -ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) -LIBS += -LDDEPS += -ALL_LDFLAGS += $(LDFLAGS) -s -LINKCMD = $(CXX) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) -define PREBUILDCMDS -endef -define PRELINKCMDS -endef -define POSTBUILDCMDS -endef - -# Per File Configurations -# ############################################# - - -# File sets -# ############################################# - -GENERATED := -OBJECTS := - -GENERATED += $(OBJDIR)/Test_Runner.o -GENERATED += $(OBJDIR)/testMain.o -GENERATED += $(OBJDIR)/testlib.o -OBJECTS += $(OBJDIR)/Test_Runner.o -OBJECTS += $(OBJDIR)/testMain.o -OBJECTS += $(OBJDIR)/testlib.o - -# Rules -# ############################################# - -all: $(TARGET) - @: - -$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR) - $(PRELINKCMDS) - @echo Linking Test_Runner - $(SILENT) $(LINKCMD) - $(POSTBUILDCMDS) - -$(TARGETDIR): - @echo Creating $(TARGETDIR) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(TARGETDIR) -else - $(SILENT) mkdir $(subst /,\\,$(TARGETDIR)) -endif - -$(OBJDIR): - @echo Creating $(OBJDIR) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) mkdir -p $(OBJDIR) -else - $(SILENT) mkdir $(subst /,\\,$(OBJDIR)) -endif - -clean: - @echo Cleaning Test_Runner -ifeq (posix,$(SHELLTYPE)) - $(SILENT) rm -f $(TARGET) - $(SILENT) rm -rf $(GENERATED) - $(SILENT) rm -rf $(OBJDIR) -else - $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) - $(SILENT) if exist $(subst /,\\,$(GENERATED)) del /s /q $(subst /,\\,$(GENERATED)) - $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) -endif - -prebuild: | $(OBJDIR) - $(PREBUILDCMDS) - -ifneq (,$(PCH)) -$(OBJECTS): $(GCH) | $(PCH_PLACEHOLDER) -$(GCH): $(PCH) | prebuild - @echo $(notdir $<) - $(SILENT) $(CXX) -x c++-header $(ALL_CXXFLAGS) -o "$@" -MF "$(@:%.gch=%.d)" -c "$<" -$(PCH_PLACEHOLDER): $(GCH) | $(OBJDIR) -ifeq (posix,$(SHELLTYPE)) - $(SILENT) touch "$@" -else - $(SILENT) echo $null >> "$@" -endif -else -$(OBJECTS): | prebuild -endif - - -# File Rules -# ############################################# - -$(OBJDIR)/testMain.o: ../testlib/testMain.cpp - @echo "$(notdir $<)" - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/testlib.o: ../testlib/testlib.cpp - @echo "$(notdir $<)" - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" -$(OBJDIR)/Test_Runner.o: ../tests/Test_Runner.cpp - @echo "$(notdir $<)" - $(SILENT) $(CXX) $(ALL_CXXFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" - --include $(OBJECTS:%.o=%.d) -ifneq (,$(PCH)) - -include $(PCH_PLACEHOLDER).d -endif \ No newline at end of file diff --git a/make/Test_Standard.make b/make/Test_Standard.make index 599c730..df44408 100644 --- a/make/Test_Standard.make +++ b/make/Test_Standard.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build +TARGETDIR = ../build/linux TARGET = $(TARGETDIR)/Test_Standard -OBJDIR = ../build/linux/ci/Test_Standard -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/Test_Standard +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += ../build/linux/lib/libtestlib.a LDDEPS += ../build/linux/lib/libtestlib.a diff --git a/make/Test_Standard_Part.make b/make/Test_Standard_Part.make index 6dc9459..a677fe5 100644 --- a/make/Test_Standard_Part.make +++ b/make/Test_Standard_Part.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres -TARGETDIR = ../build +TARGETDIR = ../build/linux TARGET = $(TARGETDIR)/Test_Standard_Part -OBJDIR = ../build/linux/ci/Test_Standard_Part -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/Test_Standard_Part +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += ../build/linux/lib/libtestlib.a LDDEPS += ../build/linux/lib/libtestlib.a diff --git a/make/be_build_n_run.cmd b/make/be_build_n_run.cmd deleted file mode 100644 index 211b0a7..0000000 --- a/make/be_build_n_run.cmd +++ /dev/null @@ -1,48 +0,0 @@ -@echo off -rem ======================================== -rem build and run sub -rem ======================================== -SETLOCAL -if "%_me%"=="" exit /b 1 - -set target=%1 - -echo %target% -echo - build -echo. >> %covReport% -echo === %target% >> %covReport% -set covfile=%reportsDir%\%target%.cov -del /Q %covfile% 2>NUL -msbuild %solution% -t:clean -m >NUL - -set buildLog=%buildDir%\be_build_%target%.log -cov01 -q1 -msbuild %solution% -t:%target% -m > %buildLog% 2>&1 -set elevel=%errorlevel% -cov01 -q0 -if %elevel% neq 0 ( - echo - build failed - echo - see %buildLog% - exit /b %elevel% -) else ( - del %buildLog% -) -echo - report -set exe=%buildDir%\%target%.exe -cd %srcDir% -rem reset coverage data -covclear -q -covselect -qd --import %myDir%\BullseyeCoverageExclusions -rem call executable without tests -%exe% -rem reports -covbr -qu --srcdir . > %buildDir%\todo_%target%.txt -if %_html% covhtml -q --allNum --srcdir . %reportsDir%\html_%target% -%exe% X >> %covReport% -covdir -q --srcdir . --checkmin 100,100 -if %errorlevel% neq 0 ( - covbr -qu --srcdir . > %buildDir%\todo_%target%_cov.txt - if %_html% covhtml -q --allNum --srcdir . %reportsDir%\html_%target%_cov -) -covsrc -q --srcdir . >> %covReport% -del %exe% diff --git a/make/be_off.cmd b/make/be_off.cmd deleted file mode 100644 index 5eabe55..0000000 --- a/make/be_off.cmd +++ /dev/null @@ -1,12 +0,0 @@ -@echo off -rem if cov01 installed: -rem - make sure Bullseye Coverage is off - -if "%tmpFile%" == "" exit /b 1 - -SETLOCAL - -call where cov01 | grep -c cov01.exe > %tmpFile% -set /p _beInstalled=<%tmpFile% - -if %_beInstalled% NEQ 0 call cov01 -q --off diff --git a/make/ctc_build_n_run.cmd b/make/ctc_build_n_run.cmd deleted file mode 100644 index f49e7b6..0000000 --- a/make/ctc_build_n_run.cmd +++ /dev/null @@ -1,40 +0,0 @@ -@echo off -rem ======================================== -rem build and run sub CTC -rem ======================================== -SETLOCAL -if "%_me%"=="" exit /b 1 - -set target=%1 - -echo %target% -echo - build -del /Q %monFile% %datFile% 2>NUL -msbuild %solution% -t:clean >NUL - -set buildLog=%buildDir%\ctc_build_%target%.log - -cd %myDir% - -ctclaunch %ctclaunchParams% msbuild %solution% -t:%target% %msbuildParams% > %buildLog% 2>&1 -if %errorlevel% neq 0 ( - echo - build failed - echo - see %buildLog% - exit /b %elevel% -) else ( - del %buildLog% -) -set exe=%buildDir%\%target%.exe - -echo - report -rem call executable without tests -%exe% -ctcreport.exe %ctcreportParams% -D ProjectName=%target% -template %myDir%\ctc_report.htm -o %reportsDir%\%target%.html >NUL -rem call executable with tests -%exe% X -ctcreport.exe %ctcreportParams% -D ProjectName=%target%_cov -template %myDir%\ctc_report.htm -o %reportsDir%\%target%_cov.html >NUL -if %_html% ( - ctcreport.exe %ctcreportParams% -D ProjectName=%target%_cov -o %reportsDir%\html_%target%_cov >NUL -) -del %exe% -echo. diff --git a/make/options.txt b/make/options.txt deleted file mode 100644 index 79add1f..0000000 --- a/make/options.txt +++ /dev/null @@ -1,5 +0,0 @@ -options: --c clean build and report folders --H generate HTML --l list targets --h this help diff --git a/make/setup.cmd b/make/setup.cmd deleted file mode 100644 index dd85e90..0000000 --- a/make/setup.cmd +++ /dev/null @@ -1,60 +0,0 @@ -@echo off - -if %_me%=="" exit /b 1 - -cd %~dp0 -set myDir=%cd% -cd .. -set rootDir=%cd% -set testsDir=%cd%\tests -set srcDir=%cd%\code -set buildDir=%cd%\build -set pyDir=%cd%\submodules\sompy -set reportsDir=%CD%\reports_%tool% - -set tmpCmd=%buildDir%\tmp.cmd -set tmpFile=%buildDir%\tmp.tmp - -set solution=%myDir%\Tests.sln - -if not exist %solution% ( - echo use premake5 to generate %solution% - exit /b 1 -) - -md %buildDir% 2>NUL - -set optsTxt=%myDir%\options.txt - -%pyDir%\somutil\docopts.py %optsTxt% %* > %tmpCmd% -if %errorlevel% neq 0 exit /b 1 -call %tmpCmd% -del %tmpCmd% 2>NUL - -rem help -if %_h% ( - echo usage: %_me% [options] [targets] - type %optsTxt% - exit /b 1 -) - -rem list targets -if %_l% ( - echo targets: - for %%f in (%testsDir%\*.cpp) do echo %%~nf - exit /b 1 -) - -rem clean build and reports -if %_c% ( - del /Q /S %buildDir% >NUL 2>&1 - del /Q /S %reportsDir% >NUL 2>&1 -) - -rem enable HTML (uppercase H option) -set _html=%_Hu% - -set start=%time% -md %reportsDir% 2>NUL - -exit /b 0 diff --git a/make/testlib.make b/make/testlib.make index 2a061c1..a66bd14 100644 --- a/make/testlib.make +++ b/make/testlib.make @@ -1,7 +1,7 @@ -# Alternative GNU Make project makefile autogenerated by Premake +# GNU Make project makefile autogenerated by Premake ifndef config - config=ci + config=release endif ifndef verbose @@ -18,16 +18,25 @@ endif # Configurations # ############################################# +ifeq ($(origin CC), default) + CC = gcc +endif +ifeq ($(origin CXX), default) + CXX = g++ +endif +ifeq ($(origin AR), default) + AR = ar +endif RESCOMP = windres TARGETDIR = ../build/linux/lib TARGET = $(TARGETDIR)/libtestlib.a -OBJDIR = ../build/linux/ci/testlib -DEFINES += -DNDEBUG +OBJDIR = ../build/linux/release/testlib +DEFINES += -DNDEBUG -D_COVERAGE_ON INCLUDES += -I../testlib -I../code FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MD -MP $(DEFINES) $(INCLUDES) -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -D_COVERAGE_ON +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) LIBS += LDDEPS += diff --git a/make/BullseyeCoverageExclusions b/scripts/BullseyeCoverageExclusions similarity index 100% rename from make/BullseyeCoverageExclusions rename to scripts/BullseyeCoverageExclusions diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt new file mode 100644 index 0000000..548d879 --- /dev/null +++ b/scripts/CMakeLists.txt @@ -0,0 +1,59 @@ +# ============================================================ +# CMake for CTC Coverage +# ============================================================ + +cmake_minimum_required(VERSION 3.7) + + +set (projektName CoverageTest) +project(${projektName}) + +set(REPO_PATH ${PROJECT_SOURCE_DIR}/..) +set(CODE_PATH ${REPO_PATH}/code) +set(TESTLIB_PATH ${REPO_PATH}/testlib) +set(TESTS_PATH ${REPO_PATH}/tests) +set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_LIST_DIR}) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_LIST_DIR}) + +include_directories ( + ${CODE_PATH} + ${TESTLIB_PATH} +) + +set(CMAKE_CXX_COMPILER_FORCED TRUE) +set(CMAKE_CXX_COMPILER "ctc") + +set(CMAKE_CXX_COMPILER_ARG1 "-C \"CONST_INSTR = ON\" -C \"NO_EXCLUDE+*\\code\\*\" -v -i m cl -c") + +find_library ( + CtcWin + NAMES ctcwin32.lib + HINTS C:/Testwell/CTC/Lib + NO_DEFAULT_PATH +) +file(GLOB testLibSrcs ${TESTLIB_PATH}/*.cpp) +add_library(_testlib OBJECT ${testLibSrcs}) + +add_executable(Test_Standard ${TESTS_PATH}/Test_Standard.cpp ${CODE_PATH}/CoverageSrc.cpp) +target_link_libraries(Test_Standard ${CtcWin} _testlib) + +add_executable(Test_Standard_Part ${TESTS_PATH}/Test_Standard_Part.cpp ${CODE_PATH}/CoverageSrc.cpp) +target_link_libraries(Test_Standard_Part ${CtcWin} _testlib) + +add_executable(Test_B_Macro ${TESTS_PATH}/Test_B_Macro.cpp) +target_link_libraries(Test_B_Macro ${CtcWin} _testlib) + +add_executable(Test_Count ${TESTS_PATH}/Test_Count.cpp) +target_link_libraries(Test_Count ${CtcWin} _testlib) + +add_executable(Test_Exclude ${TESTS_PATH}/Test_Exclude.cpp) +target_link_libraries(Test_Exclude ${CtcWin} _testlib) + +add_executable(Test_FD_SET_Macro ${TESTS_PATH}/Test_FD_SET_Macro.cpp) +target_link_libraries(Test_FD_SET_Macro ${CtcWin} _testlib) + +add_executable(Test_Macro ${TESTS_PATH}/Test_Macro.cpp ${CODE_PATH}/CoverageMacro.cpp) +target_link_libraries(Test_Macro ${CtcWin} _testlib) + +add_executable(Test_Mod_Cpp ${TESTS_PATH}/Test_Mod_Cpp.cpp) +target_link_libraries(Test_Mod_Cpp ${CtcWin} _testlib) diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..284aafa --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,50 @@ +# make and run section +## Windows / msbuild +### required tools on Windows +- msbuild / Developer Command Prompt +- [premake5](https://premake.github.io/) +- python 3 (associated with *.py) +### prebuild +- call premake5 with your VS version to generate solution +- call premake5 --help to find out how +### build and run scripts +#### coverage_Bullseye.py +- requires Bullseye coverage for Windows +- generates reports_Bullseye folder + - coverage summary (covsrc) + - coverage (.cov) files for coverage browser +#### coverage_CTC.py +- requires CTC++ for Windows +- generates reports_CTC folder + - simple html reports with simple template + - html folders with CTC html template +#### common usage +##### VS code +- setup Developer Command Prompt terminal see [howto](https://github.com/sorgom/howto/blob/dev/vscode/developer_command_prompt.md) +- start Developer Command Prompt terminal +- drag script into it +##### list of tests +- call scripts with **-l** for available tests +## linux / make Bullseye +### required tools on linux +- make, gcc +- python 3 +### build and run scripts +#### coverage_Bullseye.py +- requires Bullseye coverage for linux +- generates reports_Bullseye folder + - coverage summary (covsrc) + - coverage (.cov) files for coverage browser +#### usage +- build and run all tests +```shell +dev@linux:scripts$ python3 coverage_Bullseye.py +``` +- call script with **-l** for available tests +```shell +dev@linux:scripts$ python3 coverage_Bullseye.py -l +``` +- build and run some tests +```shell +dev@linux:scripts$ python3 coverage_Bullseye.py Test1 Test2 ... +``` diff --git a/make/ci.sh b/scripts/ci.sh similarity index 54% rename from make/ci.sh rename to scripts/ci.sh index 803ef57..9cd8866 100644 --- a/make/ci.sh +++ b/scripts/ci.sh @@ -1,10 +1,11 @@ #!/bin/bash # build & run for github CI cd $(dirname $0) +cd ../make make -j clean make -j echo "" -for cpp in $(ls ../tests/); do - ../build/${cpp%.cpp} X +for cpp in $(ls Test_*.make); do + ../build/linux/${cpp%.make} X done diff --git a/scripts/coverage_Bullseye.py b/scripts/coverage_Bullseye.py new file mode 100644 index 0000000..2e8ada6 --- /dev/null +++ b/scripts/coverage_Bullseye.py @@ -0,0 +1,49 @@ +"""ms build and run available tests with Bullseye coverage""" +from coverage_common import testList, call, proc, build, checkArgs, myDir, repo, srcDir, vsDir + +import atexit +from os import chdir, makedirs, environ +# from os.path import join +from sys import argv + +reportsDir = f'{repo}/reports_Bullseye' +report = f'{reportsDir}/coverage.md' +excludeFile = f'{myDir}/BullseyeCoverageExclusions' + +def covRestore(): + """restore cov01 setting""" + call('cov01 -q --pop') + +def buildAndRun(test:str, fh): + """build, run and report""" + environ['COVFILE'] = f'{reportsDir}/{test}.cov' + build(test) + call('covclear -q') + fh.write(f'### {test}\n```\n') + proc(f'{test} X', fh) + chdir(reportsDir) + call(f'covselect -qd --import {excludeFile}') + proc(f'covsrc -q --by-name', fh) + fh.write('```\n\n') + +def run(tests): + """run tests""" + makedirs(reportsDir, exist_ok=True) + with open(report, 'w') as fh: + atexit.register(covRestore) + environ['COVCOPT'] = f'--srcdir {srcDir} --macro -q' + call('cov01 -q --push') + + call('cov01 -q --off') + build('testlib') + + call('cov01 -q --on') + for test in tests: + buildAndRun(test, fh) + + fh.close() + +if __name__ == '__main__': + checkArgs() + build('clean') + run(argv[1:] or testList()) diff --git a/scripts/coverage_Bullseye_DO.py b/scripts/coverage_Bullseye_DO.py new file mode 100644 index 0000000..4450137 --- /dev/null +++ b/scripts/coverage_Bullseye_DO.py @@ -0,0 +1,24 @@ +""" +ms build and run tests with Bullseye coverage + +usage: this script [options] [tests] +options: +-c clean build and reports folder +-l list available tests +-h this help +""" +if __name__ == '__main__': + from coverage_Bullseye import run, reportsDir + from coverage_common import testList, build, showTests + import sompy + from docopts import docopts + + opts, args = docopts(__doc__) + if opts.get('l'): + showTests() + if opts.get('c'): + from shutil import rmtree + rmtree(reportsDir, ignore_errors=True) + build('clean') + + run(args or testList()) diff --git a/scripts/coverage_CTC.py b/scripts/coverage_CTC.py new file mode 100644 index 0000000..97d60be --- /dev/null +++ b/scripts/coverage_CTC.py @@ -0,0 +1,39 @@ +"""ms build and run available tests with CTC coverage""" +from coverage_common import testList, call, build, checkArgs, myDir, repo, binDir, vsDir, vsSolution +from os import chdir, makedirs, remove +from os.path import join, isfile +from sys import argv + +reportsDir = join(repo, 'reports_CTC') + +ctcLaunchParams = '-C "NO_EXCLUDE+*/code/*" -C "CONST_INSTR = ON" -i m' +ctcReportParams = f'-t 98 -nsb -shorten-path {repo}/ -include-justifications -restrict-to-files "*/code/*" -measures f,mcdc' +msBuildParams = '-p:TrackFileAccess=false -m' +monFile = 'MON.sym' +datFile = 'MON.dat' + +def reportTemplate(target): + """build report using template""" + call(f'ctcreport.exe {ctcReportParams} -D ProjectName={target} -template {join(myDir, 'ctc_report.htm')} -o {join(reportsDir, target)}.html') + +def buildAndRun(test:str): + """build, run and report""" + chdir(vsDir) + if isfile(monFile): remove(monFile) + if isfile(datFile): remove(datFile) + call(f'ctclaunch {ctcLaunchParams} msbuild {vsSolution} -t:{test} {msBuildParams}') + + exe = join(binDir, f'{test}.exe') + call(exe) + reportTemplate(test) + call(f'{exe} X') + reportTemplate(f'{test}_cov') + htmlDir = join(reportsDir, f'html_{test}_cov') + call(f'ctcreport.exe {ctcReportParams} -D ProjectName={test}_cov -o {htmlDir}') + +if __name__ == '__main__': + checkArgs() + makedirs(reportsDir, exist_ok=True) + build('clean') + for test in argv[1:] or testList(): + buildAndRun(test) diff --git a/scripts/coverage_common.py b/scripts/coverage_common.py new file mode 100644 index 0000000..0be0820 --- /dev/null +++ b/scripts/coverage_common.py @@ -0,0 +1,67 @@ +from glob import glob +from os import chdir, getcwd, system, name as oname, environ +from os.path import dirname, abspath, isfile +from subprocess import Popen, PIPE +from sys import argv + +isWin = oname == 'nt' +osSub = 'windows' if isWin else 'linux' + +chdir(dirname(abspath(__file__))) +myDir = getcwd() +chdir('..') +repo = getcwd() +buildDir = f'{repo}/build' +binDir = f'{buildDir}/{osSub}' +makeDir = f'{repo}/make' +vsDir = f'{repo}/vs' +vsSolution = f'{vsDir}/Tests.sln' +srcDir = f'{repo}/code' +testsDir = f'{repo}/tests' + +if isWin and not isfile(vsSolution): + print('not found:', vsSolution, 'use premake5 to generate', sep='\n') + exit(1) + +environ['PATH'] = f"{binDir}{';' if isWin else ':'}{environ['PATH']}" + +def testList(): + """return list of tests""" + if isWin: + chdir(vsDir) + return [c.replace('.vcxproj', '') for c in glob('Test_*.vcxproj')] + else: + chdir(makeDir) + return [c.replace('.make', '') for c in glob('Test_*.make')] + +def call(call:str): + if system(call) != 0: + print('call failed:', call) + exit(1) + +def proc(call:str, fh): + """run process to report""" + try: + with Popen(call.split(), stdout=PIPE, universal_newlines=True) as proc: + fh.write(proc.stdout.read()) + except Exception: + print('call failed:', call) + exit(1) + +def build(target): + """build target""" + if isWin: + chdir(vsDir) + call(f'msbuild -m {vsSolution} -t:{target}') + else: + call(f'make -j -C {makeDir} {target}') + +def showTests(): + """show available tests""" + print('available tests:', *testList(), sep='\n') + exit(0) + +def checkArgs(): + """show available tests with -l option""" + if '-l' in argv: + showTests() diff --git a/make/ctc_report.htm b/scripts/ctc_report.htm similarity index 98% rename from make/ctc_report.htm rename to scripts/ctc_report.htm index bf86429..05761d4 100644 --- a/make/ctc_report.htm +++ b/scripts/ctc_report.htm @@ -43,7 +43,6 @@ $Checkpoints$$Hits$$TER$% {CTC_LOOP_END("CoverageMeasures")} - + - diff --git a/make/premake5.lua b/scripts/premake5.lua similarity index 77% rename from make/premake5.lua rename to scripts/premake5.lua index 02c8a27..ee9fece 100644 --- a/make/premake5.lua +++ b/scripts/premake5.lua @@ -2,29 +2,35 @@ -- premake5 build rules for coverage test -- ============================================================ -buildoptions_vs = '/std:c++17 /MP /W4 /wd4100 /wd4103 /wd4068 /D_COVERAGE_ON' -buildoptions_gcc = '-std=c++17 -pedantic-errors -D_COVERAGE_ON' +buildoptions_vs = '/std:c++17 /MP /W4 /wd4100 /wd4103 /wd4068' +buildoptions_gcc = '-std=c++17 -pedantic-errors -Werror -Wall -Wno-unknown-pragmas' workspace 'Tests' - configurations { 'ci' } + configurations { 'release' } language 'C++' - targetdir '../build' objdir '../build/%{_TARGET_OS}' defines { 'NDEBUG' } kind 'ConsoleApp' includedirs { '../testlib', '../code' } + defines { '_COVERAGE_ON' } filter { 'action:vs*' } warnings 'high' buildoptions { buildoptions_vs } + location '../vs' filter { 'action:gmake*' } buildoptions { buildoptions_gcc } + location '../make' filter { 'kind:ConsoleApp' } + targetdir '../build/%{_TARGET_OS}' libdirs { '../build/%{_TARGET_OS}/lib' } links { 'testlib' } + filter { 'kind:StaticLib' } + targetdir '../build/%{_TARGET_OS}/lib' + project 'Test_Standard' files { '../tests/Test_Standard.cpp', '../code/CoverageSrc.cpp' } @@ -49,7 +55,9 @@ workspace 'Tests' project 'Test_Mod_Cpp' files { '../tests/Test_Mod_Cpp.cpp' } + project 'Test_All' + files { '../tests/*.cpp', '../code/*.cpp' } + project 'testlib' kind 'StaticLib' - targetdir '../build/%{_TARGET_OS}/lib' files { '../testlib/*.cpp' } diff --git a/scripts/sompy.py b/scripts/sompy.py new file mode 100644 index 0000000..1bbec22 --- /dev/null +++ b/scripts/sompy.py @@ -0,0 +1,6 @@ +# This file is used to add sompy/somutil to the sys.path +from sys import path as syspath +from os.path import dirname, abspath, join +sompy_path = abspath(join(dirname(__file__), '../submodules/sompy/somutil')) +if sompy_path not in syspath: + syspath.insert(0, sompy_path) diff --git a/submodules/sompy b/submodules/sompy index c39bb1c..167252f 160000 --- a/submodules/sompy +++ b/submodules/sompy @@ -1 +1 @@ -Subproject commit c39bb1ce3e0692d04551ebf7675c209ce36bc1a2 +Subproject commit 167252f6c3a8d2a2d2af9f5daa77ebd47ebfa3d0 diff --git a/tests/Test_Macro.cpp b/tests/Test_Macro.cpp index e292956..6a890ae 100644 --- a/tests/Test_Macro.cpp +++ b/tests/Test_Macro.cpp @@ -5,8 +5,10 @@ TEST(Macro) { - const CoverageMacro& cm = CoverageMacro::instance(); + CoverageMacro& cm = CoverageMacro::instance(); const bool b = cm.getBool1(); const int i = cm.getInt1(); + cm.setInt1(42); + cm.setBool1(true); use(b, i); } diff --git a/tests/Test_Mod_Cpp.cpp b/tests/Test_Mod_Cpp.cpp index a6573d1..3ca7fc4 100644 --- a/tests/Test_Mod_Cpp.cpp +++ b/tests/Test_Mod_Cpp.cpp @@ -3,7 +3,7 @@ #include #include -TEST(Mod_Cpp) +TEST(Mod_Cpp_1) { { CoverageMcpp c0(0); @@ -20,3 +20,37 @@ TEST(Mod_Cpp) CoverageMcpp::assignments(1, 0); CoverageMcpp::assignments(1, 1); } + +TEST(Mod_Cpp_2) +{ + bool b = false; + int i = 0; + b = CoverageInline::isNeg(); + b = CoverageInline::isNeg(); + b = CoverageInline::isNeg(); + b = CoverageInline::isNeg(); + + b = CoverageInline::func(); + b = CoverageInline::func(); + + i = CoverageInline::val(); + i = CoverageInline::val(); + use(b, i); +} + +TEST(Mod_Cpp_3) +{ + bool b = false; + int i = 0; + b = CoverageConstExpr::isNeg(); + b = CoverageConstExpr::isNeg(); + b = CoverageConstExpr::isNeg(); + b = CoverageConstExpr::isNeg(); + + b = CoverageConstExpr::func(); + b = CoverageConstExpr::func(); + + i = CoverageConstExpr::val(); + i = CoverageConstExpr::val(); + use(b, i); +} diff --git a/tests/Test_Standard.cpp b/tests/Test_Standard.cpp index 24d0336..869fdff 100644 --- a/tests/Test_Standard.cpp +++ b/tests/Test_Standard.cpp @@ -123,6 +123,7 @@ TEST(Standard_2) b = CoverageTpl::isNeg(); i = CoverageTpl::val(); - ByteBuffer bb; - use(b, i, bb); + ByteBufferHeap bbh; + ByteBufferStack bbs; + use(b, i, bbh, bbs); } diff --git a/tests/Test_Standard_Part.cpp b/tests/Test_Standard_Part.cpp index 981350e..0634b2c 100644 --- a/tests/Test_Standard_Part.cpp +++ b/tests/Test_Standard_Part.cpp @@ -123,6 +123,6 @@ TEST(Standard_Part_2) // b = CoverageTpl::isNeg(); // i = CoverageTpl::val(); - ByteBuffer bb; - use(b, i, bb); + ByteBufferStack bbs; + use(b, i, bbs); }