Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support make check #9614

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS)
endif
endif

AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = autogen.sh copy-builtin
EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am
EXTRA_DIST += META AUTHORS COPYRIGHT LICENSE NEWS NOTICE README.md
Expand All @@ -47,6 +46,11 @@ EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash.descrip

@CODE_COVERAGE_RULES@

AUTOMAKE_OPTIONS = foreign serial-tests

TESTS = scripts/zloop.sh scripts/zfs-tests.sh
TESTS_ENVIRONMENT = ZLOOP_TIMEOUT=600 ZLOOP_COREMAX=1

.PHONY: gitrev
gitrev:
-${top_srcdir}/scripts/make_gitrev.sh
Expand Down
1 change: 1 addition & 0 deletions scripts/common.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export ZFS=${ZFS:-$SBIN_DIR/zfs}
export ZPOOL=${ZPOOL:-$SBIN_DIR/zpool}
export ZTEST=${ZTEST:-$SBIN_DIR/ztest}
export ZFS_SH=${ZFS_SH:-$SCRIPT_DIR/zfs.sh}
export ZFS_HELPERS_SH=${ZFS_HELPERS_SH:-$SCRIPT_DIR/zfs-helpers.sh}

# Test Suite
export RUNFILE_DIR=${RUNFILE_DIR:-$ZTS_DIR/runfiles}
Expand Down
47 changes: 40 additions & 7 deletions scripts/zfs-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ PROG=zfs-helpers.sh
DRYRUN="no"
INSTALL="no"
REMOVE="no"
CHECK="no"
VERBOSE="no"

fail() {
Expand All @@ -45,14 +46,15 @@ msg() {
usage() {
cat << EOF
USAGE:
$0 [dhirv]
$0 [dhcirv]

DESCRIPTION:
Install/remove the ZFS helper utilities.
Check/install/remove the ZFS helper utilities.

OPTIONS:
-d Dry run
-h Show this message
-c Check the helper utilities (default)
-i Install the helper utilities
-r Remove the helper utilities
-v Verbose
Expand All @@ -63,7 +65,7 @@ $0 -r
EOF
}

while getopts 'hdirv' OPTION; do
while getopts 'hdcirv' OPTION; do
case $OPTION in
h)
usage
Expand All @@ -78,6 +80,9 @@ while getopts 'hdirv' OPTION; do
r)
REMOVE="yes"
;;
c)
CHECK="yes"
;;
v)
VERBOSE="yes"
;;
Expand All @@ -93,11 +98,13 @@ if [ "$INSTALL" = "yes" ] && [ "$REMOVE" = "yes" ]; then
fi

if [ "$INSTALL" = "no" ] && [ "$REMOVE" = "no" ]; then
fail "Either -i or -r must be specified"
CHECK="yes"
fi

if [ "$(id -u)" != "0" ]; then
fail "Must run as root"
if [ "$INSTALL" = "yes" ] || [ "$REMOVE" = "yes" ]; then
fail "Must run as root"
fi
fi

if [ "$INTREE" != "yes" ]; then
Expand Down Expand Up @@ -149,7 +156,30 @@ remove() {
fi
}

if [ "${INSTALL}" = "yes" ]; then
check() {
file=$1

if [ -e "$file" ]; then
msg "Found file: $file"
else
msg "Missing file: $file"
exit 1
fi
}

