xref: /aosp_15_r20/external/e2fsprogs/tests/d_punch_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 > $EXP1
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 Workerfallocate /$name 0 39
41*6a54128fSAndroid Build Coastguard Workerpunch /$name 10 10
42*6a54128fSAndroid Build Coastguard Workerpunch /$name 13 13
43*6a54128fSAndroid Build Coastguard Workerpunch /$name 26 26
44*6a54128fSAndroid Build Coastguard Workerpunch /$name 29 29
45*6a54128fSAndroid Build Coastguard WorkerENDL
46*6a54128fSAndroid Build Coastguard Worker}
47*6a54128fSAndroid Build Coastguard Worker
48*6a54128fSAndroid Build Coastguard Worker#Files we create:
49*6a54128fSAndroid Build Coastguard Worker# a: punch a 40k file
50*6a54128fSAndroid Build Coastguard Worker# b*: punch sparse file starting at b*
51*6a54128fSAndroid Build Coastguard Worker# c*: punch spare file ending at c*
52*6a54128fSAndroid Build Coastguard Worker# d: midcluster to midcluster, surrounding sparse
53*6a54128fSAndroid Build Coastguard Worker# e: partial middle cluster alloc
54*6a54128fSAndroid Build Coastguard Worker# f: one big file
55*6a54128fSAndroid Build Coastguard Workerbase=5000
56*6a54128fSAndroid Build Coastguard Workercat > $TMPFILE.cmd << ENDL
57*6a54128fSAndroid Build Coastguard Workerwrite /dev/null a
58*6a54128fSAndroid Build Coastguard Workerfallocate /a 0 39
59*6a54128fSAndroid Build Coastguard Workerpunch /a 0 39
60*6a54128fSAndroid Build Coastguard WorkerENDL
61*6a54128fSAndroid Build Coastguard Workerecho "ex /a" >> $TMPFILE.cmd2
62*6a54128fSAndroid Build Coastguard Worker
63*6a54128fSAndroid Build Coastguard Workermake_file sample $base --uninit >> $TMPFILE.cmd
64*6a54128fSAndroid Build Coastguard Workerecho "ex /sample" >> $TMPFILE.cmd2
65*6a54128fSAndroid Build Coastguard Workerbase=10000
66*6a54128fSAndroid Build Coastguard Worker
67*6a54128fSAndroid Build Coastguard Workerfor i in 8 9 10 11 12 13 14 15; do
68*6a54128fSAndroid Build Coastguard Worker	make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd
69*6a54128fSAndroid Build Coastguard Worker	echo "punch /b$i $i 39" >> $TMPFILE.cmd
70*6a54128fSAndroid Build Coastguard Worker	echo "ex /b$i" >> $TMPFILE.cmd2
71*6a54128fSAndroid Build Coastguard Workerdone
72*6a54128fSAndroid Build Coastguard Worker
73*6a54128fSAndroid Build Coastguard Workerfor i in 24 25 26 27 28 29 30 31; do
74*6a54128fSAndroid Build Coastguard Worker	make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd
75*6a54128fSAndroid Build Coastguard Worker	echo "punch /c$i 0 $i" >> $TMPFILE.cmd
76*6a54128fSAndroid Build Coastguard Worker	echo "ex /c$i" >> $TMPFILE.cmd2
77*6a54128fSAndroid Build Coastguard Workerdone
78*6a54128fSAndroid Build Coastguard Worker
79*6a54128fSAndroid Build Coastguard Workermake_file d $(($base + 640)) --uninit >> $TMPFILE.cmd
80*6a54128fSAndroid Build Coastguard Workerecho "punch /d 4 35" >> $TMPFILE.cmd
81*6a54128fSAndroid Build Coastguard Workerecho "ex /d" >> $TMPFILE.cmd2
82*6a54128fSAndroid Build Coastguard Worker
83*6a54128fSAndroid Build Coastguard Workermake_file e $(($base + 680)) --uninit >> $TMPFILE.cmd
84*6a54128fSAndroid Build Coastguard Workerecho "punch /e 19 20" >> $TMPFILE.cmd
85*6a54128fSAndroid Build Coastguard Workerecho "ex /e" >> $TMPFILE.cmd2
86*6a54128fSAndroid Build Coastguard Worker
87*6a54128fSAndroid Build Coastguard Workercat >> $TMPFILE.cmd << ENDL
88*6a54128fSAndroid Build Coastguard Workerwrite /dev/null f
89*6a54128fSAndroid Build Coastguard Workersif /f size 1024
90*6a54128fSAndroid Build Coastguard Workereo /f
91*6a54128fSAndroid Build Coastguard Workerset_bmap --uninit 0 9000
92*6a54128fSAndroid Build Coastguard Workerec
93*6a54128fSAndroid Build Coastguard Workersif /f blocks 16
94*6a54128fSAndroid Build Coastguard Workersetb 9000
95*6a54128fSAndroid Build Coastguard Workerfallocate /f 0 8999
96*6a54128fSAndroid Build Coastguard Workerpunch /f 1 8998
97*6a54128fSAndroid Build Coastguard WorkerENDL
98*6a54128fSAndroid Build Coastguard Workerecho "ex /f" >> $TMPFILE.cmd2
99*6a54128fSAndroid Build Coastguard Worker
100*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1
101*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1
102*6a54128fSAndroid Build Coastguard Worker
103*6a54128fSAndroid Build Coastguard Worker$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1
104*6a54128fSAndroid Build Coastguard Workerstatus=$?
105*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new
106*6a54128fSAndroid Build Coastguard Workersed -f $cmd_dir/filter.sed $OUT.new > $OUT
107*6a54128fSAndroid Build Coastguard Workerrm -f $TMPFILE $TMPFILE.cmd $TMPFILE.cmd2 $OUT.new
108*6a54128fSAndroid Build Coastguard Worker
109*6a54128fSAndroid Build Coastguard Workercmp -s $OUT $EXP
110*6a54128fSAndroid Build Coastguard Workerstatus=$?
111*6a54128fSAndroid Build Coastguard Worker
112*6a54128fSAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then
113*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: ok"
114*6a54128fSAndroid Build Coastguard Worker	touch $test_name.ok
115*6a54128fSAndroid Build Coastguard Workerelse
116*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: failed"
117*6a54128fSAndroid Build Coastguard Worker	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
118*6a54128fSAndroid Build Coastguard Worker	rm -f $test_name.tmp
119*6a54128fSAndroid Build Coastguard Workerfi
120*6a54128fSAndroid Build Coastguard Worker
121*6a54128fSAndroid Build Coastguard Workerunset IMAGE FSCK_OPT OUT EXP
122