Hello,
Attached is a small script I've been using.
It helps running multiple tests for a given program.
example:
./scripts/check_program sort
Will find all sort-related tests (based on filename) and run them.
Adding "-e" or "-v" also runs expensive and very expensive tests:
examle:
./scripts/check_program -v sort
is equivalent to:
make check VERBOSE=yes SUBDIRS=. \
RUN_EXPENSIVE_TESTS=yes \ RUN_VERY_EXPENSIVE_TESTS=yes \
TESTS="./tests/misc/sort-NaN-infloop.sh
./tests/misc/sort-benchmark-random.sh
./tests/misc/sort-compress-hang.sh
./tests/misc/sort-compress-proc.sh
./tests/misc/sort-compress.sh
./tests/misc/sort-continue.sh
./tests/misc/sort-debug-keys.sh
./tests/misc/sort-debug-warn.sh
./tests/misc/sort-discrim.sh
./tests/misc/sort-exit-early.sh
./tests/misc/sort-files0-from.pl
./tests/misc/sort-float.sh
./tests/misc/sort-merge-fdlimit.sh
./tests/misc/sort-merge.pl
./tests/misc/sort-month.sh
./tests/misc/sort-rand.sh
./tests/misc/sort-spinlock-abuse.sh
./tests/misc/sort-stale-thread-mem.sh
./tests/misc/sort-u-FMR.sh
./tests/misc/sort-unique-segv.sh
./tests/misc/sort-unique.sh
./tests/misc/sort-version.sh
./tests/misc/sort.pl"
If others find it useful, you're welcomed to add this.
-gordon
>From 965a01bfaf129b4d1da8d0927a9149e4c4145ff3 Mon Sep 17 00:00:00 2001
From: "A. Gordon" <[email protected]>
Date: Fri, 24 Jan 2014 13:39:14 -0500
Subject: [PATCH] scripts: add check_program, to run tests easily
* scripts/check_program: New script, so you can easily run all tests
relating to a certain program. Takes less time than checking all
programs with 'make check', and quicker to type than
'make check TESTS=TEST1,TEST2,TEST3' for multiple tests.
---
scripts/check_program | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100755 scripts/check_program
diff --git a/scripts/check_program b/scripts/check_program
new file mode 100755
index 0000000..f38e410
--- /dev/null
+++ b/scripts/check_program
@@ -0,0 +1,70 @@
+#!/bin/sh
+# A small helper script to run multiple tests at once.
+# example:
+# ./scripts/check_program sort
+# would run all 'sort' related tests under ./tests/
+
+# Written by Assaf Gordon
+
+# allow the user to override 'make'
+MAKE=${MAKE-make}
+
+VERSION='2014-01-24 00:37:51' # UTC
+
+prog_name=`basename $0`
+die () { echo "$prog_name: $*" >&2; exit 1; }
+
+usage() {
+ echo >&2 "\
+Usage: $0 [OPTION] PROGRAM
+Runs all tests for PROGRAM
+
+Options:
+ -e run EXPENSIVE tests
+ -v run EXPENSIVE and VERY_EXPENSIVE tests
+ -h display this help and exit
+
+Examples:
+To run all (non-expensive) tests for 'uniq':
+
+ $0 uniq
+
+To run all (including expensive and very expensive) tests for 'sort':
+
+ $0 -v sort
+
+"
+}
+
+RUN_EXPENSIVE_TESTS=no
+RUN_VERY_EXPENSIVE_TESTS=no
+while getopts :evh name
+do
+ case $name in
+ (v) RUN_VERY_EXPENSIVE_TESTS=yes;RUN_EXPENSIVE_TESTS=yes;;
+ (e) RUN_EXPENSIVE_TESTS=yes;;
+ (h) usage; exit 0 ;;
+ (--) shift ; break ;;
+ (*) die "Unknown option '$OPTARG'" ;;
+ esac
+ shift
+done
+
+PROGRAM=$1
+[ -z "$PROGRAM" ] && die "missing PROGRAM name. See '-h' for help."
+
+
+[ -d "./tests" ] || die "'tests/' directory not found." \
+ "Please run this script from the" \
+ "main directory of 'Coreutils'."
+
+TESTS=$(find ./tests/ \( -name '*.sh' -o -name '*.pl' \) -print | \
+ grep -w -- "$PROGRAM" | paste -s -d' ')
+[ -z "$TESTS" ] && die "no tests found for '$PROGRAM'"
+
+echo "Running the following tests for '$PROGRAM':"
+echo "$TESTS" | tr ' ' '\n' | sed 's/^/ /'
+
+$MAKE check TESTS="$TESTS" VERBOSE=yes SUBDIRS=. \
+ RUN_EXPENSIVE_TESTS=$RUN_EXPENSIVE_TESTS \
+ RUN_VERY_EXPENSIVE_TESTS=$RUN_VERY_EXPENSIVE_TESTS
--
1.8.4.3