if [ "$CHECK" = "yes" ]; then
check "$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
check "$INSTALL_MOUNT_HELPER_DIR/fsck.zfs"
check "$INSTALL_UDEV_DIR/zvol_id"
check "$INSTALL_UDEV_DIR/vdev_id"
check "$INSTALL_UDEV_RULE_DIR/60-zvol.rules"
check "$INSTALL_UDEV_RULE_DIR/69-vdev.rules"
check "$INSTALL_UDEV_RULE_DIR/90-zfs.rules"
check "$INSTALL_SYSCONF_DIR/zfs/zpool.d"
check "$INSTALL_PYTHON_DIR/libzfs_core"
check "/lib/libzfs_core.so"
check "/lib/libnvpair.so"
elif [ "$INSTALL" = "yes" ]; then
install "$CMD_DIR/mount_zfs/mount.zfs" \
"$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
install "$CMD_DIR/fsck_zfs/fsck.zfs" \
Expand All @@ -176,7 +206,7 @@ if [ "${INSTALL}" = "yes" ]; then
install "$(find "$LIB_DIR/libnvpair" -type f -name 'libnvpair.so*')" \
"/lib/libnvpair.so"
ldconfig
else
elif [ "$REMOVE" = "yes" ]; then
remove "$INSTALL_MOUNT_HELPER_DIR/mount.zfs"
remove "$INSTALL_MOUNT_HELPER_DIR/fsck.zfs"
remove "$INSTALL_UDEV_DIR/zvol_id"
Expand All @@ -189,6 +219,9 @@ else
remove "/lib/libzfs_core.so"
remove "/lib/libnvpair.so"
ldconfig
else
echo "Unknown command"
exit 1
fi

exit 0
69 changes: 59 additions & 10 deletions scripts/zfs-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ fail() {
exit 1
}

#
# Log a message, cleanup, and return 77 to indicate to `make check` the
# test script could not be run and was instead skipped.
#
skip() {
cleanup
exit 77
}

#
# Attempt to remove loopback devices and files which where created earlier
# by this script to run the test framework. The '-k' option may be passed
Expand Down Expand Up @@ -455,7 +464,7 @@ if [ "$(id -u)" = "0" ]; then
fi

if [ "$(sudo whoami)" != "root" ]; then
fail "Passwordless sudo access required."
skip "Passwordless sudo access required."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this ask for a password, if sudo is not configured? I think you can use sudo -n true and return 0 is sudo-with-password is OK.

fi

#
Expand All @@ -464,19 +473,50 @@ fi
constrain_path

#
# Check if ksh exists
# Verify the ZFS module stack is loaded.
#
[ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh."
[ -e "$STF_SUITE/include/default.cfg" ] || fail \
"Missing $STF_SUITE/include/default.cfg file."
if [ ! -r /sys/module/zfs/version ]; then
echo "The ZFS kernel modules must be loaded."
echo "Use 'sudo $ZFS_SH' to load them."
skip
fi

#
# Verify the ZFS module stack is loaded.
# Verify required support utilities are installed. This is currently
# non-fatal but missing utilities may result in test failures.
#
if [ "$STACK_TRACER" = "yes" ]; then
sudo "${ZFS_SH}" -S &>/dev/null
else
sudo "${ZFS_SH}" &>/dev/null
if [ -n "$STF_MISSING_BIN" ]; then
echo "Warning: The following required utilities are not installed."
echo "This may result in individual test failures. The missing"
echo "utilities should be installed using your package manager."
echo
echo "$STF_MISSING_BIN"
echo
fi

#
# Verify the ZFS helper utilities are installed when running in-tree.
#
if [ "$INTREE" = "yes" ]; then
if ! $ZFS_HELPERS_SH -c; then
echo "The ZFS helper utilities are not installed."
echo "Use 'sudo $ZFS_HELPERS_SH -iv' to create symlinks."
skip
fi
fi

#
# Check if ksh exists.
#
if [ ! -e "$STF_PATH/ksh" ]; then
fail "This test suite requires ksh."
fi

#
# Check if the default.cfg file exists
#
if [ ! -e "$STF_SUITE/include/default.cfg" ]; then
fail "Missing $STF_SUITE/include/default.cfg file."
fi

#
Expand All @@ -486,6 +526,15 @@ if [ "$CLEANUPALL" = "yes" ]; then
cleanup_all
fi

#
# Verify there are no testpools imported from a previously failed run.
#
if sudo "$ZPOOL" list -H -o name | grep -q testpool; then
echo "There is a pool named 'testpool' imported on this system. This"
echo "pool is most likely left over from a previous failed test run."
skip
fi

#
# By default preserve any existing pools
# NOTE: Since 'zpool list' outputs a newline-delimited list convert $KEEP from
Expand Down
Loading