1if ! test -x $DEBUGFS_EXE; then
2	echo "$test_name: $test_description: skipped (no debugfs)"
3	return 0
4fi
5
6OUT=$test_name.log
7EXP=$test_dir/expect
8VERIFY_FSCK_OPT=-yf
9
10TEST_DATA=$test_name.tmp
11VERIFY_DATA=$test_name.ver.tmp
12
13echo "debugfs create special files" > $OUT.new
14
15dd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
16
17echo "mke2fs -Fq -b 1024 test.img 512" >> $OUT.new
18
19$MKE2FS -Fq -b 1024 -o linux $TMPFILE 512 > /dev/null 2>&1
20status=$?
21echo Exit status is $status >> $OUT.new
22
23$DEBUGFS -w $TMPFILE << EOF > /dev/null 2>&1
24set_current_time 20130115140000
25set_super_value lastcheck 0
26set_super_value hash_seed null
27set_super_value mkfs_time 0
28symlink foo bar
29symlink foo2 12345678901234567890123456789012345678901234567890123456789012345678901234567890
30mknod pipe p
31mknod sda b 8 0
32mknod null c 1 3
33EOF
34
35echo "debugfs -R ''stat foo'' -w test.img" >> $OUT.new
36$DEBUGFS -R "stat foo" -w $TMPFILE >> $OUT.new 2>&1
37status=$?
38echo Exit status is $status >> $OUT.new
39
40echo "debugfs -R ''stat foo2'' -w test.img" >> $OUT.new
41$DEBUGFS -R "stat foo2" -w $TMPFILE >> $OUT.new 2>&1
42status=$?
43echo Exit status is $status >> $OUT.new
44
45echo "debugfs -R ''block_dump 28'' -w test.img" >> $OUT.new
46$DEBUGFS -R "block_dump 28" -w $TMPFILE >> $OUT.new 2>&1
47status=$?
48echo Exit status is $status >> $OUT.new
49
50echo "debugfs -R ''stat pipe'' -w test.img" >> $OUT.new
51$DEBUGFS -R "stat pipe" -w $TMPFILE >> $OUT.new 2>&1
52status=$?
53echo Exit status is $status >> $OUT.new
54
55echo "debugfs -R ''stat sda'' -w test.img" >> $OUT.new
56$DEBUGFS -R "stat sda" -w $TMPFILE >> $OUT.new 2>&1
57status=$?
58echo Exit status is $status >> $OUT.new
59
60echo "debugfs -R ''stat null'' -w test.img" >> $OUT.new
61$DEBUGFS -R "stat null" -w $TMPFILE >> $OUT.new 2>&1
62status=$?
63echo Exit status is $status >> $OUT.new
64
65echo e2fsck $VERIFY_FSCK_OPT -N test_filesys >> $OUT.new
66$FSCK $VERIFY_FSCK_OPT -N test_filesys $TMPFILE >> $OUT.new 2>&1
67status=$?
68echo Exit status is $status >> $OUT.new
69sed -f $cmd_dir/filter.sed $OUT.new > $OUT
70
71#
72# Do the verification
73#
74
75rm -f $TMPFILE $OUT.new
76cmp -s $OUT $EXP
77status=$?
78
79if [ "$status" = 0 ] ; then
80	echo "$test_name: $test_description: ok"
81	touch $test_name.ok
82else
83	echo "$test_name: $test_description: failed"
84	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
85fi
86
87unset VERIFY_FSCK_OPT NATIVE_FSCK_OPT OUT EXP TEST_DATA VERIFY_DATA
88