diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:29:32 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:29:32 -0800 |
commit | 2068259fff846977bdd4262fa27ea6cb81d35a78 (patch) | |
tree | d4c35114dd30b1fbf3e91f785f63023f97438147 /test-mount.sh | |
parent | ee88353f0c125cdc2ee7a56187fde3a10e4ff918 (diff) | |
download | genext2fs-2068259fff846977bdd4262fa27ea6cb81d35a78.tar.gz |
auto import from //depot/cupcake/@135843android-sdk-tools_r2android-sdk-1.6_r2android-sdk-1.6_r1android-sdk-1.6-docs_r1android-sdk-1.5_r3android-sdk-1.5_r1android-sdk-1.5-preandroid-1.6_r2android-1.6_r1.5android-1.6_r1.4android-1.6_r1.3android-1.6_r1.2android-1.6_r1.1android-1.6_r1android-1.5r4android-1.5r3android-1.5r2android-1.5donut-release2donut-releasedonutcupcake-releasecupcake
Diffstat (limited to 'test-mount.sh')
-rwxr-xr-x | test-mount.sh | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/test-mount.sh b/test-mount.sh new file mode 100755 index 0000000..cd07edc --- /dev/null +++ b/test-mount.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +# Use this script if you need to regenerate the digest values +# in test.sh, or if you don't care about digests and you just +# want to see some fsck results. Should be run as root. + +set -e + +. ./test-gen.lib + +test_cleanup () { + umount mnt 2>/dev/null || true + rm -rf mnt fout lsout +} + +fail () { + echo FAILED + test_cleanup + gen_cleanup + exit 1 +} + +pass () { + md5=`calc_digest` + echo PASSED + echo $@ $md5 + test_cleanup + gen_cleanup +} + +# dtest-mount - Exercise the -d directory option of genext2fs +# Creates an image with a file of given size, verifies it +# and returns the command line with which to invoke dtest() +# Usage: dtest-mount file-size number-of-blocks +dtest_mount () { + size=$1; blocks=$2 + echo Testing with file of size $size + dgen $size $blocks + /sbin/e2fsck -fn ext2.img || fail + mkdir -p mnt + mount -t ext2 -o ro,loop ext2.img mnt || fail + if (! [ -f mnt/file.$size ]) || \ + [ $size != "`ls -al mnt | grep file.$size | + awk '{print $5}'`" ] ; then + fail + fi + pass dtest $size $blocks +} + +# ftest-mount - Exercise the -f spec-file option of genext2fs +# Creates an image with the devices mentioned in the given spec +# file, verifies it, and returns the command line with which to +# invoke ftest() +# Usage: ftest-mount spec-file number-of-blocks +ftest_mount () { + fname=$1; blocks=$2 + echo Testing with devices file $fname + fgen $fname $blocks + /sbin/e2fsck -fn ext2.img || fail + mkdir -p mnt + mount -t ext2 -o ro,loop ext2.img mnt || fail + [ -d mnt/dev ] || fail + # Exclude those devices that have interpolated + # minor numbers, as being too hard to match. + egrep -v "(hda|hdb|tty|loop|ram|ubda)" $fname | \ + grep '^[^ #]* [bc]' | \ + awk '{print $1,$4,$5,$6","$7}'| \ + sort -d -k3.6 > fout + ls -aln mnt/dev | \ + egrep -v "(hda|hdb|tty|loop|ram|ubda)" | \ + grep ^[bc] | \ + awk '{ print "/dev/"$10,$3,$4,$5$6}' | \ + sort -d -k3.6 > lsout + diff fout lsout || fail + pass ftest $fname $blocks +} + +dtest_mount 0 4096 +dtest_mount 0 8193 +dtest_mount 0 8194 +dtest_mount 1 4096 +dtest_mount 12288 4096 +dtest_mount 274432 4096 +dtest_mount 8388608 9000 +dtest_mount 16777216 20000 + +ftest_mount device_table.txt 4096 |