aboutsummaryrefslogtreecommitdiff
path: root/test-gen.lib
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:29:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:29:32 -0800
commit2068259fff846977bdd4262fa27ea6cb81d35a78 (patch)
treed4c35114dd30b1fbf3e91f785f63023f97438147 /test-gen.lib
parentee88353f0c125cdc2ee7a56187fde3a10e4ff918 (diff)
downloadgenext2fs-2068259fff846977bdd4262fa27ea6cb81d35a78.tar.gz
Diffstat (limited to 'test-gen.lib')
-rw-r--r--test-gen.lib56
1 files changed, 56 insertions, 0 deletions
diff --git a/test-gen.lib b/test-gen.lib
new file mode 100644
index 0000000..c6e73b9
--- /dev/null
+++ b/test-gen.lib
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# These routines contain the filesystem generation code.
+# This code is sourced by the other scripts so that digest
+# generation is consistent.
+
+# dgen - Exercises the -d directory option of genext2fs
+# Creates an image with a file of given size
+# Usage: dgen file-size number-of-blocks
+dgen () {
+ size=$1; blocks=$2
+ rm -rf test
+ mkdir -p test
+ cd test
+ if [ x$size = x0 ]; then
+ > file.$1
+ else
+ dd if=/dev/zero of=file.$1 bs=$size count=1 2>/dev/null
+ fi
+ chmod 777 file.$1
+ TZ=UTC-11 touch -t 200502070321.43 file.$1 .
+ cd ..
+ ./genext2fs -N 17 -b $blocks -d test -f -q ext2.img
+}
+
+# fgen - Exercises the -f spec-file option of genext2fs
+# Creates an image with the devices mentioned in the given spec file
+# Usage: fgen spec-file number-of-blocks
+fgen () {
+ fname=$1; blocks=$2;
+ mkdir -p test
+ cp $fname test
+ TZ=UTC-11 touch -t 200502070321.43 test/$fname
+ ./genext2fs -N 92 -b $blocks -D test/$fname -f ext2.img
+}
+
+# gen_cleanup - Remove the files generated by the above functions
+# Usage: gen_cleanup
+gen_cleanup () {
+ rm -rf ext2.img test
+}
+
+# calc_digest - Return the MD5 digest of the test image
+# Usage: calc_digest
+calc_digest () {
+ digest=`md5sum ext2.img 2>/dev/null | cut -f 1 -d " "`
+ if [ x$digest != x ] ; then
+ echo $digest
+ else
+ digest=`md5 ext2.img 2>/dev/null | cut -f 4 -d " "`
+ echo $digest
+ fi
+}
+
+LC_ALL=C
+export LC_ALL