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 <behlendorf1@llnl.gov>
Closes #1113
echo -e "${COLOR_BROWN}Skip${COLOR_RESET}"
}
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.
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.
trap "mv ${RULE}.disabled ${RULE}" INT TERM EXIT
mv ${RULE} ${RULE}.disabled
fi
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
local POOL_NAME=tank
local ZVOL_NAME=fish
local FULL_NAME=${POOL_NAME}/${ZVOL_NAME}
local POOL_NAME=tank
local ZVOL_NAME=fish
local FULL_NAME=${POOL_NAME}/${ZVOL_NAME}
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
# Create a pool and volume.
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
# Create a pool and volume.
sync
# Verify the copied files match the original files.
sync
# Verify the copied files match the original files.
- diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1${SRC_DIR} \
+ diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1/${SRC_DIR##*/} \
&>/dev/null || fail 9
# Remove the files, umount, destroy the volume and pool.
&>/dev/null || fail 9
# Remove the files, umount, destroy the volume and pool.
- rm -Rf /tmp/${ZVOL_NAME}-part1${SRC_DIR}* || fail 10
+ rm -Rf /tmp/${ZVOL_NAME}-part1/${SRC_DIR##*/} || fail 10
umount /tmp/${ZVOL_NAME}-part1 || fail 11
rmdir /tmp/${ZVOL_NAME}-part1 || fail 12
umount /tmp/${ZVOL_NAME}-part1 || fail 11
rmdir /tmp/${ZVOL_NAME}-part1 || fail 12
local SNAP_NAME=pristine
local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME}
local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME}
local SNAP_NAME=pristine
local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME}
local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME}
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
# Create a pool and volume.
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
# Create a pool and volume.
# Verify the copied files match the original files,
# and the copied files do NOT appear in the snapshot.
# Verify the copied files match the original files,
# and the copied files do NOT appear in the snapshot.
- diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1${SRC_DIR} \
+ diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1/${SRC_DIR##*/} \
- diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}-part1${SRC_DIR} \
+ diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}-part1/${SRC_DIR##*/} \
&>/dev/null && fail 13
# umount, destroy the snapshot, volume, and pool.
&>/dev/null && fail 13
# umount, destroy the snapshot, volume, and pool.
local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME}
local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME}
local FULL_CLONE_NAME=${POOL_NAME}/${CLONE_NAME}
local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME}
local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME}
local FULL_CLONE_NAME=${POOL_NAME}/${CLONE_NAME}
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
# Create a pool and volume.
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
# Create a pool and volume.
# Verify the copied files match the original files,
# and the copied files do NOT appear in the snapshot.
# Verify the copied files match the original files,
# and the copied files do NOT appear in the snapshot.
- diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1${SRC_DIR} \
+ diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1/${SRC_DIR##*/} \
- diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}-part1${SRC_DIR} \
+ diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}-part1/${SRC_DIR##*/} \
&>/dev/null && fail 13
# Clone from the original pristine snapshot
&>/dev/null && fail 13
# Clone from the original pristine snapshot
local FULL_ZVOL_NAME2=${POOL_NAME2}/${ZVOL_NAME}
local FULL_SNAP_NAME1=${POOL_NAME1}/${ZVOL_NAME}@${SNAP_NAME}
local FULL_SNAP_NAME2=${POOL_NAME2}/${ZVOL_NAME}@${SNAP_NAME}
local FULL_ZVOL_NAME2=${POOL_NAME2}/${ZVOL_NAME}
local FULL_SNAP_NAME1=${POOL_NAME1}/${ZVOL_NAME}@${SNAP_NAME}
local FULL_SNAP_NAME2=${POOL_NAME2}/${ZVOL_NAME}@${SNAP_NAME}
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
# Create two pools and a volume
local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX`
# Create two pools and a volume