From 25f506850d96b61394ed92bc453fc9aa2323f5bf Mon Sep 17 00:00:00 2001 From: sorgom <110917257+sorgom@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:15:28 +0200 Subject: [PATCH] Som devel 20 (#68) * a not satisfying state * a not satisfying state * bullseye build interim (not working?) * bullseye build interim (not working?) * bullseye build, run & md * minor improvements --- .gitignore | 2 +- CLOC.md | 24 ++-- README.md | 2 +- SIL4.md | 2 +- application/main/AppMain.cpp | 1 - make/bullseye/_covbuild.cmd | 24 ++++ make/bullseye/_covdirs.cmd | 15 +++ make/bullseye/_covreport.cmd | 37 ++++++ make/bullseye/_covstep1.cmd | 96 +++++++++++++++ make/bullseye/_runapp.cmd | 10 ++ make/bullseye/covBuildAndRun.cmd | 130 --------------------- make/bullseye/genMd.cmd | 28 +++++ make/bullseye/modTests.cmd | 28 +++++ make/bullseye/sysTests.cmd | 49 ++++++++ make/premake5.lua | 6 +- make/premake5_settings.lua | 10 +- make/premake5_vs.lua | 128 ++++++++++---------- scripts/runGcov.py | 7 +- specification/codebase/Mem.h | 7 -- testing/README.md | 5 +- testing/coverage_bullseye.md | 54 +++++++++ testing/{coverage.md => coverage_tools.md} | 26 +---- testing/testenv/testlib/src/TestLib.cpp | 2 +- 23 files changed, 434 insertions(+), 259 deletions(-) create mode 100644 make/bullseye/_covbuild.cmd create mode 100644 make/bullseye/_covdirs.cmd create mode 100644 make/bullseye/_covreport.cmd create mode 100644 make/bullseye/_covstep1.cmd create mode 100644 make/bullseye/_runapp.cmd delete mode 100644 make/bullseye/covBuildAndRun.cmd create mode 100644 make/bullseye/genMd.cmd create mode 100644 make/bullseye/modTests.cmd create mode 100644 make/bullseye/sysTests.cmd create mode 100644 testing/coverage_bullseye.md rename testing/{coverage.md => coverage_tools.md} (55%) diff --git a/.gitignore b/.gitignore index ec3d6d94..4d1b6e7a 100644 --- a/.gitignore +++ b/.gitignore @@ -87,5 +87,5 @@ transitions_*.md .obsidian -!_cov*.txt +!*/bullseye/_*.* reports diff --git a/CLOC.md b/CLOC.md index de74b268..efa18a13 100644 --- a/CLOC.md +++ b/CLOC.md @@ -4,10 +4,10 @@ ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- -C++ 14 155 25 1128 -C/C++ Header 17 179 148 646 +C++ 14 145 25 1127 +C/C++ Header 17 159 148 691 ------------------------------------------------------------------------------- -SUM: 31 334 173 1774 +SUM: 31 304 173 1818 ------------------------------------------------------------------------------- ``` **testenv** @@ -15,10 +15,10 @@ SUM: 31 334 173 1774 ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- -C/C++ Header 24 237 174 1116 -C++ 9 41 0 217 +C/C++ Header 24 218 175 1122 +C++ 9 37 0 217 ------------------------------------------------------------------------------- -SUM: 33 278 174 1333 +SUM: 33 255 175 1339 ------------------------------------------------------------------------------- ``` **moduletests** @@ -26,9 +26,9 @@ SUM: 33 278 174 1333 ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- -C++ 14 302 300 2376 +C++ 14 290 299 2376 ------------------------------------------------------------------------------- -SUM: 14 302 300 2376 +SUM: 14 290 299 2376 ------------------------------------------------------------------------------- ``` **systemtests** @@ -36,9 +36,9 @@ SUM: 14 302 300 2376 ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- -C++ 2 15 22 117 +C++ 2 14 22 117 ------------------------------------------------------------------------------- -SUM: 2 15 22 117 +SUM: 2 14 22 117 ------------------------------------------------------------------------------- ``` **specification** @@ -46,8 +46,8 @@ SUM: 2 15 22 117 ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- -C/C++ Header 14 97 142 309 +C/C++ Header 14 85 142 346 ------------------------------------------------------------------------------- -SUM: 14 97 142 309 +SUM: 14 85 142 346 ------------------------------------------------------------------------------- ``` \ No newline at end of file diff --git a/README.md b/README.md index c5c2cd5c..991da730 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,6 @@ The aim is to - [AI usage](AI.md) - [testing](testing/README.md) - [transition tables](specification/doc/transition_tables.md) -- [code coverage](testing/coverage.md) +- [code coverage](testing/coverage_tools.md) - [how to build](make/README.md) - [current lines of code](CLOC.md) diff --git a/SIL4.md b/SIL4.md index 1283e25a..6fea49e3 100644 --- a/SIL4.md +++ b/SIL4.md @@ -45,4 +45,4 @@ Additional flags see header of [premake5_vs.lua](make/premake5_vs.lua) ## code coverage Application code coverage by tests must be 100%. -See also [remarks on code coverage](testing/coverage.md) +See also [remarks on code coverage](testing/coverage_tools.md) diff --git a/application/main/AppMain.cpp b/application/main/AppMain.cpp index 3011c1e2..7cbbf66c 100644 --- a/application/main/AppMain.cpp +++ b/application/main/AppMain.cpp @@ -1,5 +1,4 @@ #include -#include #include using std::cout, std::endl; #include diff --git a/make/bullseye/_covbuild.cmd b/make/bullseye/_covbuild.cmd new file mode 100644 index 00000000..83c9e294 --- /dev/null +++ b/make/bullseye/_covbuild.cmd @@ -0,0 +1,24 @@ +@echo off +if "%_me%" == "" exit /b 1 +rem ======================================================================== +rem Bullseye coverage: build step +rem ======================================================================== + +SETLOCAL +call cov01 -q %1 + +:next +shift +if "%1"=="" goto end +echo -- %1 +call %vsCall% /t:%1 >> %buildLog% 2>&1 +if %errorlevel% NEQ 0 ( + echo - build error + exit /b 1 +) +if not exist %exeDir%\%1.exe ( + echo - exe not found + exit /b 1 +) +goto next +:end diff --git a/make/bullseye/_covdirs.cmd b/make/bullseye/_covdirs.cmd new file mode 100644 index 00000000..8c4b78bd --- /dev/null +++ b/make/bullseye/_covdirs.cmd @@ -0,0 +1,15 @@ +@echo off +if "%_me%" == "" exit /b 1 +rem ======================================================================== +rem Bullseye coverage: base directories +rem ======================================================================== +cd /d %~dp0 +set myDir=%cd% +cd .. +set makeDir=%cd% +cd .. +set dstwDir=%cd% + +set reportsDir=%dstwDir%\reports + +cd %myDir% diff --git a/make/bullseye/_covreport.cmd b/make/bullseye/_covreport.cmd new file mode 100644 index 00000000..eeee6e15 --- /dev/null +++ b/make/bullseye/_covreport.cmd @@ -0,0 +1,37 @@ +@echo off +if "%_me%" == "" exit /b 1 +rem ======================================================================== +rem Bullseye coverage: reporting +rem ======================================================================== + +if exist %testReport% ( + echo - test errors + cat %testReport% + exit /b 1 +) + +if %_update% == 1 exit /b 0 + +set covMin=%minFunctionCov%,%minDecisionCov% + +call covselect -qd +call covselect -q --import %excludeFile% + +if %_genhtml% == 1 ( + echo - html + call covhtml -q --allNum %covHtmlDir% +) + +echo - report + +echo ### %_me% %DATE% %TIME% > %covLog% +echo ``` >> %covLog% +cd %dstwDir% +call covdir -q --by-name --srcdir . >> %covLog% + +set _result=failed +call covdir -q --checkmin %covMin% +if %errorlevel% == 0 set _result=passed +echo covmin %covMin% %_result% >> %covLog% +echo ``` >> %covLog% +cat %covLog% diff --git a/make/bullseye/_covstep1.cmd b/make/bullseye/_covstep1.cmd new file mode 100644 index 00000000..8d5fe9a2 --- /dev/null +++ b/make/bullseye/_covstep1.cmd @@ -0,0 +1,96 @@ +@echo off +if "%_me%" == "" exit /b 1 +rem ======================================================================== +rem Bullseye coverage: build and run step 1 (requires VS shell) +rem ======================================================================== +rem setup +rem ======================================================================== +rem minmal coverage setup +rem - minimal function coverage % +set minFunctionCov=100 +rem - minimal decision coverage % +set minDecisionCov=99 + +call %~dp0_covdirs.cmd + +set premakeFile=%makeDir%\premake5_vs.lua + +set exeDir=%makeDir%\exe +set vsSolution=%makeDir%\dstw.sln +set vsConfig=ci +set myReportsDir=%reportsDir%\%_me% +set buildLog=%myReportsDir%\build_.txt +set covLog=%myReportsDir%\coverage.txt +set covHtmlDir=%myReportsDir%\html +set testReport=%myReportsDir%\test_errors.txt + +set covfile=%reportsDir%\%_me%.cov +set covcopt=--srcdir %dstwDir% +set excludeFile=%myDir%\_covexclude.txt +set optsTxt=%myDir%\_covoptions.txt + +set vsCall=msbuild %vsSolution% /p:Configuration=%vsConfig% + +rem ======================================================================== +rem CLI options +rem ======================================================================== +set _vsversion=vs2019 +set _premake=0 +set _cleanbuild=0 +set _cleanreports=0 +set _genhtml=0 +set _update=0 + +for %%p in (%*) do ( + if "%%p" == "-h" ( + echo Usage: %_me%.cmd [options] + cat %optsTxt% + exit /b 1 + ) else if "%%p" == "-c" ( + set _cleanbuild=1 + ) else if "%%p" == "-r" ( + set _cleanreports=1 + ) else if "%%p" == "-H" ( + set _genhtml=1 + ) else if "%%p" == "-u" ( + set _update=1 + ) else if "%%p" == "-p" ( + set _premake=1 + ) else ( + set _vsversion=%%p + ) +) + +rem ======================================================================== +rem common 1st steps +rem ======================================================================== +if not exist %vsSolution% set _premake=1 +if not exist %covfile% set _cleanbuild=1 + +if %_cleanreports% == 1 ( + echo - clean reports + if exist %myReportsDir% rm -rf %myReportsDir% +) + +if %_premake% == 1 ( + echo - premake for %_vsversion% + call premake5 --file=%premakeFile% %_vsversion% + set _cleanbuild=1 +) + +if %_cleanbuild% == 1 ( + echo - clean + if exist %covfile% rm -f %covfile% + call %vsCall% /t:clean >NUL +) + +if not exist %myReportsDir% mkdir %myReportsDir% + +echo %DATE% %TIME% > %buildLog% + +echo - build +call cov01 -q --off +echo -- cpputest +call %vsCall% /t:cpputest >> %buildLog% 2>&1 + +exit /b 0 diff --git a/make/bullseye/_runapp.cmd b/make/bullseye/_runapp.cmd new file mode 100644 index 00000000..a9944955 --- /dev/null +++ b/make/bullseye/_runapp.cmd @@ -0,0 +1,10 @@ +@echo off +if "%_me%" == "" exit /b 1 +if "%tmpFile%" == "" exit /b 1 +rem ======================================================================== +rem system tests: run app in background +rem ======================================================================== +echo running > %tmpFile% +call %exeDir%\dstw_run.exe loop >NUL +rm -f %tmpFile% +exit 0 diff --git a/make/bullseye/covBuildAndRun.cmd b/make/bullseye/covBuildAndRun.cmd deleted file mode 100644 index 9ebc4b5c..00000000 --- a/make/bullseye/covBuildAndRun.cmd +++ /dev/null @@ -1,130 +0,0 @@ -@echo off -rem ======================================================================== -rem Bullseye coverage: build and run tests (requires VS shell) -rem ======================================================================== - -SETLOCAL -rem minmal coverage setup -rem - minimal function coverage % -set minFunctionCov=100 -rem - minimal decision coverage % -set minDecisionCov=99 - -cd /d %~dp0 -set myDir=%cd% -cd .. -set makeDir=%cd% -cd .. -set dstwDir=%cd% - -set premakeFile=%makeDir%\premake5_vs.lua - -set executable=%makeDir%\exe\tests.exe -set vsSolution=%makeDir%\tests.sln -set vsBuildTarget=tests - -set reportsDir=%dstwDir%\reports -set buildLog=%reportsDir%\buildReport.txt -set covLog=%reportsDir%\coverageReport.txt -set covHtmlDir=%reportsDir%\html - -set covfile=%makeDir%\dstw.cov -set covcopt=--srcdir %dstwDir% -set excludeFile=%myDir%\_covexclude.txt -set optsTxt=%myDir%\_covoptions.txt - -set covMin=%minFunctionCov%,%minDecisionCov% - -set _vsversion=vs2019 -set _premake=0 -set _cleanbuild=0 -set _cleanreports=0 -set _genhtml=0 -set _update=0 - -for %%p in (%*) do ( - if "%%p" == "-h" ( - echo Usage: %~n0%~x0 [options] - cat %optsTxt% - exit /b 0 - ) else if "%%p" == "-c" ( - set _cleanbuild=1 - ) else if "%%p" == "-r" ( - set _cleanreports=1 - ) else if "%%p" == "-H" ( - set _genhtml=1 - ) else if "%%p" == "-u" ( - set _update=1 - ) else if "%%p" == "-p" ( - set _premake=1 - ) else ( - set _vsversion=%%p - ) -) - -if not exist %vsSolution% set _premake=1 -if not exist %covfile% set _cleanbuild=1 - -if %_premake% == 1 ( - echo - premake for %_vsversion% - call premake5 --file=%premakeFile% %_vsversion% - set _cleanbuild=1 -) - -if %_cleanreports% == 1 ( - echo - clean reports - if exist %reportsDir% rm -rf %reportsDir% -) - -if %_cleanbuild% == 1 ( - echo - clean - if exist %covfile% rm -f %covfile% - call msbuild /t:Clean %vsSolution% >NUL -) - -if not exist %reportsDir% mkdir %reportsDir% - -call cov01 -q1 - -echo - build -call msbuild /t:%vsBuildTarget% %vsSolution% > %buildLog% 2>&1 - -call cov01 -q0 - -if not exist %executable% ( - echo %executable% not found - exit /b 1 -) - -if not exist %covfile% ( - echo %covfile% not found - exit /b 1 -) - -rm -f %buildLog% - -rem rewind coverage file if it was not removed before -call covclear -q - -echo - run -call %executable% >NUL - -if %_update% == 1 exit /b 0 - -call covselect -qd -call covselect -q --import %excludeFile% - -if %_genhtml% == 1 ( - echo - html - call covhtml -q --allNum %covHtmlDir% -) - -echo - report - -cd %dstwDir% -call covdir -q --by-name --srcdir . | tee %covLog% - -set _result=failed -call covdir -q --checkmin %covMin% -if %errorlevel% == 0 set _result=passed -echo covmin %covMin% %_result% | tee -a %covLog% diff --git a/make/bullseye/genMd.cmd b/make/bullseye/genMd.cmd new file mode 100644 index 00000000..9079484e --- /dev/null +++ b/make/bullseye/genMd.cmd @@ -0,0 +1,28 @@ +@echo off +rem ======================================================================== +rem Bullseye coverage: generate md file +rem ======================================================================== +SETLOCAL +set _me=%~n0 +call %~dp0_covdirs.cmd %* +set reportMod=%reportsDir%\modTests\coverage.txt +set reportSys=%reportsDir%\sysTests\coverage.txt +set target=%dstwDir%\testing\coverage_bullseye.md + +if not exist %reportMod% call %myDir%\modTests.cmd +if not exist %reportSys% call %myDir%\sysTests.cmd + +if not exist %reportMod% ( + echo %reportMod% not found + exit /b 1 +) +if not exist %reportSys% ( + echo %reportSys% not found + exit /b 1 +) +echo # current bullseye coverage > %target% +echo. >> %target% +cat %reportMod% >> %target% +echo. >> %target% +cat %reportSys% >> %target% +echo. >> %target% diff --git a/make/bullseye/modTests.cmd b/make/bullseye/modTests.cmd new file mode 100644 index 00000000..65bfcb02 --- /dev/null +++ b/make/bullseye/modTests.cmd @@ -0,0 +1,28 @@ +@echo off +rem ======================================================================== +rem Bullseye coverage: build and run module tests (requires VS shell) +rem ======================================================================== + +SETLOCAL +set _me=%~n0 +call %~dp0_covstep1.cmd %* +if %errorlevel% neq 0 exit /b 0 + +call %myDir%\_covbuild.cmd --on moduletests +if %errorlevel% NEQ 0 exit /b 1 + +if not exist %covfile% ( + echo %covfile% not found + exit /b 1 +) + +rm -f %buildLog% + +rem rewind coverage file if it was not removed before +call covclear -q + +echo - run +call %exeDir%\moduletests.exe -b -v > %testReport% 2>&1 +if %errorlevel% == 0 rm -f %testReport% + +call %myDir%\_covreport.cmd diff --git a/make/bullseye/sysTests.cmd b/make/bullseye/sysTests.cmd new file mode 100644 index 00000000..c0316e22 --- /dev/null +++ b/make/bullseye/sysTests.cmd @@ -0,0 +1,49 @@ +@echo off +rem ======================================================================== +rem Bullseye coverage: build and run module tests (requires VS shell) +rem ======================================================================== + +SETLOCAL +set _me=%~n0 +call %~dp0_covstep1.cmd %* +if %errorlevel% neq 0 exit /b 0 + +call %myDir%\_covbuild.cmd --off dstw_gen dstw_stop systemtests_run +if %errorlevel% NEQ 0 exit /b 1 + +call %myDir%\_covbuild.cmd --on dstw_run +if %errorlevel% NEQ 0 exit /b 1 + +if not exist %covfile% ( + echo %covfile% not found + exit /b 1 +) +rm -f %buildLog% + +echo - gen data +call %exeDir%\dstw_gen.exe >NUL + +set /a "myID=%random%" +set tmpFile=%reportsDir%\run.%myID%.tmp + +echo - launch application +start /B %myDir%\_runapp.cmd + +timeout /t 2 /nobreak >NUL 2>&1 +echo - run tests +call %exeDir%\systemtests_run.exe -b -v > %testReport% 2>&1 +if %errorlevel% == 0 rm -f %testReport% + +echo - stop application ... +call %exeDir%\dstw_stop.exe + +:wait +timeout /t 1 /nobreak >NUL 2>&1 +if exist %tmpFile% goto wait + +rem - minimal function coverage % +set minFunctionCov=50 +rem - minimal decision coverage % +set minDecisionCov=30 + +call %myDir%\_covreport.cmd diff --git a/make/premake5.lua b/make/premake5.lua index 6e2cdbf8..f4f0b8d6 100644 --- a/make/premake5.lua +++ b/make/premake5.lua @@ -136,7 +136,7 @@ workspace 'systemtests' objdir 'obj/gcc/%{prj.name}' buildoptions { buildoptions_gcc } - defines { defines_gendata } + defines { defines_test } filter { 'configurations:ci' } defines { 'NDEBUG' } @@ -148,7 +148,7 @@ workspace 'systemtests' project 'systemtests_stop' kind 'ConsoleApp' targetdir 'bin' - files { files_systemtest_stop } + files { files_dstw_stop } includedirs { includedirs_test } project 'systemtests_run' @@ -182,7 +182,7 @@ workspace 'dstw' project 'dstw_gen' kind 'ConsoleApp' includedirs { includedirs_test } - defines { 'NDEBUG', defines_gendata } + defines { 'NDEBUG', defines_test } files { files_gendata } project 'dstw_run' diff --git a/make/premake5_settings.lua b/make/premake5_settings.lua index 911c5a49..a24d4103 100644 --- a/make/premake5_settings.lua +++ b/make/premake5_settings.lua @@ -64,18 +64,10 @@ defines_test = { defines_app = { 'NDEBUG' } -defines_gendata = { - defines_test, - -- 'TEST_NUM_TSW=101', - -- 'TEST_NUM_SIG=102', - -- 'TEST_NUM_LCR=103', - -- 'TEST_NUM_SEG=104' -} - files_moduletest = { '../testing/tests/moduletests/**.cpp' } files_systemtest = { '../testing/tests/systemtests/SYST_*.cpp' } files_devtest = { '../testing/tests/devtests/*.cpp' } -files_systemtest_stop = { +files_dstw_stop = { '../testing/tests/systemtests/stopAppMain.cpp', '../testing/testenv/TCP/src/TCP_Client.cpp' } diff --git a/make/premake5_vs.lua b/make/premake5_vs.lua index 7a5a2ed5..c471f95a 100644 --- a/make/premake5_vs.lua +++ b/make/premake5_vs.lua @@ -20,97 +20,97 @@ include 'premake5_settings.lua' buildoptions_vs = '/std:c++17 /MP' buildoptions_vs_app = buildoptions_vs .. ' /W4 /wd4100 /wd4103' buildoptions_vs_test = buildoptions_vs_app .. ' /wd4127 /D_WINSOCK_DEPRECATED_NO_WARNINGS' - +buildoptions_vs_cpputest = buildoptions_vs_app .. ' -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED' -- ============================================================ --- > tests.sln --- module tests at once runtime --- including CppUTest sources --- -> exe/tests.exe +-- > dstw.sln -- configurations: --- - ci module tests --- - debug module tests debug mode --- - dev developer tests debug mode +-- - ci no debug +-- - debug debug mode +-- - dev debug mode -- ============================================================ -workspace 'tests' +workspace 'dstw' filter { 'action:vs*' } configurations { 'ci', 'debug', 'dev' } language 'C++' - objdir 'obj/vs/%{prj.name}' + objdir 'obj/%{prj.name}/%{cfg.name}' + kind 'ConsoleApp' + targetdir 'exe' + libdirs { 'lib' } + warnings 'high' + + filter { 'configurations:ci' } + defines { 'NDEBUG' } - includedirs { includedirs_test } + filter { 'configurations:debug' } + defines { 'DEBUG' } + symbols 'On' - defines { defines_test } + filter { 'configurations:dev' } + defines { 'DEBUG' } + symbols 'On' - project 'tests' - kind 'ConsoleApp' - targetdir 'exe' - warnings 'high' - links { 'winmm', 'ws2_32' } + -- ============================================================ + -- common + -- ============================================================ + project 'cpputest' + kind 'StaticLib' + targetdir 'lib' + buildoptions { buildoptions_vs_cpputest } + includedirs { includedirs_cpputest } + files { files_cpputest_vs } + + -- ============================================================ + -- module tests + -- configurations: + -- - ci module tests + -- - debug module tests debug mode + -- - dev developer tests debug mode + -- ============================================================ + -- must be unstrumented for coverage + project 'moduletests' buildoptions { buildoptions_vs_test } - files { files_cpputest_vs, files_testenv, files_app } + includedirs { includedirs_test } + links { 'winmm', 'ws2_32', 'cpputest' } + + files { files_app, files_testenv } filter { 'configurations:ci' } - defines { 'NDEBUG' } files { files_moduletest } filter { 'configurations:debug' } - defines { 'DEBUG' } - symbols 'On' files { files_moduletest } filter { 'configurations:dev' } - defines { 'DEBUG', defines_test } - symbols 'On' files { files_devtest } - --- ============================================================ --- > dstw_system.sln --- build all executables at once: --- - application runtime --- - generate proj data for runtime --- - TCP based system tests --- - TCP based application stop --- ============================================================ -workspace 'dstw_system' - filter { 'action:vs*' } - configurations { 'ci', 'debug' } - language 'C++' - objdir 'obj/vs/%{prj.name}' - kind 'ConsoleApp' - - targetdir 'exe' - warnings 'high' - buildoptions { buildoptions_vs_app } - - filter { 'configurations:ci' } - defines { 'NDEBUG' } - - filter { 'configurations:debug' } - defines { 'DEBUG' } - symbols 'On' - + + -- ============================================================ + -- system tests + -- ============================================================ + -- run first project 'dstw_gen' - defines { defines_gendata } + buildoptions { buildoptions_vs_app } includedirs { includedirs_test } files { files_gendata } - - project 'dstw_run' - defines { defines_app } + + -- run second in background + -- must be unstrumented for coverage + project 'dstw_run' + buildoptions { buildoptions_vs_app } includedirs { includedirs_app } files { files_app, files_app_main } links { 'ws2_32' } - project 'systemtests_stop' - links { 'ws2_32' } - files { files_systemtest_stop } - includedirs { includedirs_test } - buildoptions { buildoptions_vs_test } - + -- run third project 'systemtests_run' - kind 'ConsoleApp' - links { 'winmm', 'ws2_32' } - files { files_cpputest_vs, files_testenv, files_systemtest } - defines { defines_gendata } + buildoptions { buildoptions_vs_test } includedirs { includedirs_test } + files { files_systemtest, files_testenv } + links { 'winmm', 'ws2_32', 'cpputest' } + + -- run last to stop application in background + project 'dstw_stop' buildoptions { buildoptions_vs_test } + includedirs { includedirs_test } + files { files_dstw_stop } + links { 'ws2_32' } diff --git a/scripts/runGcov.py b/scripts/runGcov.py index f3a2d565..6cadbb08 100644 --- a/scripts/runGcov.py +++ b/scripts/runGcov.py @@ -7,7 +7,7 @@ from projectDirs import makDir, tsgDir from modUtilz import mdTxt, mdCode, writeFile -ttl = '## sample gcov snapshot' +ttl = '# current gcov coverage' def runGcov(conf='ci', verbose=True): return Gcov().run( @@ -19,9 +19,10 @@ def runGcov(conf='ci', verbose=True): ) def gcovToMd(): - cov = runGcov(verbose=False) + cov = runGcov(verbose=True) if not cov: return - mdf = f'{tsgDir}/coverage.md' + print(cov) + mdf = f'{tsgDir}/coverage_gcov.md' txt = mdTxt(mdf, ttl) res = [txt] if txt else [] res.append('\n'.join([ttl, mdCode(cov)])) diff --git a/specification/codebase/Mem.h b/specification/codebase/Mem.h index 11318531..71e84a8f 100644 --- a/specification/codebase/Mem.h +++ b/specification/codebase/Mem.h @@ -13,13 +13,6 @@ class Mem { public: - // memset a char array - template - inline static void set(CHAR(& a)[N], CHAR b = 0) - { - std::memset(a, b, N); - } - // memcpy char array template inline static void cpy(CHAR(& trg)[N], const CHAR(& src)[N]) diff --git a/testing/README.md b/testing/README.md index 4bd38426..93d0da76 100644 --- a/testing/README.md +++ b/testing/README.md @@ -70,10 +70,11 @@ The system tests take place that way: ![system tests](../specification/doc/sys_tests.svg) ## code coverage -for current current code coverage see [coverage.md](coverage.md) +- [coverage tools](coverage_tools.md) +- [current bullseye coverage](coverage_bullseye.md) ## used APIs -- [CppUTestSteps](https://github.com/sorgom/CppUTestSteps) +- [CppUTestSteps](https://github.com/sorgom/CppUTestSteps) ## IL headers - [header for production build](../application/components/SYS/IL.h) diff --git a/testing/coverage_bullseye.md b/testing/coverage_bullseye.md new file mode 100644 index 00000000..39f2a7ff --- /dev/null +++ b/testing/coverage_bullseye.md @@ -0,0 +1,54 @@ +# current bullseye coverage + +### modTests 16.10.2024 18:24:47,67 +``` +Directory Function Coverage C/D Coverage +------------------------------- ----------------- ---------------- +application/components/ 128 / 128 = 100% 315 / 316 = 99% +application/components/BAS/ 25 / 25 = 100% 39 / 39 = 100% +application/components/BAS/src/ 1 / 1 = 100% 14 / 14 = 100% +application/components/COM/ 32 / 32 = 100% 79 / 80 = 98% +application/components/COM/src/ 31 / 31 = 100% 79 / 80 = 98% +application/components/LCR/ 15 / 15 = 100% 40 / 40 = 100% +application/components/LCR/src/ 11 / 11 = 100% 40 / 40 = 100% +application/components/SIG/ 30 / 30 = 100% 95 / 95 = 100% +application/components/SIG/src/ 24 / 24 = 100% 95 / 95 = 100% +application/components/SYS/ 15 / 15 = 100% 40 / 40 = 100% +application/components/SYS/src/ 13 / 13 = 100% 40 / 40 = 100% +application/components/TSW/ 11 / 11 = 100% 22 / 22 = 100% +application/components/TSW/src/ 8 / 8 = 100% 22 / 22 = 100% +specification/ 5 / 5 = 100% 0 / 0 +specification/codebase/ 2 / 2 = 100% 0 / 0 +specification/ifs/ 3 / 3 = 100% 0 / 0 +------------------------------- ----------------- ---------------- +Total 133 / 133 = 100% 315 / 316 = 99% +covmin 100,99 passed +``` + +### sysTests 16.10.2024 18:27:29,41 +``` +Directory Function Coverage C/D Coverage +------------------------------- ----------------- ---------------- +application/ 100 / 143 = 69% 107 / 322 = 33% +application/components/ 99 / 142 = 69% 104 / 316 = 32% +application/components/BAS/ 21 / 25 = 84% 30 / 39 = 76% +application/components/BAS/src/ 1 / 1 = 100% 9 / 14 = 64% +application/components/COM/ 31 / 32 = 96% 49 / 80 = 61% +application/components/COM/src/ 30 / 31 = 96% 49 / 80 = 61% +application/components/LCR/ 5 / 15 = 33% 1 / 40 = 2% +application/components/LCR/src/ 2 / 11 = 18% 1 / 40 = 2% +application/components/SIG/ 5 / 30 = 16% 1 / 95 = 1% +application/components/SIG/src/ 2 / 24 = 8% 1 / 95 = 1% +application/components/SYS/ 28 / 29 = 96% 18 / 40 = 45% +application/components/SYS/src/ 12 / 13 = 92% 18 / 40 = 45% +application/components/TSW/ 9 / 11 = 81% 5 / 22 = 22% +application/components/TSW/src/ 6 / 8 = 75% 5 / 22 = 22% +application/main/ 1 / 1 = 100% 3 / 6 = 50% +specification/ 5 / 5 = 100% 0 / 0 +specification/codebase/ 2 / 2 = 100% 0 / 0 +specification/ifs/ 3 / 3 = 100% 0 / 0 +------------------------------- ----------------- ---------------- +Total 105 / 148 = 70% 107 / 322 = 33% +covmin 50,30 passed +``` + diff --git a/testing/coverage.md b/testing/coverage_tools.md similarity index 55% rename from testing/coverage.md rename to testing/coverage_tools.md index f7fc7b96..8d8957b7 100644 --- a/testing/coverage.md +++ b/testing/coverage_tools.md @@ -14,30 +14,8 @@ It's available for Windows and Linux. Bullseye is not for free - but they provide a free trial period. -Sample text summary output: -``` -Directory Function Coverage C/D Coverage -------------------------------- ----------------- ---------------- -application/components/ 128 / 128 = 100% 315 / 316 = 99% -application/components/BAS/ 25 / 25 = 100% 39 / 39 = 100% -application/components/BAS/src/ 1 / 1 = 100% 14 / 14 = 100% -application/components/COM/ 32 / 32 = 100% 79 / 80 = 98% -application/components/COM/src/ 31 / 31 = 100% 79 / 80 = 98% -application/components/LCR/ 15 / 15 = 100% 40 / 40 = 100% -application/components/LCR/src/ 11 / 11 = 100% 40 / 40 = 100% -application/components/SIG/ 30 / 30 = 100% 95 / 95 = 100% -application/components/SIG/src/ 24 / 24 = 100% 95 / 95 = 100% -application/components/SYS/ 15 / 15 = 100% 40 / 40 = 100% -application/components/SYS/src/ 13 / 13 = 100% 40 / 40 = 100% -application/components/TSW/ 11 / 11 = 100% 22 / 22 = 100% -application/components/TSW/src/ 8 / 8 = 100% 22 / 22 = 100% -specification/ 6 / 6 = 100% 0 / 0 -specification/codebase/ 3 / 3 = 100% 0 / 0 -specification/ifs/ 3 / 3 = 100% 0 / 0 -------------------------------- ----------------- ---------------- -Total 134 / 134 = 100% 315 / 316 = 99% -``` -For details see [bullseye html report](http://dstw.sorgo.de/bullseye/) +- [current text report](coverage_bullseye.md) +- [sample html report](http://dstw.sorgo.de/bullseye/) ## gcov Gcov comes with gnu compiler collection (gcc) and therefore is available diff --git a/testing/testenv/testlib/src/TestLib.cpp b/testing/testenv/testlib/src/TestLib.cpp index df2b9c6e..4435dcea 100644 --- a/testing/testenv/testlib/src/TestLib.cpp +++ b/testing/testenv/testlib/src/TestLib.cpp @@ -15,7 +15,7 @@ namespace test void genComName(ComName& cName, UINT32 num, CONST_C_STRING name) { - Mem::set(cName.chars, ' '); + std::memset(cName.chars, ' ', ComNameSize); static CHAR buf[sizeof(ComName) + 1]; const int sz = std::snprintf(buf, sizeof(buf), "%s %03u ", name, num); if (sz > 0)