Home | History | Annotate | Download | only in genext2fs
      1 #!/bin/sh
      2 
      3 # This script generates a variety of filesystems and checks that they
      4 # are identical to ones that are known to be mountable, and pass fsck
      5 # and various other sanity checks.
      6 
      7 # Passing these tests is preferable to passing test-mount.sh because
      8 # this script doesn't require root, and because passing these tests
      9 # guarantees byte-for-byte agreement with other builds, ports,
     10 # architectures, times of day etc.
     11 
     12 set -e
     13 
     14 . ./test-gen.lib
     15 
     16 # md5cmp - Calculate MD5 digest and compare it to an expected value.
     17 # Usage: md5cmp expected-digest
     18 md5cmp () {
     19 	checksum=$1
     20 	md5=`calc_digest`
     21 	if [ x$md5 = x$checksum ] ; then
     22 		echo PASSED
     23 	else
     24 		echo FAILED
     25 		exit 1
     26 	fi
     27 }
     28 
     29 # dtest - Exercises the -d directory option of genext2fs
     30 # Creates an image with a file of given size and verifies it
     31 # Usage: dtest file-size number-of-blocks correct-checksum
     32 dtest () {
     33 	size=$1; blocks=$2; checksum=$3
     34 	echo Testing with file of size $size
     35 	dgen $size $blocks
     36 	md5cmp $checksum
     37 	gen_cleanup
     38 }
     39 
     40 # ftest - Exercises the -f spec-file option of genext2fs
     41 # Creates an image with the devices mentioned in the given spec 
     42 # file and verifies it
     43 # Usage: ftest spec-file number-of-blocks correct-checksum
     44 ftest () {
     45 	fname=$1; blocks=$2; checksum=$3
     46 	echo Testing with devices file $fname
     47 	fgen $fname $blocks
     48 	md5cmp $checksum
     49 	gen_cleanup
     50 }
     51 
     52 # NB: to regenerate these values, always use test-mount.sh, that is,
     53 # replace the following lines with the output of
     54 # sudo sh test-mount.sh|grep test
     55 
     56 dtest 0 4096 3bc6424b8fcd51a0de34ee59d91d5f16
     57 dtest 0 8193 f174804f6b433b552706cbbfc60c416d
     58 dtest 0 8194 4855a55d0cbdc44584634df49ebd5711
     59 dtest 1 4096 09c569b6bfb45222c729c42d04d5451f
     60 dtest 12288 4096 61febcbfbf32024ef99103fcdc282c39
     61 dtest 274432 4096 0c517803552c55c1806e4220b0a0164f
     62 dtest 8388608 9000 e0e5ea15bced10ab486d8135584b5d8e
     63 dtest 16777216 20000 fdf636eb905ab4dc1bf76dce5ac5d209
     64 ftest device_table.txt 4096 a0af06d944b11d2902dfd705484c64cc
     65