OSDN Git Service

Code drop from //branches/cupcake/...@124589
[android-x86/external-e2fsprogs.git] / tests / test_script.in
1 #!/bin/sh
2 #
3 # Test script for e2fsck
4 #
5
6 LC_ALL=C
7 export LC_ALL
8
9 case "$1" in 
10     --valgrind)
11         export USE_VALGRIND="valgrind -q --weird-hacks=lax-ioctls"
12         shift;
13 esac
14
15 if test "$1"x = x ; then
16   TESTS=`ls -d $SRCDIR/[a-zA-Z]_* | $EGREP -v "\.failed|\.new"`
17 else
18   TESTS=
19   for i 
20   do
21     case $i in
22         *.failed|*.new) continue ;;
23         [a-zA-Z])       TESTS="$TESTS $SRCDIR/${i}_*" ;;
24         *)              TESTS="$TESTS $SRCDIR/$i" ;;
25     esac
26   done
27 fi
28
29 cmd_dir=$SRCDIR
30
31 if test "$TEST_CONFIG"x = x; then
32         TEST_CONFIG=$SRCDIR/test_config
33 fi
34
35 . $TEST_CONFIG
36
37 for test_dir in $TESTS
38 do
39         test_name=`echo $test_dir | sed -e 's;.*/;;'`
40         if [ -f $test_dir ] ; then
41             continue;
42         fi
43         if [ ! -d $test_dir ] ; then
44                 echo "The test '$test_name' does not exist."
45                 continue;
46         fi
47         if [ -z "`ls $test_dir`" ]; then
48                 continue
49         fi
50         if [ -f $test_dir/name ]; then
51                 test_description=`cat $test_dir/name`
52                 printf "%s: %s: " "$test_name" "$test_description"
53         else
54                 printf "%s: " "$test_name"
55         fi
56         if [ -f $test_dir/script ]; then
57                 . $test_dir/script
58         else
59                 test_base=`echo $test_name | sed -e 's/_.*//'`
60                 default_script=$SRCDIR/defaults/${test_base}_script
61                 if [ -f $default_script ]; then
62                         . $SRCDIR/defaults/${test_base}_script
63                 else
64                         echo "Missing test script!"
65                 fi
66         fi
67 done
68
69 num_ok=`ls *.ok 2>/dev/null | wc -l`
70 num_failed=`ls *.failed 2>/dev/null | wc -l`
71
72 echo "$num_ok tests succeeded   $num_failed tests failed"
73
74 test "$num_failed" -eq 0 || exit 1