diff options
author | Brian Behlendorf <[email protected]> | 2013-01-28 13:39:40 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-01-28 14:51:26 -0800 |
commit | 930b6fec210d828cb3755f8756dbbbf3001cccae (patch) | |
tree | bbbc7b6f4ee26f155f777057d1ced53ca5de613f /scripts/common.sh.in | |
parent | 14ee71efbc28086406bb255f2292b9535d845625 (diff) |
Stop using /bin/ as a source in zconfig.sh
Test 5, 6, 7, and 7 in zconfig.sh use /bin/ as a source of random
directories and files for their test. This has lead to unexpected
tests failures because the total size of /bin/ on the test system
isn't checked and it is entirely possible for it to be larger than
the target filesystem.
To resolve this issue we create a somewhat random collection of
files and directories in /var/tmp to use. On average we expect
about 5MB of data with the worst case being 20MB. This is large
enough to be interesting and small enough to always fit in the
default test datasets.
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #1113
Diffstat (limited to 'scripts/common.sh.in')
-rw-r--r-- | scripts/common.sh.in | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/common.sh.in b/scripts/common.sh.in index f087f4431..531c7983b 100644 --- a/scripts/common.sh.in +++ b/scripts/common.sh.in @@ -116,6 +116,27 @@ skip() { echo -e "${COLOR_BROWN}Skip${COLOR_RESET}" } +populate() { + local ROOT=$1 + local MAX_DIR_SIZE=$2 + local MAX_FILE_SIZE=$3 + + mkdir -p $ROOT/{a,b,c,d,e,f,g}/{h,i} + DIRS=`find $ROOT` + + for DIR in $DIRS; do + COUNT=$(($RANDOM % $MAX_DIR_SIZE)) + + for i in `seq $COUNT`; do + FILE=`mktemp -p ${DIR}` + SIZE=$(($RANDOM % $MAX_FILE_SIZE)) + dd if=/dev/urandom of=$FILE bs=1k count=$SIZE &>/dev/null + done + done + + return 0 +} + init() { # Disable the udev rule 90-zfs.rules to prevent the zfs module # stack from being loaded due to the detection of a zfs device. @@ -127,6 +148,12 @@ init() { trap "mv ${RULE}.disabled ${RULE}" INT TERM EXIT mv ${RULE} ${RULE}.disabled fi + + # Create a random directory tree of files and sub-directories to + # to act as a copy source for the various regression tests. + SRC_DIR=`mktemp -d -p /var/tmp/ zfs.src.XXXXXXXX` + trap "rm -Rf $SRC_DIR" INT TERM EXIT + populate $SRC_DIR 10 100 } spl_dump_log() { |