valgrind.sh 987 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (c) 2009-2016 Petri Lehtinen <petri@digip.org>
  2. #
  3. # Jansson is free software; you can redistribute it and/or modify
  4. # it under the terms of the MIT license. See LICENSE for details.
  5. [ -z "$VALGRIND" ] && VALGRIND=0
  6. VALGRIND_CMDLINE="valgrind --leak-check=full --show-reachable=yes --track-origins=yes -q"
  7. if [ $VALGRIND -eq 1 ]; then
  8. test_runner="$VALGRIND_CMDLINE"
  9. json_process="$VALGRIND_CMDLINE $json_process"
  10. else
  11. test_runner=""
  12. fi
  13. valgrind_check() {
  14. if [ $VALGRIND -eq 1 ]; then
  15. # Check for Valgrind error output. The valgrind option
  16. # --error-exitcode is not enough because Valgrind doesn't
  17. # think unfreed allocs are errors.
  18. if grep -E -q '^==[0-9]+== ' $1; then
  19. touch $test_log/valgrind_error
  20. return 1
  21. fi
  22. fi
  23. }
  24. valgrind_show_error() {
  25. if [ $VALGRIND -eq 1 -a -f $test_log/valgrind_error ]; then
  26. echo "valgrind detected an error"
  27. return 0
  28. fi
  29. return 1
  30. }