1*6a54128fSAndroid Build Coastguard Workertest_description="create fs image from dir, then minimize it" 2*6a54128fSAndroid Build Coastguard Workerif ! test -x $RESIZE2FS_EXE -o ! -x $DEBUGFS_EXE; then 3*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: skipped (no debugfs/resize2fs)" 4*6a54128fSAndroid Build Coastguard Worker return 0 5*6a54128fSAndroid Build Coastguard Workerfi 6*6a54128fSAndroid Build Coastguard Worker 7*6a54128fSAndroid Build Coastguard WorkerMKFS_DIR=$TMPFILE.dir 8*6a54128fSAndroid Build Coastguard WorkerOUT=$test_name.log 9*6a54128fSAndroid Build Coastguard WorkerEXP=$test_dir/expect 10*6a54128fSAndroid Build Coastguard Worker 11*6a54128fSAndroid Build Coastguard Workerrm -rf $MKFS_DIR 12*6a54128fSAndroid Build Coastguard Workermkdir -p $MKFS_DIR 13*6a54128fSAndroid Build Coastguard Workermkdir $MKFS_DIR/dir 14*6a54128fSAndroid Build Coastguard Workermkdir $MKFS_DIR/emptydir 15*6a54128fSAndroid Build Coastguard Workerdd if=/dev/zero of=$MKFS_DIR/bigzerofile bs=1 count=1 seek=1073741824 2> /dev/null 16*6a54128fSAndroid Build Coastguard Workerecho "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1024 2> /dev/null 17*6a54128fSAndroid Build Coastguard Workerecho "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=524288 conv=notrunc 2> /dev/null 18*6a54128fSAndroid Build Coastguard Workerecho "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1048576 conv=notrunc 2> /dev/null 19*6a54128fSAndroid Build Coastguard Workerecho "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=536870912 conv=notrunc 2> /dev/null 20*6a54128fSAndroid Build Coastguard Workerecho "M" | dd of=$MKFS_DIR/sparsefile bs=1 count=1 seek=1073741824 conv=notrunc 2> /dev/null 21*6a54128fSAndroid Build Coastguard Workerdd if=/dev/zero bs=1024 count=32 2> /dev/null | tr '\0' 'a' > $MKFS_DIR/bigfile 22*6a54128fSAndroid Build Coastguard Workertouch $MKFS_DIR/emptyfile 23*6a54128fSAndroid Build Coastguard Workerecho "Test me" > $MKFS_DIR/dir/file 24*6a54128fSAndroid Build Coastguard Worker 25*6a54128fSAndroid Build Coastguard Workerecho "create fs" > $OUT 26*6a54128fSAndroid Build Coastguard Worker$MKE2FS -q -F -o Linux -T ext4 -O ^has_journal,metadata_csum,64bit,^resize_inode -E lazy_itable_init=1 -b 1024 -d $MKFS_DIR $TMPFILE 16384 >> $OUT 2>&1 27*6a54128fSAndroid Build Coastguard Worker 28*6a54128fSAndroid Build Coastguard Worker$DUMPE2FS $TMPFILE >> $OUT 2>&1 29*6a54128fSAndroid Build Coastguard Workercat > $TMPFILE.cmd << ENDL 30*6a54128fSAndroid Build Coastguard Workerstat /emptyfile 31*6a54128fSAndroid Build Coastguard Workerstat /bigfile 32*6a54128fSAndroid Build Coastguard Workerstat /sparsefile 33*6a54128fSAndroid Build Coastguard Workerstat /bigzerofile 34*6a54128fSAndroid Build Coastguard Workerstat /fifo 35*6a54128fSAndroid Build Coastguard Workerstat /emptydir 36*6a54128fSAndroid Build Coastguard Workerstat /dir 37*6a54128fSAndroid Build Coastguard Workerstat /dir/file 38*6a54128fSAndroid Build Coastguard WorkerENDL 39*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -f $TMPFILE.cmd $TMPFILE 2>&1 | egrep "(stat|Size:|Type:)" >> $OUT 40*6a54128fSAndroid Build Coastguard Worker 41*6a54128fSAndroid Build Coastguard Workercat > $TMPFILE.cmd << ENDL 42*6a54128fSAndroid Build Coastguard Workerex /emptyfile 43*6a54128fSAndroid Build Coastguard Workerex /bigfile 44*6a54128fSAndroid Build Coastguard Workerex /sparsefile 45*6a54128fSAndroid Build Coastguard Workerex /bigzerofile 46*6a54128fSAndroid Build Coastguard Workerex /dir 47*6a54128fSAndroid Build Coastguard Workerex /dir/file 48*6a54128fSAndroid Build Coastguard WorkerENDL 49*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -f $TMPFILE.cmd $TMPFILE >> $OUT 2>&1 50*6a54128fSAndroid Build Coastguard Worker$FSCK -f -n $TMPFILE >> $OUT 2>&1 51*6a54128fSAndroid Build Coastguard Worker 52*6a54128fSAndroid Build Coastguard Workerecho "minify fs" >> $OUT 53*6a54128fSAndroid Build Coastguard Worker$TUNE2FS -m 0 $TMPFILE >> $OUT 2>&1 54*6a54128fSAndroid Build Coastguard Worker$RESIZE2FS -M $TMPFILE >> $OUT 2>&1 55*6a54128fSAndroid Build Coastguard Worker$DUMPE2FS $TMPFILE >> $OUT 2>&1 56*6a54128fSAndroid Build Coastguard Worker$FSCK -f -n $TMPFILE >> $OUT 2>&1 57*6a54128fSAndroid Build Coastguard Worker 58*6a54128fSAndroid Build Coastguard Workerecho "minify fs (2)" >> $OUT 59*6a54128fSAndroid Build Coastguard Worker$TUNE2FS -m 0 $TMPFILE >> $OUT 2>&1 60*6a54128fSAndroid Build Coastguard Worker$RESIZE2FS -M $TMPFILE >> $OUT 2>&1 61*6a54128fSAndroid Build Coastguard Worker$DUMPE2FS $TMPFILE >> $OUT 2>&1 62*6a54128fSAndroid Build Coastguard Worker$FSCK -f -n $TMPFILE >> $OUT 2>&1 63*6a54128fSAndroid Build Coastguard Worker 64*6a54128fSAndroid Build Coastguard Workersed -f $cmd_dir/filter.sed -f $test_dir/output.sed -e "s;$TMPFILE;test.img;" < $OUT > $OUT.tmp 65*6a54128fSAndroid Build Coastguard Workermv $OUT.tmp $OUT 66*6a54128fSAndroid Build Coastguard Worker 67*6a54128fSAndroid Build Coastguard Worker# Do the verification 68*6a54128fSAndroid Build Coastguard Workercmp -s $OUT $EXP 69*6a54128fSAndroid Build Coastguard Workerstatus=$? 70*6a54128fSAndroid Build Coastguard Worker 71*6a54128fSAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then 72*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: ok" 73*6a54128fSAndroid Build Coastguard Worker touch $test_name.ok 74*6a54128fSAndroid Build Coastguard Workerelse 75*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: failed" 76*6a54128fSAndroid Build Coastguard Worker diff $DIFF_OPTS $EXP $OUT > $test_name.failed 77*6a54128fSAndroid Build Coastguard Workerfi 78*6a54128fSAndroid Build Coastguard Worker 79*6a54128fSAndroid Build Coastguard Workerrm -rf $TMPFILE.cmd $MKFS_DIR 80*6a54128fSAndroid Build Coastguard Workerunset MKFS_DIR OUT EXP 81