Whamcloud - gitweb
b8d72cc63fb8ae0e0ba139b2a4a5b09019538754
[tools/e2fsprogs.git] / tests / test_script.in
1 #!/bin/sh
2 #
3 # Test script for e2fsck
4 #
5
6 if test "$1"x = x ; then
7   TESTS=`ls -d $SRCDIR/[a-zA-Z]_* | $EGREP -v "\.failed|\.new"`
8 else
9   TESTS=
10   for i 
11   do
12     case $i in
13         *.failed|*.new) continue ;;
14         [a-zA-Z])       TESTS="$TESTS $SRCDIR/${i}_*" ;;
15         *)              TESTS="$TESTS $SRCDIR/$i" ;;
16     esac
17   done
18 fi
19
20 cmd_dir=$SRCDIR
21
22 if test "$TEST_CONFIG"x = x; then
23         TEST_CONFIG=$SRCDIR/test_config
24 fi
25
26 . $TEST_CONFIG
27
28 for test_dir in $TESTS
29 do
30         test_name=`echo $test_dir | sed -e 's;.*/;;'`
31         if [ -f $test_dir ] ; then
32             continue;
33         fi
34         if [ ! -d $test_dir ] ; then
35                 echo "The test '$test_name' does not exist."
36                 continue;
37         fi
38         if [ -f $test_dir/name ]; then
39                 test_description=`cat $test_dir/name`
40                 printf "%s: %s: " "$test_name" "$test_description"
41         else
42                 printf "%s: " "$test_name"
43         fi
44         if [ -f $test_dir/script ]; then
45                 . $test_dir/script
46         else
47                 test_base=`echo $test_name | sed -e 's/_.*//'`
48                 default_script=$SRCDIR/defaults/${test_base}_script
49                 if [ -f $default_script ]; then
50                         . $SRCDIR/defaults/${test_base}_script
51                 else
52                         echo "Missing test script!"
53                 fi
54         fi
55 done
56
57 num_ok=`ls *.ok 2>/dev/null | wc -l`
58 num_failed=`ls *.failed 2>/dev/null | wc -l`
59
60 echo "$num_ok tests succeeded   $num_failed tests failed"
61