#!/bin/sh
+# Run all or specified test scripts
#
-# Test script for e2fsck
-#
-
-LC_ALL=C
-export LC_ALL
-case "$1" in
+case "$1" in
--valgrind)
- export USE_VALGRIND="valgrind -q --weird-hacks=lax-ioctls"
- shift;
+ export USE_VALGRIND="valgrind -q --sim-hints=lax-ioctls"
+ shift
+ ;;
+ --valgrind-leakcheck)
+ export USE_VALGRIND="valgrind --sim-hints=lax-ioctls --leak-check=full --show-reachable=yes --log-file=/tmp/valgrind-%p.log"
+ shift
+ ;;
+ --failed)
+ DO_FAILED=yes
+ shift
+ ;;
esac
-if test "$1"x = x ; then
- TESTS=`ls -d $SRCDIR/[a-zA-Z]_* | $EGREP -v "\.failed|\.new"`
-else
- TESTS=
- for i
- do
- case $i in
- *.failed|*.new) continue ;;
- [a-zA-Z]) TESTS="$TESTS $SRCDIR/${i}_*" ;;
- *) TESTS="$TESTS $SRCDIR/$i" ;;
- esac
- done
+TESTS=
+
+if test -n "$DO_FAILED"; then
+ FAILED=$(find . -maxdepth 1 -name \*.failed)
+ if test -z "$FAILED" ; then
+ echo " "
+ echo "No (more) failed tests!"
+ echo " "
+ fi
+ for fname in $FAILED ; do
+ TESTS="$TESTS $SRCDIR/${fname%%.failed}"
+ done
fi
-cmd_dir=$SRCDIR
+for i; do
+ case $i in
+ [a-zA-Z]) TESTS="$TESTS $SRCDIR/${i}_*" ;;
+ *) TESTS="$TESTS $SRCDIR/$i" ;;
+ esac
+done
-if test "$TEST_CONFIG"x = x; then
- TEST_CONFIG=$SRCDIR/test_config
+if test "$TESTS"x = x ; then
+ if test -n "$DO_FAILED"; then
+ exit 0
+ fi
+ TESTS=`ls -d $SRCDIR/[a-zA-Z]_*`
fi
-. $TEST_CONFIG
-
-for test_dir in $TESTS
-do
- test_name=`echo $test_dir | sed -e 's;.*/;;'`
- if [ -f $test_dir ] ; then
- continue;
- fi
- if [ ! -d $test_dir ] ; then
- echo "The test '$test_name' does not exist."
- continue;
- fi
- if [ -z "`ls $test_dir`" ]; then
- continue
- fi
- if [ -f $test_dir/name ]; then
- test_description=`cat $test_dir/name`
- printf "%s: %s: " "$test_name" "$test_description"
- else
- printf "%s: " "$test_name"
- fi
- if [ -f $test_dir/script ]; then
- . $test_dir/script
- else
- test_base=`echo $test_name | sed -e 's/_.*//'`
- default_script=$SRCDIR/defaults/${test_base}_script
- if [ -f $default_script ]; then
- . $SRCDIR/defaults/${test_base}_script
- else
- echo "Missing test script!"
- fi
- fi
+for test_dir in $TESTS; do
+ ./test_one $test_dir
done
-num_ok=`ls *.ok 2>/dev/null | wc -l`
-num_failed=`ls *.failed 2>/dev/null | wc -l`
-
-echo "$num_ok tests succeeded $num_failed tests failed"
-
-test "$num_failed" -eq 0 || exit 1
+$SRCDIR/test_post