xref: /aosp_15_r20/external/e2fsprogs/tests/f_itable_collision/script (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker#!/bin/bash
2*6a54128fSAndroid Build Coastguard Worker
3*6a54128fSAndroid Build Coastguard Worker# Run this test with a specific time, because we're crosslinking an extent tree
4*6a54128fSAndroid Build Coastguard Worker# block with the inode table.  When fsck sets dtime to now, we want "now" to be
5*6a54128fSAndroid Build Coastguard Worker# our preprogrammed value.
6*6a54128fSAndroid Build Coastguard Worker
7*6a54128fSAndroid Build Coastguard WorkerFSCK_OPT=-fy
8*6a54128fSAndroid Build Coastguard WorkerIMAGE=$test_dir/image.gz
9*6a54128fSAndroid Build Coastguard WorkerE2FSCK_TIME=4294967294
10*6a54128fSAndroid Build Coastguard Workerexport E2FSCK_TIME
11*6a54128fSAndroid Build Coastguard Worker
12*6a54128fSAndroid Build Coastguard Workergzip -d < $IMAGE > $TMPFILE
13*6a54128fSAndroid Build Coastguard Worker
14*6a54128fSAndroid Build Coastguard Worker# Run fsck to fix things?
15*6a54128fSAndroid Build Coastguard WorkerEXP1=$test_dir/expect.1
16*6a54128fSAndroid Build Coastguard WorkerOUT1=$test_name.1.log
17*6a54128fSAndroid Build Coastguard Worker
18*6a54128fSAndroid Build Coastguard Worker$FSCK $FSCK_OPT -N test_filesys $TMPFILE 2>&1 | tail -n +2 > $OUT1
19*6a54128fSAndroid Build Coastguard Workerecho "Exit status is $?" >> $OUT1
20*6a54128fSAndroid Build Coastguard Worker
21*6a54128fSAndroid Build Coastguard Worker# Run a second time
22*6a54128fSAndroid Build Coastguard WorkerEXP2=$test_dir/expect.2
23*6a54128fSAndroid Build Coastguard WorkerOUT2=$test_name.2.log
24*6a54128fSAndroid Build Coastguard Worker
25*6a54128fSAndroid Build Coastguard Worker$FSCK $FSCK_OPT -N test_filesys $TMPFILE 2>&1 | tail -n +2 > $OUT2
26*6a54128fSAndroid Build Coastguard Workerecho "Exit status is $?" >> $OUT2
27*6a54128fSAndroid Build Coastguard Worker
28*6a54128fSAndroid Build Coastguard Worker# Figure out what happened
29*6a54128fSAndroid Build Coastguard Workerif cmp -s $EXP1 $OUT1 && cmp -s $EXP2 $OUT2; then
30*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: ok"
31*6a54128fSAndroid Build Coastguard Worker	touch $test_name.ok
32*6a54128fSAndroid Build Coastguard Workerelse
33*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: failed"
34*6a54128fSAndroid Build Coastguard Worker	diff -u $EXP1 $OUT1 >> $test_name.failed
35*6a54128fSAndroid Build Coastguard Worker	diff -u $EXP2 $OUT2 >> $test_name.failed
36*6a54128fSAndroid Build Coastguard Workerfi
37