From ccbf4fb5da269b1a6f4b8d5a59def7dd535d83c7 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sat, 30 Aug 2014 19:57:15 -0700 Subject: [PATCH] Make valgrind part of test scripts --- script/test_compiler.sh | 3 +-- script/test_runtime.sh | 3 +-- script/util/run_tests.sh | 52 +++++++++++++++++++++++++++++++++------- script/valgrind.sh | 6 ----- 4 files changed, 46 insertions(+), 18 deletions(-) delete mode 100755 script/valgrind.sh diff --git a/script/test_compiler.sh b/script/test_compiler.sh index 18d43188..d2950e79 100755 --- a/script/test_compiler.sh +++ b/script/test_compiler.sh @@ -2,6 +2,5 @@ set -e -u -make compiler_specs source `dirname $0`/util/run_tests.sh -run_tests out/Default/compiler_specs "$@" +run_tests compiler_specs "$@" diff --git a/script/test_runtime.sh b/script/test_runtime.sh index 9a5a503a..d2843ef8 100755 --- a/script/test_runtime.sh +++ b/script/test_runtime.sh @@ -2,6 +2,5 @@ set -e -u -make runtime_specs source `dirname $0`/util/run_tests.sh -run_tests out/Default/runtime_specs "$@" +run_tests runtime_specs "$@" diff --git a/script/util/run_tests.sh b/script/util/run_tests.sh index 74a15aff..85d60997 100644 --- a/script/util/run_tests.sh +++ b/script/util/run_tests.sh @@ -1,12 +1,38 @@ +function usage { + cat <<-EOF +USAGE + + $0 [-dghv] [-f focus-string] + +OPTIONS + + -h print this message + + -d run tests in a debugger (either lldb or gdb) + + -g run tests with valgrind + + -v run tests with verbose output + + -f focus tests to those containing the substring + +EOF +} + function run_tests { - local cmd=$1 + local debug + local args + local valgrind + local target=$1 + local cmd="out/Default/${target}" shift - local debug= - local args= - - while getopts "dvf:" option; do + while getopts "hdgvf:" option; do case ${option} in + h) + usage + exit + ;; d) debug=true ;; @@ -16,13 +42,22 @@ function run_tests { v) args="$args --reporter=spec" ;; - *) - exit + g) + valgrind=true ;; esac done - if [[ -n $debug ]]; then + make $target + + if [[ -n $valgrind ]]; then + eval valgrind \ + --suppressions=./etc/valgrind.supp \ + --dsymutil=yes \ + $cmd \ + $args + + elif [[ -n $debug ]]; then if which -s gdb; then eval gdb $cmd -- $args elif which -s lldb; then @@ -31,6 +66,7 @@ function run_tests { echo "No debugger found" exit 1 fi + else eval time $cmd $args fi diff --git a/script/valgrind.sh b/script/valgrind.sh deleted file mode 100755 index 9966a3be..00000000 --- a/script/valgrind.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -valgrind $@ \ - --suppressions=./etc/valgrind.supp \ - --dsymutil=yes \ - out/Default/runtime_specs