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