From 5cbf6db937a304c4d2b60878a2405a1e2900abdf Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 11 Oct 2011 14:36:42 -0700 Subject: [PATCH] Disable 90-zfs.rules for test suite When running the zconfig.sh, zpios-sanity.sh, and zfault.sh from the installed packages the 90-zfs.rules can cause failures. These will occur because the test suite assumes it has full control over loading/unloading the module stack. If the stack gets asynchronously loaded by the udev rule the test suite will treat it as a failure. Resolve the issue by disabling the offending rule during the tests and enabling it on exit. Signed-off-by: Brian Behlendorf --- scripts/common.sh.in | 16 ++++++++++++++++ scripts/zconfig.sh | 3 +++ scripts/zfault.sh | 3 +++ scripts/zpios-sanity.sh | 3 +++ 4 files changed, 25 insertions(+) diff --git a/scripts/common.sh.in b/scripts/common.sh.in index 51671ebc01..56706194cc 100644 --- a/scripts/common.sh.in +++ b/scripts/common.sh.in @@ -36,6 +36,9 @@ libexecdir=@libexecdir@ pkglibexecdir=${libexecdir}/@PACKAGE@ bindir=@bindir@ sbindir=@sbindir@ +udevdir=@udevdir@ +udevruledir=@udevruledir@ +sysconfdir=@sysconfdir@ ETCDIR=${ETCDIR:-/etc} DEVDIR=${DEVDIR:-/dev/disk/zpool} @@ -113,6 +116,19 @@ skip() { echo -e "${COLOR_BROWN}Skip${COLOR_RESET}" } +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. + # This is important because the test scripts require full control + # over when and how the modules are loaded/unloaded. A trap is + # set to ensure the udev rule is correctly replaced on exit. + local RULE=${udevruledir}/90-zfs.rules + if test -e ${RULE}; then + trap "mv ${RULE}.disabled ${RULE}; exit $?" INT TERM EXIT + mv ${RULE} ${RULE}.disabled + fi +} + spl_dump_log() { ${SYSCTL} -w kernel.spl.debug.dump=1 &>/dev/null local NAME=`dmesg | tail -n 1 | cut -f5 -d' '` diff --git a/scripts/zconfig.sh b/scripts/zconfig.sh index f635423dd2..80f7e45701 100755 --- a/scripts/zconfig.sh +++ b/scripts/zconfig.sh @@ -60,6 +60,9 @@ if [ $(id -u) != 0 ]; then die "Must run as root" fi +# Initialize the test suite +init + # Perform pre-cleanup is requested if [ ${CLEANUP} ]; then ${ZFS_SH} -u diff --git a/scripts/zfault.sh b/scripts/zfault.sh index da4f16f4f0..a5f1f3cb1d 100755 --- a/scripts/zfault.sh +++ b/scripts/zfault.sh @@ -86,6 +86,9 @@ if [ $(id -u) != 0 ]; then die "Must run as root" fi +# Initialize the test suite +init + # Perform pre-cleanup is requested if [ ${CLEANUP} ]; then ${ZFS_SH} -u diff --git a/scripts/zpios-sanity.sh b/scripts/zpios-sanity.sh index fcd91b6e6a..0f441157d5 100755 --- a/scripts/zpios-sanity.sh +++ b/scripts/zpios-sanity.sh @@ -62,6 +62,9 @@ if [ $(id -u) != 0 ]; then die "Must run as root" fi +# Initialize the test suite +init + # Perform pre-cleanup is requested if [ ${CLEANUP} ]; then ${ZFS_SH} -u