Created
April 4, 2024 05:39
-
-
Save perillo/cebd9f82094471b241b961a4f869b0ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -euo pipefail | |
# Build kcov | |
scripts/make.sh | |
printf "\n\n" | |
# Build tests | |
mkdir -p build-tests | |
cd build-tests | |
cmake ../tests | |
make | |
# Run tests | |
run_tests() { | |
# Don't pollute the /tmp directory. | |
tmpdir=$(mktemp -d --tmpdir kcov-test-XXXXXXXXXX) | |
export TMPDIR="$tmpdir" | |
# Print the name of the temporary work directory. | |
printf "WORK=%s\n" "$TMPDIR" | |
export PYTHONPATH=tests/tools | |
python -m libkcov build/src/kcov "$tmpdir" build-tests "." -v "$@" || exit 64 | |
} | |
# Remove all artifacts generated by a previous run_tests | |
cleanup() { | |
# Used by system mode | |
rm -rdf /tmp/kcov-data | |
# /tmp/kcov-system.pid | |
# /tmp/kcov-system.pipe | |
# Total coverage | |
rm -rdf /tmp/kcov-kcov | |
# Other | |
rm -rdf /tmp/test-kcov # bash.bash_accumulate_changed_data | |
rm -f /tmp/setpgid.pid # compiled.setpgid_kill | |
rm -f main.log # compiled.attach_process_with_threads | |
rm -f thread.log # compiled.attach_process_with_threads | |
rm -rdf "echo" # basic.outdir_is_executable | |
# rm -rdf build-tests/.debug # debuglink | |
} | |
cd .. | |
# Clean generated files and directories | |
trap 'cleanup' EXIT INT QUIT TERM | |
# TODO: "rm -rf /tmp/kcov-system.*", better done by each test case. | |
# TODO: Reap all childrens? | |
run_tests "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment