xref: /aosp_15_r20/external/e2fsprogs/tests/d_fallocate_bigalloc/script (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Workerif ! test -x $DEBUGFS_EXE; then
2*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: skipped (no debugfs)"
3*6a54128fSAndroid Build Coastguard Worker	return 0
4*6a54128fSAndroid Build Coastguard Workerfi
5*6a54128fSAndroid Build Coastguard Worker
6*6a54128fSAndroid Build Coastguard WorkerFSCK_OPT=-fy
7*6a54128fSAndroid Build Coastguard WorkerOUT=$test_name.log
8*6a54128fSAndroid Build Coastguard Workerif [ -f $test_dir/expect.gz ]; then
9*6a54128fSAndroid Build Coastguard Worker	EXP=$test_name.tmp
10*6a54128fSAndroid Build Coastguard Worker	gunzip < $test_dir/expect.gz > $EXP
11*6a54128fSAndroid Build Coastguard Workerelse
12*6a54128fSAndroid Build Coastguard Worker	EXP=$test_dir/expect
13*6a54128fSAndroid Build Coastguard Workerfi
14*6a54128fSAndroid Build Coastguard Worker
15*6a54128fSAndroid Build Coastguard Workercat > $TMPFILE.conf << ENDL
16*6a54128fSAndroid Build Coastguard Worker[fs_types]
17*6a54128fSAndroid Build Coastguard Workerext4 = {
18*6a54128fSAndroid Build Coastguard Worker	cluster_size = 8192
19*6a54128fSAndroid Build Coastguard Worker        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
20*6a54128fSAndroid Build Coastguard Worker        blocksize = 1024
21*6a54128fSAndroid Build Coastguard Worker        inode_size = 256
22*6a54128fSAndroid Build Coastguard Worker        inode_ratio = 16384
23*6a54128fSAndroid Build Coastguard Worker}
24*6a54128fSAndroid Build Coastguard WorkerENDL
25*6a54128fSAndroid Build Coastguard WorkerMKE2FS_CONFIG=$TMPFILE.conf $MKE2FS -F -o Linux -b 1024 -O bigalloc -T ext4 $TMPFILE 65536 > $OUT.new 2>&1
26*6a54128fSAndroid Build Coastguard Workerrm -f $TMPFILE.conf
27*6a54128fSAndroid Build Coastguard Worker
28*6a54128fSAndroid Build Coastguard Worker$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
29*6a54128fSAndroid Build Coastguard Workerstatus=$?
30*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new
31*6a54128fSAndroid Build Coastguard Worker
32*6a54128fSAndroid Build Coastguard Workerecho "debugfs write files" >> $OUT.new
33*6a54128fSAndroid Build Coastguard Workermake_file() {
34*6a54128fSAndroid Build Coastguard Worker	name="$1"
35*6a54128fSAndroid Build Coastguard Worker	start="$2"
36*6a54128fSAndroid Build Coastguard Worker	flag="$3"
37*6a54128fSAndroid Build Coastguard Worker
38*6a54128fSAndroid Build Coastguard Worker	cat << ENDL
39*6a54128fSAndroid Build Coastguard Workerwrite /dev/null $name
40*6a54128fSAndroid Build Coastguard Workersif /$name size 40960
41*6a54128fSAndroid Build Coastguard Workereo /$name
42*6a54128fSAndroid Build Coastguard Workerset_bmap $flag 10 $((start + 10))
43*6a54128fSAndroid Build Coastguard Workerset_bmap $flag 13 $((start + 13))
44*6a54128fSAndroid Build Coastguard Workerset_bmap $flag 26 $((start + 26))
45*6a54128fSAndroid Build Coastguard Workerset_bmap $flag 29 $((start + 29))
46*6a54128fSAndroid Build Coastguard Workerec
47*6a54128fSAndroid Build Coastguard Workersif /$name blocks 32
48*6a54128fSAndroid Build Coastguard Workersetb $((start + 10))
49*6a54128fSAndroid Build Coastguard Workersetb $((start + 13))
50*6a54128fSAndroid Build Coastguard Workersetb $((start + 26))
51*6a54128fSAndroid Build Coastguard Workersetb $((start + 29))
52*6a54128fSAndroid Build Coastguard WorkerENDL
53*6a54128fSAndroid Build Coastguard Worker}
54*6a54128fSAndroid Build Coastguard Worker
55*6a54128fSAndroid Build Coastguard Worker#Files we create:
56*6a54128fSAndroid Build Coastguard Worker# a: fallocate a 40k file
57*6a54128fSAndroid Build Coastguard Worker# b*: falloc sparse file starting at b*
58*6a54128fSAndroid Build Coastguard Worker# c*: falloc spare file ending at c*
59*6a54128fSAndroid Build Coastguard Worker# d: midcluster to midcluster, surrounding sparse
60*6a54128fSAndroid Build Coastguard Worker# e: partial middle cluster alloc
61*6a54128fSAndroid Build Coastguard Worker# f: one big file
62*6a54128fSAndroid Build Coastguard Worker# g*: falloc sparse init file starting at g*
63*6a54128fSAndroid Build Coastguard Worker# h*: falloc sparse init file ending at h*
64*6a54128fSAndroid Build Coastguard Worker# i: midcluster to midcluster, surrounding sparse init
65*6a54128fSAndroid Build Coastguard Worker# j: partial middle cluster alloc
66*6a54128fSAndroid Build Coastguard Worker# k: one big init file
67*6a54128fSAndroid Build Coastguard Workerbase=5000
68*6a54128fSAndroid Build Coastguard Workercat > $TMPFILE.cmd << ENDL
69*6a54128fSAndroid Build Coastguard Workerwrite /dev/null a
70*6a54128fSAndroid Build Coastguard Workersif /a size 40960
71*6a54128fSAndroid Build Coastguard Workerfallocate /a 0 39
72*6a54128fSAndroid Build Coastguard WorkerENDL
73*6a54128fSAndroid Build Coastguard Workerecho "ex /a" >> $TMPFILE.cmd2
74*6a54128fSAndroid Build Coastguard Worker
75*6a54128fSAndroid Build Coastguard Workermake_file sample $base --uninit >> $TMPFILE.cmd
76*6a54128fSAndroid Build Coastguard Workerecho "ex /sample" >> $TMPFILE.cmd2
77*6a54128fSAndroid Build Coastguard Workerbase=10000
78*6a54128fSAndroid Build Coastguard Worker
79*6a54128fSAndroid Build Coastguard Workerfor i in 8 9 10 11 12 13 14 15; do
80*6a54128fSAndroid Build Coastguard Worker	make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd
81*6a54128fSAndroid Build Coastguard Worker	echo "fallocate /b$i $i 39" >> $TMPFILE.cmd
82*6a54128fSAndroid Build Coastguard Worker	echo "ex /b$i" >> $TMPFILE.cmd2
83*6a54128fSAndroid Build Coastguard Workerdone
84*6a54128fSAndroid Build Coastguard Worker
85*6a54128fSAndroid Build Coastguard Workerfor i in 24 25 26 27 28 29 30 31; do
86*6a54128fSAndroid Build Coastguard Worker	make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd
87*6a54128fSAndroid Build Coastguard Worker	echo "fallocate /c$i 0 $i" >> $TMPFILE.cmd
88*6a54128fSAndroid Build Coastguard Worker	echo "ex /c$i" >> $TMPFILE.cmd2
89*6a54128fSAndroid Build Coastguard Workerdone
90*6a54128fSAndroid Build Coastguard Worker
91*6a54128fSAndroid Build Coastguard Workermake_file d $(($base + 640)) --uninit >> $TMPFILE.cmd
92*6a54128fSAndroid Build Coastguard Workerecho "fallocate /d 4 35" >> $TMPFILE.cmd
93*6a54128fSAndroid Build Coastguard Workerecho "ex /d" >> $TMPFILE.cmd2
94*6a54128fSAndroid Build Coastguard Worker
95*6a54128fSAndroid Build Coastguard Workermake_file e $(($base + 680)) --uninit >> $TMPFILE.cmd
96*6a54128fSAndroid Build Coastguard Workerecho "fallocate /e 19 20" >> $TMPFILE.cmd
97*6a54128fSAndroid Build Coastguard Workerecho "ex /e" >> $TMPFILE.cmd2
98*6a54128fSAndroid Build Coastguard Worker
99*6a54128fSAndroid Build Coastguard Workercat >> $TMPFILE.cmd << ENDL
100*6a54128fSAndroid Build Coastguard Workerwrite /dev/null f
101*6a54128fSAndroid Build Coastguard Workersif /f size 1024
102*6a54128fSAndroid Build Coastguard Workereo /f
103*6a54128fSAndroid Build Coastguard Workerset_bmap --uninit 0 9000
104*6a54128fSAndroid Build Coastguard Workerec
105*6a54128fSAndroid Build Coastguard Workersif /f blocks 16
106*6a54128fSAndroid Build Coastguard Workersetb 9000
107*6a54128fSAndroid Build Coastguard Workerfallocate /f 0 8999
108*6a54128fSAndroid Build Coastguard WorkerENDL
109*6a54128fSAndroid Build Coastguard Workerecho "ex /f" >> $TMPFILE.cmd2
110*6a54128fSAndroid Build Coastguard Worker
111*6a54128fSAndroid Build Coastguard Worker# Now do it again, but with initialized blocks
112*6a54128fSAndroid Build Coastguard Workerbase=20000
113*6a54128fSAndroid Build Coastguard Workerfor i in 8 9 10 11 12 13 14 15; do
114*6a54128fSAndroid Build Coastguard Worker	make_file g$i $(($base + (40 * ($i - 8)))) >> $TMPFILE.cmd
115*6a54128fSAndroid Build Coastguard Worker	echo "fallocate /g$i $i 39" >> $TMPFILE.cmd
116*6a54128fSAndroid Build Coastguard Worker	echo "ex /g$i" >> $TMPFILE.cmd2
117*6a54128fSAndroid Build Coastguard Workerdone
118*6a54128fSAndroid Build Coastguard Worker
119*6a54128fSAndroid Build Coastguard Workerfor i in 24 25 26 27 28 29 30 31; do
120*6a54128fSAndroid Build Coastguard Worker	make_file h$i $(($base + 320 + (40 * ($i - 24)))) >> $TMPFILE.cmd
121*6a54128fSAndroid Build Coastguard Worker	echo "fallocate /h$i 0 $i" >> $TMPFILE.cmd
122*6a54128fSAndroid Build Coastguard Worker	echo "ex /h$i" >> $TMPFILE.cmd2
123*6a54128fSAndroid Build Coastguard Workerdone
124*6a54128fSAndroid Build Coastguard Worker
125*6a54128fSAndroid Build Coastguard Workermake_file i $(($base + 640)) >> $TMPFILE.cmd
126*6a54128fSAndroid Build Coastguard Workerecho "fallocate /i 4 35" >> $TMPFILE.cmd
127*6a54128fSAndroid Build Coastguard Workerecho "ex /i" >> $TMPFILE.cmd2
128*6a54128fSAndroid Build Coastguard Worker
129*6a54128fSAndroid Build Coastguard Workermake_file j $(($base + 680)) >> $TMPFILE.cmd
130*6a54128fSAndroid Build Coastguard Workerecho "fallocate /j 19 20" >> $TMPFILE.cmd
131*6a54128fSAndroid Build Coastguard Workerecho "ex /j" >> $TMPFILE.cmd2
132*6a54128fSAndroid Build Coastguard Worker
133*6a54128fSAndroid Build Coastguard Workercat >> $TMPFILE.cmd << ENDL
134*6a54128fSAndroid Build Coastguard Workerwrite /dev/null k
135*6a54128fSAndroid Build Coastguard Workersif /k size 1024
136*6a54128fSAndroid Build Coastguard Workereo /k
137*6a54128fSAndroid Build Coastguard Workerset_bmap 0 19000
138*6a54128fSAndroid Build Coastguard Workerec
139*6a54128fSAndroid Build Coastguard Workersif /k blocks 16
140*6a54128fSAndroid Build Coastguard Workersetb 19000
141*6a54128fSAndroid Build Coastguard Workerfallocate /k 0 8999
142*6a54128fSAndroid Build Coastguard Workersif /k size 9216000
143*6a54128fSAndroid Build Coastguard WorkerENDL
144*6a54128fSAndroid Build Coastguard Workerecho "ex /k" >> $TMPFILE.cmd2
145*6a54128fSAndroid Build Coastguard Worker
146*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1
147*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1
148*6a54128fSAndroid Build Coastguard Worker
149*6a54128fSAndroid Build Coastguard Worker$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
150*6a54128fSAndroid Build Coastguard Workerstatus=$?
151*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new
152*6a54128fSAndroid Build Coastguard Worker
153*6a54128fSAndroid Build Coastguard Workersed -f $cmd_dir/filter.sed $OUT.new > $OUT
154*6a54128fSAndroid Build Coastguard Workerrm -f $TMPFILE $TMPFILE.cmd $TMPFILE.cmd2 $OUT.new
155*6a54128fSAndroid Build Coastguard Worker
156*6a54128fSAndroid Build Coastguard Workercmp -s $OUT $EXP
157*6a54128fSAndroid Build Coastguard Workerstatus=$?
158*6a54128fSAndroid Build Coastguard Worker
159*6a54128fSAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then
160*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: ok"
161*6a54128fSAndroid Build Coastguard Worker	touch $test_name.ok
162*6a54128fSAndroid Build Coastguard Workerelse
163*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: failed"
164*6a54128fSAndroid Build Coastguard Worker	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
165*6a54128fSAndroid Build Coastguard Workerfi
166*6a54128fSAndroid Build Coastguard Workerrm -f $EXP
167*6a54128fSAndroid Build Coastguard Worker
168*6a54128fSAndroid Build Coastguard Workerunset IMAGE FSCK_OPT OUT EXP
169