kos/scripts/test/valgrind.sh
Ari Archer cbcc1346d7
Pre-42: Security notices, removal, abstraction, fixes and documentation
- Add a notice for security of authentication storing
    - Add a TODO for it
- Remove flags
- Add a config option to disable effective ID setting
- Add a `WERRORIF_COND` macro for the `ERRORIF_COND(WSTRERRNO(x), y)` pattern
- Fix the way if `cin` is EOF it'd exit with `EXIT_FAILURE` rather than `EXIT_STDIN`
- Fix the formatting of some errors
- Added some notes for developers

Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-10-15 23:29:25 +03:00

40 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
. scripts/test/noroot.lib.sh
main() {
log_file="${LOGFILE:-valgrind.log}"
tools=(memcheck cachegrind callgrind helgrind drd massif dhat lackey none exp-bbv)
base_cmd='valgrind --trace-children=yes --log-file=valgrind.log -s'
end_cmd="cat -- '$log_file' && head -n 1 -- '$log_file' && exit 127"
for tool in "${tools[@]}"; do
log "Trying tool $tool"
case "$tool" in
memcheck) opt='--leak-check=full --show-leak-kinds=all --track-origins=yes --expensive-definedness-checks=yes' ;;
cachegrind) opt='--branch-sim=yes' ;;
drd) opt='--check-stack-var=yes --free-is-write=yes' ;;
massif) opt='--stacks=yes' ;;
helgrind) opt='--free-is-write=yes' ;;
*) opt='' ;;
esac
cmd="$base_cmd $opt --tool='$tool' ./kos && $end_cmd"
log "Trying with command '$cmd'"
rm -rf ./*.out.*
log 'Compilation'
compile "$cmd"
log 'Optimisation flags'
optimising "$cmd"
rm -rf ./*.out.*
done
}
main "$@"