diff --git a/tests/build.sh b/tests/build.sh index ed84ec5..ddbe329 100755 --- a/tests/build.sh +++ b/tests/build.sh @@ -3,7 +3,7 @@ set -e ROOT=`pwd` if [ $# -ne 2 ]; then - echo "usage: ./build.sh [b|d] [path to cpp file]" + echo "usage: ./build.sh [b|d|c] [path to cpp file]" exit 1 fi @@ -20,6 +20,8 @@ if [ $1 = "b" ]; then FLAGS+=" -O2" elif [ $1 = "d" ]; then FLAGS+=" -O0 -g -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address,undefined" +elif [ $1 = "c" ]; then + FLAGS+=" -O0 --coverage" else echo "usage: ./build.sh [b|d] [path to cpp file]" exit 1 diff --git a/tests/clear-coverage.sh b/tests/clear-coverage.sh new file mode 100755 index 0000000..ec78b4c --- /dev/null +++ b/tests/clear-coverage.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e -o pipefail + +find ../build/tests/ -name '*.gcda' -delete -or -name '*.gcno' -delete +find ../build/tests/ -name '*.gcda' -or -name '*.gcno' diff --git a/tests/own/test.sh b/tests/own/test.sh index b589a63..1280eca 100755 --- a/tests/own/test.sh +++ b/tests/own/test.sh @@ -2,7 +2,7 @@ set -e -o pipefail if [ $# -lt 3 ]; then - echo "usage: ./test.sh [b|d] [deterministic|fuzz|bench] [files...]" + echo "usage: ./test.sh [b|d|c] [deterministic|fuzz|bench] [files...]" exit 1 fi @@ -11,7 +11,10 @@ TEST_MODE=$2 FILES=$(find ${@:3} -name '*.cpp' | sort) cd .. -ROOT=`pwd` + +if [ $BUILD_MODE = "c" ]; then + ./clear-coverage.sh +fi for CPP_FILE in $FILES; do echo @@ -20,5 +23,9 @@ for CPP_FILE in $FILES; do echo ================================================================ ./build.sh $BUILD_MODE own/$CPP_FILE echo start - time $ROOT/../build/tests/own/$CPP_FILE.e $TEST_MODE + time ../build/tests/own/$CPP_FILE.e $TEST_MODE done + +if [ $BUILD_MODE = "c" ]; then + ./report-coverage.sh +fi diff --git a/tests/report-coverage.sh b/tests/report-coverage.sh new file mode 100755 index 0000000..efb1df4 --- /dev/null +++ b/tests/report-coverage.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e -o pipefail + +mkdir -p ../build/coverage +gcovr --root ../src/ --object-directory ../build/ \ + --html-details ../build/coverage/index.html \ + --html-tab-size=2 --merge-mode-functions=separate diff --git a/tests/yosupo/test.sh b/tests/yosupo/test.sh index 9805f56..b98fdec 100755 --- a/tests/yosupo/test.sh +++ b/tests/yosupo/test.sh @@ -2,7 +2,7 @@ set -e -o pipefail if [ $# -lt 2 ]; then - echo "usage: ./test.sh [b|d] [files...]" + echo "usage: ./test.sh [b|d|c] [files...]" exit 1 fi @@ -12,6 +12,10 @@ FILES=$(find ${@:2} -name '*.cpp' | sort) cd .. ROOT=`pwd` +# if [ $BUILD_MODE = "c" ]; then +# ./clear-coverage.sh +# fi + for CPP_FILE in $FILES; do echo echo ================================================================ @@ -44,3 +48,7 @@ for CPP_FILE in $FILES; do fi done done + +if [ $BUILD_MODE = "c" ]; then + ./report-coverage.sh +fi