xref: /aosp_15_r20/external/e2fsprogs/tests/f_readonly_fsck/script (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard WorkerFSCK_OPT=-fn
2*6a54128fSAndroid Build Coastguard WorkerOUT=$test_name.log
3*6a54128fSAndroid Build Coastguard Workerif [ -f $test_dir/expect.gz ]; then
4*6a54128fSAndroid Build Coastguard Worker	EXP=$test_name.tmp
5*6a54128fSAndroid Build Coastguard Worker	gunzip < $test_dir/expect.gz > $EXP1
6*6a54128fSAndroid Build Coastguard Workerelse
7*6a54128fSAndroid Build Coastguard Worker	EXP=$test_dir/expect
8*6a54128fSAndroid Build Coastguard Workerfi
9*6a54128fSAndroid Build Coastguard Worker
10*6a54128fSAndroid Build Coastguard Workerdd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
11*6a54128fSAndroid Build Coastguard Worker
12*6a54128fSAndroid Build Coastguard Workergzip -d < $test_dir/image.gz > $TMPFILE
13*6a54128fSAndroid Build Coastguard Worker
14*6a54128fSAndroid Build Coastguard Workerold="$($CRCSUM < $TMPFILE)"
15*6a54128fSAndroid Build Coastguard Worker
16*6a54128fSAndroid Build Coastguard Worker$FSCK $FSCK_OPT -N test_filesys $TMPFILE > $OUT.new 2>&1
17*6a54128fSAndroid Build Coastguard Workerstatus=$?
18*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new
19*6a54128fSAndroid Build Coastguard Worker
20*6a54128fSAndroid Build Coastguard Workernew="$($CRCSUM < $TMPFILE)"
21*6a54128fSAndroid Build Coastguard Worker
22*6a54128fSAndroid Build Coastguard Workerif [ "${old}" != "${new}" ]; then
23*6a54128fSAndroid Build Coastguard Worker	echo "ERROR: crc mismatch!  ${old} ${new}" >> $OUT.new
24*6a54128fSAndroid Build Coastguard Workerelse
25*6a54128fSAndroid Build Coastguard Worker	echo "crc did not change.  ${old}" >> $OUT.new
26*6a54128fSAndroid Build Coastguard Workerfi
27*6a54128fSAndroid Build Coastguard Worker
28*6a54128fSAndroid Build Coastguard Workersed -f $cmd_dir/filter.sed $OUT.new > $OUT
29*6a54128fSAndroid Build Coastguard Workerrm -f $TMPFILE $OUT.new
30*6a54128fSAndroid Build Coastguard Worker
31*6a54128fSAndroid Build Coastguard Workercmp -s $OUT $EXP
32*6a54128fSAndroid Build Coastguard Workerstatus=$?
33*6a54128fSAndroid Build Coastguard Worker
34*6a54128fSAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then
35*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: ok"
36*6a54128fSAndroid Build Coastguard Worker	touch $test_name.ok
37*6a54128fSAndroid Build Coastguard Workerelse
38*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: failed"
39*6a54128fSAndroid Build Coastguard Worker	diff $DIFF_OPTS $EXP $OUT > $test_name.failed
40*6a54128fSAndroid Build Coastguard Worker	rm -f $test_name.tmp
41*6a54128fSAndroid Build Coastguard Workerfi
42*6a54128fSAndroid Build Coastguard Worker
43*6a54128fSAndroid Build Coastguard Workerunset IMAGE FSCK_OPT OUT EXP old new
44