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