Whamcloud - gitweb
tests: clean up $DEBUGFS_EXE usage in scripts
[tools/e2fsprogs.git] / tests / d_punch_bigalloc / script
1 if ! test -x $DEBUGFS_EXE; then
2         echo "$test_name: $test_description: skipped (no debugfs)"
3         return 0
4 fi
5
6 FSCK_OPT=-fy
7 OUT=$test_name.log
8 if [ -f $test_dir/expect.gz ]; then
9         EXP=$test_name.tmp
10         gunzip < $test_dir/expect.gz > $EXP1
11 else
12         EXP=$test_dir/expect
13 fi
14
15 cp /dev/null $OUT
16
17 cat > $TMPFILE.conf << ENDL
18 [fs_types]
19 ext4 = {
20         cluster_size = 8192
21         base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr,^has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,64bit
22         blocksize = 1024
23         inode_size = 256
24         inode_ratio = 16384
25 }
26 ENDL
27 MKE2FS_CONFIG=$TMPFILE.conf $MKE2FS -F -o Linux -b 1024 -O bigalloc -T ext4 $TMPFILE 65536 2>&1 | sed -f $cmd_dir/filter.sed >> $OUT 2>&1
28 rm -rf $TMPFILE.conf
29
30 $FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1
31 status=$?
32 echo Exit status is $status >> $OUT.new
33 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
34 rm -f $OUT.new
35
36 echo "debugfs write files" >> $OUT
37 make_file() {
38         name="$1"
39         start="$2"
40         flag="$3"
41
42         cat << ENDL
43 write /dev/null $name
44 fallocate /$name 0 39
45 punch /$name 10 10
46 punch /$name 13 13
47 punch /$name 26 26
48 punch /$name 29 29
49 ENDL
50 }
51
52 #Files we create:
53 # a: punch a 40k file
54 # b*: punch sparse file starting at b*
55 # c*: punch spare file ending at c*
56 # d: midcluster to midcluster, surrounding sparse
57 # e: partial middle cluster alloc
58 # f: one big file
59 base=5000
60 cat > $TMPFILE.cmd << ENDL
61 write /dev/null a
62 fallocate /a 0 39
63 punch /a 0 39
64 ENDL
65 echo "ex /a" >> $TMPFILE.cmd2
66
67 make_file sample $base --uninit >> $TMPFILE.cmd
68 echo "ex /sample" >> $TMPFILE.cmd2
69 base=10000
70
71 for i in 8 9 10 11 12 13 14 15; do
72         make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd
73         echo "punch /b$i $i 39" >> $TMPFILE.cmd
74         echo "ex /b$i" >> $TMPFILE.cmd2
75 done
76
77 for i in 24 25 26 27 28 29 30 31; do
78         make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd
79         echo "punch /c$i 0 $i" >> $TMPFILE.cmd
80         echo "ex /c$i" >> $TMPFILE.cmd2
81 done
82
83 make_file d $(($base + 640)) --uninit >> $TMPFILE.cmd
84 echo "punch /d 4 35" >> $TMPFILE.cmd
85 echo "ex /d" >> $TMPFILE.cmd2
86
87 make_file e $(($base + 680)) --uninit >> $TMPFILE.cmd
88 echo "punch /e 19 20" >> $TMPFILE.cmd
89 echo "ex /e" >> $TMPFILE.cmd2
90
91 cat >> $TMPFILE.cmd << ENDL
92 write /dev/null f
93 sif /f size 1024
94 eo /f
95 set_bmap --uninit 0 9000
96 ec
97 sif /f blocks 16
98 setb 9000
99 fallocate /f 0 8999
100 punch /f 1 8998
101 ENDL
102 echo "ex /f" >> $TMPFILE.cmd2
103
104 $DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1
105 $DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1
106 sed -f $cmd_dir/filter.sed < $OUT.new >> $OUT
107 rm -rf $OUT.new $TMPFILE.cmd $TMPFILE.cmd2
108
109 $FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1
110 status=$?
111 echo Exit status is $status >> $OUT.new
112 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
113 rm -f $OUT.new
114
115 rm -f $TMPFILE
116
117 cmp -s $OUT $EXP
118 status=$?
119
120 if [ "$status" = 0 ] ; then
121         echo "$test_name: $test_description: ok"
122         touch $test_name.ok
123 else
124         echo "$test_name: $test_description: failed"
125         diff $DIFF_OPTS $EXP $OUT > $test_name.failed
126         rm -f $test_name.tmp
127 fi
128
129 unset IMAGE FSCK_OPT OUT EXP