xref: /aosp_15_r20/external/e2fsprogs/tests/m_offset/script (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Workertest_description="mke2fs with offset option (-E offset=N)"
2*6a54128fSAndroid Build Coastguard WorkerOUT="$test_name.log"
3*6a54128fSAndroid Build Coastguard Worker
4*6a54128fSAndroid Build Coastguard Workerecho "testing mke2fs with -E offset=524288 option (no fssize)" > "$OUT"
5*6a54128fSAndroid Build Coastguard Workeryes a | $DD of="$TMPFILE" bs=1k count=2048 iflag=fullblock 2>>"$OUT"
6*6a54128fSAndroid Build Coastguard Worker$MKE2FS -F -b 1024 -E offset=524288 "$TMPFILE" >> "$OUT" 2>&1
7*6a54128fSAndroid Build Coastguard Worker# compute crc of the first 512 1k blocks
8*6a54128fSAndroid Build Coastguard Workercrc_first1=`$DD if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM`
9*6a54128fSAndroid Build Coastguard Worker
10*6a54128fSAndroid Build Coastguard Workerecho "testing mke2fs with -E offset=524288 option (explicit fssize)" >> "$OUT"
11*6a54128fSAndroid Build Coastguard Workeryes a | $DD of="$TMPFILE" bs=1k count=2048 iflag=fullblock 2>>"$OUT"
12*6a54128fSAndroid Build Coastguard Worker$MKE2FS -F -b 1024 -E offset=524288 "$TMPFILE" 1024 >> "$OUT" 2>&1
13*6a54128fSAndroid Build Coastguard Worker# compute crc of the first and last 512 1k blocks
14*6a54128fSAndroid Build Coastguard Workercrc_first2=`$DD if="$TMPFILE" bs=1k count=512 2>/dev/null | $CRCSUM`
15*6a54128fSAndroid Build Coastguard Workercrc_last2=`$DD if="$TMPFILE" bs=1k count=512 skip=1536 2>/dev/null | $CRCSUM`
16*6a54128fSAndroid Build Coastguard Workercrc_exp=`yes a | $DD bs=1k count=512 2>/dev/null | $CRCSUM`
17*6a54128fSAndroid Build Coastguard Worker# a warning should be only emitted by the first mke2fs call
18*6a54128fSAndroid Build Coastguard Workerwarning=`grep -c "offset specified without an explicit file system size." \
19*6a54128fSAndroid Build Coastguard Worker	"$OUT"`
20*6a54128fSAndroid Build Coastguard Worker
21*6a54128fSAndroid Build Coastguard Workerif [ "$warning" -eq 1 -a \
22*6a54128fSAndroid Build Coastguard Worker	 "$crc_first1" = "$crc_first2" -a \
23*6a54128fSAndroid Build Coastguard Worker	 "$crc_first2" = "$crc_last2" -a \
24*6a54128fSAndroid Build Coastguard Worker	 "$crc_first2" = "$crc_exp" ]; then
25*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: ok"
26*6a54128fSAndroid Build Coastguard Worker	touch "$test_name.ok"
27*6a54128fSAndroid Build Coastguard Workerelse
28*6a54128fSAndroid Build Coastguard Worker	echo "$test_name: $test_description: failed"
29*6a54128fSAndroid Build Coastguard Worker	echo "warning: $warning" > "$test_name.failed"
30*6a54128fSAndroid Build Coastguard Worker	echo "crc_first1: $crc_first1" >> "$test_name.failed"
31*6a54128fSAndroid Build Coastguard Worker	echo "crc_first2: $crc_first2" >> "$test_name.failed"
32*6a54128fSAndroid Build Coastguard Worker	echo "crc_last2: $crc_last2" >> "$test_name.failed"
33*6a54128fSAndroid Build Coastguard Worker	echo "crc_exp: $crc_exp" >> "$test_name.failed"
34*6a54128fSAndroid Build Coastguard Workerfi
35