xref: /aosp_15_r20/external/e2fsprogs/tests/u_undo_undo/script (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Workertest_description="undo e2undo"
2*6a54128fSAndroid Build Coastguard Workerif test -x $E2UNDO_EXE; then
3*6a54128fSAndroid Build Coastguard Worker
4*6a54128fSAndroid Build Coastguard WorkerTDB_FILE=${TMPDIR:-/tmp}/e2fsck-$(basename $TMPFILE).e2undo
5*6a54128fSAndroid Build Coastguard WorkerTDB_FILE2=${TMPDIR:-/tmp}/e2undo-$(basename $TMPFILE).e2undo
6*6a54128fSAndroid Build Coastguard WorkerOUT=$test_name.log
7*6a54128fSAndroid Build Coastguard Workerrm -f $TDB_FILE $TDB_FILE2 >/dev/null 2>&1
8*6a54128fSAndroid Build Coastguard Worker
9*6a54128fSAndroid Build Coastguard Workerdd if=/dev/zero of=$TMPFILE bs=1k count=512 > /dev/null 2>&1
10*6a54128fSAndroid Build Coastguard Worker
11*6a54128fSAndroid Build Coastguard Workerecho mke2fs -q -F -o Linux -T ext4 -O ^metadata_csum,64bit -E lazy_itable_init=1 -b 1024 $TMPFILE  > $OUT
12*6a54128fSAndroid Build Coastguard Worker$MKE2FS -q -F -o Linux -T ext4 -O ^metadata_csum,64bit -E lazy_itable_init=1 -b 1024 $TMPFILE  >> $OUT 2>&1
13*6a54128fSAndroid Build Coastguard Workercrc0=`$CRCSUM $TMPFILE`
14*6a54128fSAndroid Build Coastguard Workerecho $CRCSUM before e2fsck $crc0 >> $OUT
15*6a54128fSAndroid Build Coastguard Worker
16*6a54128fSAndroid Build Coastguard Workerecho using e2fsck to test e2undo >> $OUT
17*6a54128fSAndroid Build Coastguard Worker$FSCK -f -y -D -z $TDB_FILE $TMPFILE >> $OUT 2>&1
18*6a54128fSAndroid Build Coastguard Workercrc1=`$CRCSUM $TMPFILE`
19*6a54128fSAndroid Build Coastguard Workerecho $CRCSUM after e2fsck $crc1 >> $OUT
20*6a54128fSAndroid Build Coastguard Worker
21*6a54128fSAndroid Build Coastguard Workerecho e2undo the e2fsck >> $OUT
22*6a54128fSAndroid Build Coastguard Worker$E2UNDO -z $TDB_FILE2 $TDB_FILE $TMPFILE  >> $OUT 2>&1
23*6a54128fSAndroid Build Coastguard Workercrc2=`$CRCSUM $TMPFILE`
24*6a54128fSAndroid Build Coastguard Workerecho $CRCSUM after e2undo $crc2 >> $OUT
25*6a54128fSAndroid Build Coastguard Worker
26*6a54128fSAndroid Build Coastguard Workerecho e2undo the e2undo >> $OUT
27*6a54128fSAndroid Build Coastguard Worker$E2UNDO $TDB_FILE2 $TMPFILE  >> $OUT 2>&1
28*6a54128fSAndroid Build Coastguard Workercrc3=`$CRCSUM $TMPFILE`
29*6a54128fSAndroid Build Coastguard Workerecho $CRCSUM after e2undo $crc3 >> $OUT
30*6a54128fSAndroid Build Coastguard Worker
31*6a54128fSAndroid Build Coastguard Workerecho e2undo the e2undo the e2undo >> $OUT
32*6a54128fSAndroid Build Coastguard Worker$E2UNDO $TDB_FILE $TMPFILE  >> $OUT 2>&1
33*6a54128fSAndroid Build Coastguard Workercrc4=`$CRCSUM $TMPFILE`
34*6a54128fSAndroid Build Coastguard Workerecho $CRCSUM after e2undo $crc4 >> $OUT
35*6a54128fSAndroid Build Coastguard Worker
36*6a54128fSAndroid Build Coastguard Worker$E2UNDO -h $TDB_FILE $TMPFILE >> $OUT 2>&1
37*6a54128fSAndroid Build Coastguard Worker$E2UNDO -h $TDB_FILE2 $TMPFILE >> $OUT 2>&1
38*6a54128fSAndroid Build Coastguard Worker
39*6a54128fSAndroid Build Coastguard Worker$E2UNDO -z $TDB_FILE2 $TDB_FILE2 $TMPFILE >> $OUT 2>&1
40*6a54128fSAndroid Build Coastguard Worker
41*6a54128fSAndroid Build Coastguard Workercrc5=`$CRCSUM $TMPFILE`
42*6a54128fSAndroid Build Coastguard Workerecho $CRCSUM after failed e2undo $crc5 >> $OUT
43*6a54128fSAndroid Build Coastguard Worker
44*6a54128fSAndroid Build Coastguard Workerecho $crc0 $crc1 $crc2 $crc3 $crc4 $crc5 >> $OUT
45*6a54128fSAndroid Build Coastguard Worker
46*6a54128fSAndroid Build Coastguard Workerif [ $crc0 = $crc2 ] && [ $crc2 = $crc4 ] && [ $crc5 = $crc4 ] && [ $crc1 = $crc3 ] && [ $crc1 != $crc2 ]; then
47*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: ok"
48*6a54128fSAndroid Build Coastguard Worker	touch $test_name.ok
49*6a54128fSAndroid Build Coastguard Workerelse
50*6a54128fSAndroid Build Coastguard Worker	ln -f $test_name.log $test_name.failed
51*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: failed"
52*6a54128fSAndroid Build Coastguard Workerfi
53*6a54128fSAndroid Build Coastguard Workerrm -f $TDB_FILE $TDB_FILE2 $TMPFILE
54*6a54128fSAndroid Build Coastguard Workerfi
55