Whamcloud - gitweb
86d1deee37a3b0971261ed53ff1c40605cdebb10
[tools/e2fsprogs.git] / tests / d_fallocate_blkmap / 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         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
21         blocksize = 1024
22         inode_size = 256
23         inode_ratio = 16384
24 }
25 ENDL
26 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
27 rm -rf $TMPFILE.conf
28
29 $FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1
30 status=$?
31 echo Exit status is $status >> $OUT.new
32 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
33 rm -f $OUT.new
34
35 echo "debugfs write files" >> $OUT
36
37 #Files we create:
38 # a: fallocate a 40k file
39 # k: one big file
40 base=5000
41 cat > $TMPFILE.cmd << ENDL
42 write /dev/null a
43 sif /a bmap[2] 8000
44 sif /a size 40960
45 sif /a i_blocks 2
46 setb 8000
47 fallocate /a 0 39
48
49 write /dev/null b
50 sif /b size 10240000
51 sif /b bmap[0] 10000
52 sif /b i_blocks 2
53 setb 10000
54 fallocate /b 0 9999
55 ENDL
56 echo "stat /a" >> $TMPFILE.cmd2
57 echo "stat /b" >> $TMPFILE.cmd2
58
59 $DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1
60 $DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1
61 sed -f $cmd_dir/filter.sed -e '/^.*time:.*$/d' < $OUT.new >> $OUT
62 rm -rf $OUT.new $TMPFILE.cmd $TMPFILE.cmd2
63
64 $FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1
65 status=$?
66 echo Exit status is $status >> $OUT.new
67 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT
68 rm -f $OUT.new
69
70 rm -f $TMPFILE
71
72 cmp -s $OUT $EXP
73 status=$?
74
75 if [ "$status" = 0 ] ; then
76         echo "$test_name: $test_description: ok"
77         touch $test_name.ok
78 else
79         echo "$test_name: $test_description: failed"
80         diff $DIFF_OPTS $EXP $OUT > $test_name.failed
81         rm -f $test_name.tmp
82 fi
83
84 unset IMAGE FSCK_OPT OUT EXP