Whamcloud - gitweb
tests: skip tests that require debugfs if debugfs has not been built
[tools/e2fsprogs.git] / tests / d_loaddump / script
1 if test -x $DEBUGFS_EXE; then
2
3 OUT=$test_name.log
4 EXP=$test_dir/expect
5 VERIFY_FSCK_OPT=-yf
6
7 TEST_DATA=test.data
8 VERIFY_DATA=test.verify
9
10 echo "debugfs load/dump test" > $OUT
11
12 dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
13
14 echo "mke2fs -Fq -b 1024 test.img 512" >> $OUT
15
16 $MKE2FS -Fq $TMPFILE 512 > /dev/null 2>&1
17 status=$?
18 echo Exit status is $status >> $OUT
19
20 dd if=$TEST_BITS of=$TEST_DATA bs=128k count=1 conv=sync > /dev/null 2>&1 
21 echo "file fragment odd size" >> $TEST_DATA
22
23 echo "debugfs -R ''write $TEST_DATA test_data'' -w test.img" > $OUT.new
24 $DEBUGFS -R "write $TEST_DATA test_data" -w $TMPFILE >> $OUT.new 2>&1
25 status=$?
26 echo Exit status is $status >> $OUT.new
27 sed -e '2d' $OUT.new >> $OUT
28
29 echo e2fsck $VERIFY_FSCK_OPT -N test_filesys > $OUT.new
30 $FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
31 status=$?
32 echo Exit status is $status >> $OUT.new
33 sed -e '2d' $OUT.new >> $OUT
34
35 echo "debugfs -R ''dump test_data $VERIFY_DATA'' test.img" > $OUT.new
36 $DEBUGFS -R "dump test_data $VERIFY_DATA" $TMPFILE >> $OUT.new 2>&1
37 status=$?
38 echo Exit status is $status >> $OUT.new
39 sed -e '2d' $OUT.new >> $OUT
40
41 echo "cmp $TEST_DATA $VERIFY_DATA" >> $OUT
42 cmp $TEST_DATA $VERIFY_DATA >>$OUT
43 status=$?
44 echo Exit status is $status >> $OUT
45
46 #
47 # Do the verification
48 #
49
50 rm -f $test_name.ok $test_name.failed $VERIFY_DATA $TEST_DATA $TMPFILE $OUT.new
51 cmp -s $OUT $EXP
52 status=$?
53
54 if [ "$status" = 0 ] ; then
55         echo "ok"
56         touch $test_name.ok
57 else
58         echo "failed"
59         diff $DIFF_OPTS $EXP $OUT > $test_name.failed
60 fi
61
62 unset VERIFY_FSCK_OPT NATIVE_FSCK_OPT OUT EXP TEST_DATA VERIFY_DATA
63
64 else #if test -x $DEBUGFS_EXE; then
65         rm -f $test_name.ok $test_name.failed
66         echo "skipped"
67 fi