From 8f608478907893b4e4a4d02481b31568ff2fda03 Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Sun, 24 Sep 2017 17:16:44 +0200 Subject: [PATCH] Restored sanitisers based tests. We no longer ask the user to modify the makefile. We instead override the relevant variables from the command line. --- README.md | 23 ++++++++++++++++------- makefile | 19 ------------------- tests/coverage.sh | 14 +------------- 3 files changed, 17 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 6a1a556..7bf5336 100644 --- a/README.md +++ b/README.md @@ -70,19 +70,28 @@ least once. ### More serious testing -_TODO: This section is obsolete._ +You can run the test suite under clang sanitizers or valgrind: -The makefile may be modified to activate sanitising. Just run the -previous tests under the various sanitisers. If you compile for -coverage mapping, the `coverage.sh` mapping can generate a report. -Just run one of those (make sure the makefile is set up accordingly): + $ make clean + $ make test CC="clang -std=c99" CFLAGS="-fsanitize=address" - $ ./coverage.sh test.out + $ make clean + $ make test CC="clang -std=c99" CFLAGS="-fsanitize=memory" -You can also run the tests under Valgrind: + $ make clean + $ make test CC="clang -std=c99" CFLAGS="-fsanitize=undefined" + $ make clean + $ make test.out $ valgrind ./test.out +You can also check code coverage: + + $ make clean + $ make test CC="clang -std=c99" CFLAGS="-fprofile-instr-generate" + $ tests/coverage.sh + + ### Serious auditing The code may be analysed more formally with [Frama-c][] and the diff --git a/makefile b/makefile index 4b8a068..9a65041 100644 --- a/makefile +++ b/makefile @@ -1,23 +1,4 @@ -# compile with any of the following CC=gcc -std=gnu99 # speed tests don't work with -std=cxx, they need the POSIX extensions -#CC=gcc -std=c99 -#CC=gcc -std=c11 -#CC=g++ -std=c++98 -#CC=g++ -std=c++11 -#CC=g++ -std=c++14 -#CC=g++ -std=c++17 -#CC=clang -std=c99 -#CC=clang -std=c11 -#CC=clang++ -std=c++98 -#CC=clang++ -std=c++11 -#CC=clang++ -std=c++14 - -# These may be used for tests (except speed) -#CC = clang -std=c99 -fsanitize=address -#CC = clang -std=c99 -fsanitize=memory -#CC = clang -std=c99 -fsanitize=undefined -#CC = clang -std=c99 -fprofile-instr-generate -fcoverage-mapping - CFLAGS= -pedantic -Wall -Wextra -O3 -march=native DESTDIR= PREFIX=usr/local diff --git a/tests/coverage.sh b/tests/coverage.sh index 644b700..a802025 100755 --- a/tests/coverage.sh +++ b/tests/coverage.sh @@ -1,16 +1,4 @@ #! /bin/sh -echo -echo "Run & record coverage" -echo "=====================" -"./$1" -echo -echo "Generate report" -echo "===============" llvm-profdata-3.8 merge default.profraw -o all.profdata - - -echo -echo "Show report" -echo "===========" -llvm-cov show "./$1" -instr-profile=all.profdata +llvm-cov show "./test.out" -instr-profile=all.profdata -- 2.47.3