1#!/bin/sh 2# run a single regression test 3 4export DD 5 6LC_ALL=C 7export LC_ALL 8 9case "$1" in 10 --valgrind) 11 export USE_VALGRIND="valgrind -q --sim-hints=lax-ioctls" 12 shift; 13 ;; 14 --valgrind-leakcheck) 15 export USE_VALGRIND="valgrind --sim-hints=lax-ioctls --leak-check=full --show-reachable=yes --log-file=/tmp/valgrind-%p.log" 16 shift; 17 ;; 18 --skip-slow-tests) 19 SKIP_SLOW_TESTS=yes 20 shift; 21 ;; 22esac 23 24case "$1" in 25 *.failed|*.new|*.ok|*.log|*.tmp|*.slow) exit 0 ;; 26esac 27 28test_dir=$1 29cmd_dir=$SRCDIR 30 31if test "$TEST_CONFIG"x = x; then 32 TEST_CONFIG=$SRCDIR/test_config 33fi 34 35. $TEST_CONFIG 36 37test_name=`echo $test_dir | sed -e 's;.*/;;'` 38 39if [ -f $test_dir ] ; then 40 exit 0; 41fi 42if [ ! -d $test_dir ] ; then 43 echo "The test '$test_name' does not exist." 44 exit 0; 45fi 46if [ -z "`ls $test_dir`" ]; then 47 exit 0 48fi 49if [ -f $test_dir/name ]; then 50 test_description=`cat $test_dir/name` 51else 52 test_description= 53fi 54 55if [ -n "$SKIP_SLOW_TESTS" -a -f $test_dir/is_slow_test ]; then 56 echo "$test_name: $test_description: skipped (slow test)" 57 exit 0 58fi 59 60rm -f $test_name.ok $test_name.failed $test_name.log $test_name.slow 61#echo -e -n "$test_name: $test_description:\r" 62 63TMPFILE=$(mktemp ${TMPDIR:-/tmp}/e2fsprogs-tmp-$test_name.XXXXXX) 64[ "$SKIP_UNLINK" != "true" ] && trap 'rm -f $TMPFILE ; exit' 0 1 2 15 65 66start=$SECONDS 67if [ -f $test_dir/script ]; then 68 . $test_dir/script 69else 70 test_base=`echo $test_name | sed -e 's/_.*//'` 71 default_script=$SRCDIR/defaults/${test_base}_script 72 if [ -f $default_script ]; then 73 . $SRCDIR/defaults/${test_base}_script 74 else 75 echo "$test_name: Missing test script $default_script!" 76 fi 77fi 78elapsed=$((SECONDS - start)) 79if [ $elapsed -gt 60 -a ! -f $test_dir/is_slow_test ]; then 80 echo "$test_name: *** took $elapsed seconds to finish ***" | 81 tee $test_name.slow 82 echo "$test_name: consider adding $test_dir/is_slow_test" 83fi 84 85if [ -n "$PRINT_FAILED" -a -f $test_name.failed ] ; then 86 cat $test_name.failed 87fi 88 89if [ "$SKIP_UNLINK" != "true" ] ; then 90 rm -f $TMPFILE 91fi 92 93