From: Loup Vaillant Date: Wed, 14 Feb 2018 22:43:12 +0000 (+0100) Subject: Facilitated the test suite X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=1fcf7f22518dbda1a824a46ba999cce61d59f415;p=Monocypher.git Facilitated the test suite --- diff --git a/README.md b/README.md index 789f1a4..e728dfe 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Monocypher ---------- Monocypher is an easy to use, easy to deploy, auditable crypto library -written in portable C. It approches the size of [TweetNaCl][] and the +written in portable C. It approaches the size of [TweetNaCl][] and the speed of [Libsodium][]. [Official site.](https://monocypher.org/) @@ -69,28 +69,10 @@ somewhere. *Do not* use Monocypher without running those tests at least once. +The same test suite can be run under clang sanitisers and valgrind, and +be checked for code coverage: -### More serious testing - -You can run the test suite under clang sanitizers or valgrind: - - $ make clean - $ make test CC="clang -std=c99" CFLAGS="-fsanitize=address" - - $ make clean - $ make test CC="clang -std=c99" CFLAGS="-fsanitize=memory" - - $ 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 -fcoverage-mapping" + $ tests/test.sh $ tests/coverage.sh @@ -135,6 +117,13 @@ There are similar benchmarks for Libsodium and TweetNaCl: $ make speed-sodium $ make speed-tweetnacl +You can also adjust the optimisation options for Monocypher and +TweetNaCl (the default is `-O3 march=native`): + + $ make speed CFLAGS="-O2" + $ make speed-tweetnacl CFLAGS="-O2" + + Customisation ------------- diff --git a/tests/coverage.sh b/tests/coverage.sh index 9bf5bc9..a34709e 100755 --- a/tests/coverage.sh +++ b/tests/coverage.sh @@ -1,4 +1,8 @@ #! /bin/sh +set -e + +make clean +make test CC="clang -std=c99" CFLAGS="-fprofile-instr-generate -fcoverage-mapping" llvm-profdata-3.8 merge default.profraw -o all.profdata llvm-cov-3.8 show -instr-profile=all.profdata "./test.out" diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..df655bc --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +set -e + +make clean; make test +make clean; make test CC="clang -std=c99" CFLAGS="-g -fsanitize=address" +make clean; make test CC="clang -std=c99" CFLAGS="-g -fsanitize=memory" +make clean; make test CC="clang -std=c99" CFLAGS="-g -fsanitize=undefined" +make clean; make test.out; valgrind ./test.out + +echo "All sanitisers passed!"