• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2TESTS=$*
3
4if test "$TESTS"x = x ; then
5	for i in $SRCDIR/tests/*.img.bz2
6	do
7		TESTS="$TESTS `basename $i .img.bz2`"
8	done
9fi
10
11mkdir -p tests/tmp
12
13for i in $TESTS
14do
15	printf "%s: " $i
16	RESULTS=$SRCDIR/tests/$i.results
17	IMAGE_BZ2=$SRCDIR/tests/$i.img.bz2
18	IMAGE=tests/tmp/$i.img.$$
19	if test ! -f $IMAGE_BZ2 -a ! -f $RESULTS ;
20	then
21		echo "non-existent"
22		continue
23	fi
24	if [ "$i" = "swap0" ]; then
25		# swap is native-endian, so regenerate before testing
26		dd if=/dev/zero of=$IMAGE bs=16k count=64 2> /dev/null
27		mkswap -v0 $IMAGE > /dev/null
28	elif [ "$i" = "swap1" ]; then
29		# swap is native-endian, so regenerate before testing
30		dd if=/dev/zero of=$IMAGE bs=16k count=64 2> /dev/null
31		# check if mkswap supports the "-U" option
32		if mkswap -h 2>&1 | grep -q -- '-U'; then
33			UUID="-U 8ff8e77f-8553-485e-8656-58be67a81666"
34		else
35			RMUUID="| grep -v UUID"
36			RES_TMP=$SRCDIR/tests/tmp/$i.results
37			grep -v UUID $RESULTS > $RES_TMP
38			RESULTS=$RES_TMP
39		fi
40		mkswap -v1 -L SWAP-TEST $UUID $IMAGE >/dev/null
41	else
42		bunzip2 < $IMAGE_BZ2 > $IMAGE
43	fi
44	eval ./tst_probe $IMAGE $RMUUID > tests/$i.out
45	rm -f $IMAGE tests/$i.ok tests/$i.failed
46	cmp -s tests/$i.out $RESULTS
47	unset RMUUID
48	if [ $? = 0 ];  then
49		echo ok
50		touch tests/$i.ok
51	else
52		echo failed
53		diff -c tests/$i.out $RESULTS > tests/$i.failed
54	fi
55done
56
57num_ok=`ls tests/*.ok 2>/dev/null | wc -l`
58num_failed=`ls tests/*.failed 2>/dev/null | wc -l`
59
60echo "$num_ok tests succeeded	$num_failed tests failed"
61
62test "$num_failed" -eq 0 || exit 1
63