test_script.in revision cfe7ba49782892747f212b7a541820975a86b37d
1a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#!/bin/sh
2a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#
3a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o# Test script for e2fsck
4a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o#
5a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
6cfe7ba49782892747f212b7a541820975a86b37dTheodore Ts'ocase "$1" in 
7cfe7ba49782892747f212b7a541820975a86b37dTheodore Ts'o    --valgrind)
8cfe7ba49782892747f212b7a541820975a86b37dTheodore Ts'o    	export USE_VALGRIND="valgrind -q --weird-hacks=lax-ioctls"
9cfe7ba49782892747f212b7a541820975a86b37dTheodore Ts'o	shift;
10cfe7ba49782892747f212b7a541820975a86b37dTheodore Ts'oesac
11cfe7ba49782892747f212b7a541820975a86b37dTheodore Ts'o
12a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'oif test "$1"x = x ; then
1332237014a1bd0ee2cdec9a54344f84c5c178c75fTheodore Ts'o  TESTS=`ls -d $SRCDIR/[a-zA-Z]_* | $EGREP -v "\.failed|\.new"`
14a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'oelse
151e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  TESTS=
161e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  for i 
171e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  do
18521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o    case $i in
19888b29d14b314eb150b0de010c63c0520cc53f87Andreas Dilger	*.failed|*.new)	continue ;;
20521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o	[a-zA-Z])	TESTS="$TESTS $SRCDIR/${i}_*" ;;
21521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o	*)		TESTS="$TESTS $SRCDIR/$i" ;;
22521e36857227b21e7ab47b0a97f788d2af9f9717Theodore Ts'o    esac
231e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'o  done
24a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'ofi
25a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
26a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'ocmd_dir=$SRCDIR
27a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
285c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'oif test "$TEST_CONFIG"x = x; then
295c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'o	TEST_CONFIG=$SRCDIR/test_config
305c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'ofi
315c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'o
325c576477ccb2f0ca8c5d5af2e2354fd8eeff1589Theodore Ts'o. $TEST_CONFIG
33a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
341e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'ofor test_dir in $TESTS
35a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'odo
36a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o	test_name=`echo $test_dir | sed -e 's;.*/;;'`
3793d29696dfb81a1203de2859626a95ca1e467dbeTheodore Ts'o	if [ -f $test_dir ] ; then
3893d29696dfb81a1203de2859626a95ca1e467dbeTheodore Ts'o	    continue;
3993d29696dfb81a1203de2859626a95ca1e467dbeTheodore Ts'o	fi
4019c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o	if [ ! -d $test_dir ] ; then
4119c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o		echo "The test '$test_name' does not exist."
4219c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o		continue;
4319c78dc07fce2d6f39b5e541562afc3ca1ea38ffTheodore Ts'o	fi
44a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o	if [ -f $test_dir/name ]; then
45a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o		test_description=`cat $test_dir/name`
467d4343d0d05ce69e0a72da5ac34eea415d4c789fTheodore Ts'o		printf "%s: %s: " "$test_name" "$test_description"
47a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o	else
487d4343d0d05ce69e0a72da5ac34eea415d4c789fTheodore Ts'o		printf "%s: " "$test_name"
49a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o	fi
50a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o	if [ -f $test_dir/script ]; then
51a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o		. $test_dir/script
52a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o	else
53a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o		test_base=`echo $test_name | sed -e 's/_.*//'`
54a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o		default_script=$SRCDIR/defaults/${test_base}_script
55a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o		if [ -f $default_script ]; then
56a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o			. $SRCDIR/defaults/${test_base}_script
57a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o		else
58a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o			echo "Missing test script!"
59a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o		fi
60a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o	fi
61a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'odone
62a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
631e3472c5f37ca3686dd69b079d4d02a302f5798dTheodore Ts'onum_ok=`ls *.ok 2>/dev/null | wc -l`
64a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'onum_failed=`ls *.failed 2>/dev/null | wc -l`
65a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
66a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'oecho "$num_ok tests succeeded	$num_failed tests failed"
67a418d3ad819323f871005d253f7f9ac378e78ba5Theodore Ts'o
6886a02b5d3dc1cd486ef59daed6d981060c5cb950Theodore Ts'otest "$num_failed" -eq 0 || exit 1
69