summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2010-04-05 21:50:25 +0200
committerMichael Buesch <mb@bu3sch.de>2010-04-05 21:50:25 +0200
commitbba78e75dae72d5f090ad3a472e116a912e426ba (patch)
tree3507881cee8923b105d787737a08a4eb3d607491 /tests
parentbd0c8f5b87b57f47f7fb5e6481a5f2e40d557847 (diff)
downloadtoprammer-bba78e75dae72d5f090ad3a472e116a912e426ba.tar.xz
toprammer-bba78e75dae72d5f090ad3a472e116a912e426ba.zip
testsuite: Add commandline options to run only specified tests
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run-tests.sh83
1 files changed, 66 insertions, 17 deletions
diff --git a/tests/run-tests.sh b/tests/run-tests.sh
index 39ad135..3fc7862 100755
--- a/tests/run-tests.sh
+++ b/tests/run-tests.sh
@@ -126,6 +126,32 @@ function compare_file_to_hex # $1=file $2=hex_string
[ "$filehex" = "$2" ]
}
+function usage
+{
+ echo "Usage: run-tests.sh <OPTIONS> <SCRIPTPATH>"
+ echo
+ echo "Options:"
+ echo " -h|--help Show this help text"
+ echo
+ echo "If the optional scriptpath is specified, only that testscript"
+ echo "is executed. The scriptpath is DEVICE/TESTSCRIPT. Example:"
+ echo " top2049/001-atmega32dip40.test"
+ echo "This will execute the atmega32 test for the TOP2049 and exit."
+ echo "If no path is specified, all tests will be executed."
+}
+
+# Parse commandline
+nr_scriptpaths=0
+while [ $# -gt 0 ]; do
+ if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ usage
+ exit 0
+ fi
+ scriptpaths[nr_scriptpaths]="$1"
+ let nr_scriptpaths=nr_scriptpaths+1
+ shift
+done
+
current_test=
current_device=
cleanup
@@ -169,22 +195,45 @@ testfile_128k="$tmpdir/testfile_128k"
create_random_file "$testfile_128k" 4096 32
-for device in $(ls "$basedir"); do
- devdir="$basedir/$device"
- [ -d "$devdir" ] || continue
- [ "$device" == "generic" ] || request_TOP "$device" || continue
- current_device="$device"
-
- for testscript in $(ls "$devdir"); do
- current_test="$device/$testscript"
- echo "Running $current_test..."
- . "$basedir/defaults.test"
- . "$devdir/$testscript"
- rm -f "$tmpfile"
- test_init
- [ $? -eq 0 ] || continue
- test_run
- test_exit
+function do_run_test # $1=device, $2=testscript
+{
+ current_device="$1"
+ current_test="$1/$2"
+
+ echo "Running $current_test..."
+ rm -f "$tmpfile"
+
+ # Import the testscript
+ . "$basedir/defaults.test"
+ . "$basedir/$current_test"
+
+ # And run the tests
+ test_init
+ [ $? -eq 0 ] || continue
+ test_run
+ test_exit
+}
+
+if [ $nr_scriptpaths -eq 0 ]; then
+ # Run all scripts
+ for device in $(ls "$basedir"); do
+ [ -d "$basedir/$device" ] || continue
+ [ "$device" == "generic" ] || request_TOP "$device" || continue
+
+ for testscript in $(ls "$basedir/$device"); do
+ do_run_test "$device" "$testscript"
+ done
done
-done
+else
+ # Only run the specified tests
+ let end=nr_scriptpaths-1
+ for i in $(seq 0 $end); do
+ scriptpath="${scriptpaths[i]}"
+ device="$(echo "$scriptpath" | cut -d'/' -f1)"
+ testscript="$(echo "$scriptpath" | cut -d'/' -f2)"
+ [ -d "$basedir/$device" -a -f "$basedir/$device/$testscript" ] || \
+ die "$scriptpath is an invalid scriptpath"
+ do_run_test "$device" "$testscript"
+ done
+fi
cleanup
bues.ch cgit interface