Whamcloud - gitweb
fc1d1155b6c87cc6f49af4c41f66fc50fb4bffae
[tools/e2fsprogs.git] / tests / m_hugefile / script
1 FSCK_OPT=-fn
2 OUT=$test_name.log
3 EXP=$test_dir/expect
4 CONF=$TMPFILE.conf
5
6 os=$(uname -s)
7 if [ "$os" = "Darwin" -o "$os" = "GNU" -o "FreeBSD" ]; then
8         # creates a 44GB filesystem
9         echo "$test_name: $test_description: skipped for $os"
10         return 0
11 fi
12
13 cat > $CONF << ENDL
14 [fs_types]
15         hugefile = {
16                 features = extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,^resize_inode,sparse_super2
17                 hash_alg = half_md4
18                 num_backup_sb = 0
19                 packed_meta_blocks = 1
20                 make_hugefiles = 1
21                 inode_ratio = 4194304
22                 hugefiles_dir = /store
23                 hugefiles_name = big-data
24                 hugefiles_digits = 0
25                 hugefiles_size = 0
26                 hugefiles_align = 256M
27                 num_hugefiles = 1
28                 zero_hugefiles = false
29                 flex_bg_size = 262144
30         }
31 ENDL
32
33 echo "mke2fs -F -T hugefile test.img 4T" > $OUT
34 MKE2FS_CONFIG=$CONF $MKE2FS -F -T hugefile $TMPFILE 4T >> $OUT 2>&1
35 rm -f $CONF
36
37 # check the file system if we get this far, we succeeded...
38 $FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1
39 status=$?
40 echo Exit status is $status >> $OUT
41
42 echo 'debugfs -R "extents /store/big-data" test.img' >> $OUT
43
44 $DEBUGFS -R "extents /store/big-data" $TMPFILE 2>&1 | tr / " " | tr -d - | awk '
45 BEGIN {
46         expected_logical_start = 0;
47         expected_physical_start = 0;
48 }
49 {
50         if (NR != 1) {
51                 level = $1;
52                 total_levels = $2;
53
54                 if (level == total_levels) {
55                         logical_start=$5;
56                         logical_end=$6;
57                         physical_start=$7;
58                         physical_end=$8;
59                         len = $9;
60
61                         if (logical_end + 1 - logical_start != len) {
62                                 print logical_end + 1 - logical_start, len;
63                                 print "UNEXPECTED LENGTH for extent", $0;
64                         }
65                         if (physical_end + 1 - physical_start != len) {
66                                 print physical_end + 1 - physical_start, len;
67                                 print "UNEXPECTED LENGTH for extent", $0;
68                         }
69
70                         if (logical_start != expected_logical_start) {
71                                 print "UNEXPECTED LOGICAL DISCONTINUITY between extents:";
72                                 print "\t", prev;
73                                 print "\t", $0;
74                         }
75                         if (physical_start != expected_physical_start &&
76                                 expected_logical_start != 0) {
77                                 print "PHYSICAL DISCONTINUITY between extents:";
78                                 print "\t", prev;
79                                 print "\t", $0;
80                         }
81
82                         expected_logical_start = logical_end + 1;
83                         expected_physical_start = physical_end + 1;
84                 }
85         }
86         prev=$0;
87 }
88 END {
89     print "Last logical block:", expected_logical_start-1;
90     print "Last physical block:", expected_physical_start-1;
91 }
92 ' >> $OUT 2>&1
93
94 rm $TMPFILE
95
96 #
97 # Do the verification
98 #
99
100 sed -f $cmd_dir/filter.sed $OUT > $OUT.new
101 mv $OUT.new $OUT
102
103 cmp -s $OUT $EXP
104 status=$?
105
106 if [ "$status" = 0 ] ; then
107         echo "$test_name: $test_description: ok"
108         touch $test_name.ok
109 else
110         echo "$test_name: $test_description: failed"
111         diff $DIFF_OPTS $EXP $OUT > $test_name.failed
112 fi
113
114 unset IMAGE FSCK_OPT OUT EXP CONF