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