summaryrefslogtreecommitdiffstats
path: root/tests/d_loaddump/script
blob: ace33723cc3b09175e58e7c47bbdc335b66370e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
if ! test -x $DEBUGFS_EXE; then
	echo "$test_name: $test_description: skipped (no debugfs)"
	return 0
fi

OUT=$test_name.log
EXP=$test_dir/expect
VERIFY_FSCK_OPT=-yf

TEST_DATA=$test_name.tmp
VERIFY_DATA=$test_name.ver.tmp

echo "debugfs load/dump test" > $OUT.new

dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1

echo "mke2fs -Fq -b 1024 test.img 512" >> $OUT.new

$MKE2FS -Fq -b 1024 $TMPFILE 512 > /dev/null 2>&1
status=$?
echo Exit status is $status >> $OUT.new

dd if=$TEST_BITS of=$TEST_DATA bs=128k count=1 conv=sync > /dev/null 2>&1 
echo "file fragment odd size" >> $TEST_DATA

echo "debugfs -R ''write $TEST_DATA test_data'' -w test.img" >> $OUT.new
$DEBUGFS -R "write $TEST_DATA test_data" -w $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new

echo e2fsck $VERIFY_FSCK_OPT -N test_filesys >> $OUT.new
$FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new

echo "debugfs -R ''dump test_data $VERIFY_DATA'' test.img" >> $OUT.new
$DEBUGFS -R "dump test_data $VERIFY_DATA" $TMPFILE >> $OUT.new 2>&1
status=$?
echo Exit status is $status >> $OUT.new

echo "cmp $TEST_DATA $VERIFY_DATA" >> $OUT.new
cmp $TEST_DATA $VERIFY_DATA >>$OUT.new
status=$?
echo Exit status is $status >> $OUT.new
sed -f $cmd_dir/filter.sed $OUT.new > $OUT

#
# Do the verification
#

if [ "$SKIP_UNLINK" != "true" ]; then
	rm -f $VERIFY_DATA $TEST_DATA $TMPFILE $OUT.new
else
	echo "TMPFILE=$TMPFILE"
fi
cmp -s $OUT $EXP
status=$?

if [ "$status" = 0 ] ; then
	echo "$test_name: $test_description: ok"
	touch $test_name.ok
else
	echo "$test_name: $test_description: failed"
	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
fi

unset VERIFY_FSCK_OPT NATIVE_FSCK_OPT OUT EXP TEST_DATA VERIFY_DATA