resize_test revision e79a9395b382e831c125d000d2bf16ba4b6253d4
16645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org#!/bin/sh
26645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
36645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgresize_test () {
46645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
56645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgrm -f $TMPFILE
66645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgtouch $TMPFILE
76645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 > $LOG
86645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org$MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG
96645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
106645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgOUT_TMP=$(mktemp -t csum-tmp.XXXXXX)
116645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
126645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgdate > $OUT_TMP
136645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgcat $E2FSCK >> $OUT_TMP
146645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $CRCSUM $OUT_TMP >> $LOG 2>&1
156645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgCSUM_1=$($CRCSUM $OUT_TMP)
166645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho Checksum is $CSUM_1 >> $LOG
176645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
186645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho Setting up file system >> $LOG
196645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org$DEBUGFS -w $TMPFILE  >> $LOG 2>&1 << EOF
206645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgmkdir test
216645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgcd test
226645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgwrite $OUT_TMP e2fsck
236645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgls /test
246645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgstat /test/e2fsck
256645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgquit
266645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgEOF
276645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho " " >> $LOG
286645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
296645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgrm -f $OUT_TMP
306645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
316645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $FSCK -fy $TMPFILE >> $LOG 2>&1 
326645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org$FSCK -fy $TMPFILE >> $LOG 2>&1 
336645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
346645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $RESIZE2FS $RESIZE2FS_OPTS -d 31 $TMPFILE $SIZE_2 >> $LOG 2>&1
356645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 $TMPFILE $SIZE_2 >> $LOG 2>&1
366645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
376645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
386645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
396645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
406645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $FSCK -fp $TMPFILE >> $LOG 2>&1 
416645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif ! $FSCK -fp $TMPFILE >> $LOG 2>&1
426645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
436645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	dumpe2fs $TMPFILE >> $LOG
446645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
456645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
466645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
476645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
486645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
496645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
506645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $CRCSUM $OUT_TMP >> $LOG 2>&1
516645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgCSUM_2=$($CRCSUM $OUT_TMP)
526645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho Checksum is $CSUM_2 >> $LOG
536645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
546645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif test "$CSUM_1" != "$CSUM_2"
556645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
566645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
576645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
586645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
596645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
606645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
616645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
626645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
636645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
646645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
656645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $FSCK -fp $TMPFILE >> $LOG 2>&1 
666645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif ! $FSCK -fp $TMPFILE >> $LOG 2>&1
676645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
686645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	dumpe2fs $TMPFILE >> $LOG
696645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
706645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
716645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
726645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
736645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
746645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
756645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $CRCSUM $OUT_TMP >> $LOG 2>&1
766645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgCSUM_2=$($CRCSUM $OUT_TMP)
776645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho Checksum is $CSUM_2 >> $LOG
786645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
796645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif test "$CSUM_1" != "$CSUM_2"
806645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
816645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
826645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
836645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
846645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
856645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
866645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
876645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
886645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
896645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
906645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $FSCK -fp $TMPFILE >> $LOG 2>&1 
916645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif ! $FSCK -fp $TMPFILE >> $LOG 2>&1
926645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
936645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	dumpe2fs $TMPFILE >> $LOG
946645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
956645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
966645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
976645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
986645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
996645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1006645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $CRCSUM $OUT_TMP >> $LOG 2>&1
1016645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgCSUM_2=$($CRCSUM $OUT_TMP)
1026645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho Checksum is $CSUM_2 >> $LOG
1036645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1046645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif test "$CSUM_1" != "$CSUM_2"
1056645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
1066645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
1076645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
1086645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1096645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
1106645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1
1116645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
1126645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
1136645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
1146645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1156645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $FSCK -fp $TMPFILE >> $LOG 2>&1 
1166645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif ! $FSCK -fp $TMPFILE >> $LOG 2>&1
1176645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
1186645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	dumpe2fs $TMPFILE >> $LOG
1196645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
1206645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
1216645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1226645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
1236645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1
1246645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1256645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho $CRCSUM $OUT_TMP >> $LOG 2>&1
1266645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgCSUM_2=$($CRCSUM $OUT_TMP)
1276645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgecho Checksum is $CSUM_2 >> $LOG
1286645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1296645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgrm $OUT_TMP
1306645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgunset OUT_TMP
1316645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1326645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgif test "$CSUM_1" != "$CSUM_2"
1336645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgthen
1346645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org	return 1
1356645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgfi
1366645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1376645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgreturn 0
1386645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1396645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org}
1406645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org