From c49c8b146fdb45ef621fbba288758611c6d35cf3 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 27 Feb 2017 03:54:28 -0700 Subject: [PATCH] LU-8832 tests: fix module loading for Parallels It isn't possible to insmod modules directly from Parallels prl_fs mounting a host filesystem when testing directly from a build tree (insmod from an RPM installed in the root image filesystem works). Instead, copy the locally-built module into /tmp before loading it. Use load_module() in sanity.sh test_180b and run-llog.sh. Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: Id0123059e8151e2a78086579150f04b1b05cab07 Reviewed-on: https://review.whamcloud.com/25660 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Nunez Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/tests/run-llog.sh | 15 +-------------- lustre/tests/sanity.sh | 7 +++---- lustre/tests/test-framework.sh | 31 +++++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/lustre/tests/run-llog.sh b/lustre/tests/run-llog.sh index 937daee..7c34dc6b 100644 --- a/lustre/tests/run-llog.sh +++ b/lustre/tests/run-llog.sh @@ -5,19 +5,6 @@ LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)} init_test_env $@ . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} -load_llog_test() { - grep -q llog_test /proc/modules && return - # Module should have been placed with other lustre modules... - modprobe llog_test 2>&1 | grep -v "llog_test not found" - grep -q llog_test /proc/modules && return - # But maybe we're running from a developer tree... - insmod $LUSTRE/obdclass/llog_test.ko - grep -q llog_test /proc/modules && return - echo "Unable to load llog_test module!" - false - return -} - PATH=$(dirname $0):$LUSTRE/utils:$PATH TMP=${TMP:-/tmp} @@ -25,7 +12,7 @@ set -x MGS=$($LCTL dl | awk '/mgs/ { print $4 }') [ -z "$MGS" ] && echo "$0: SKIP: no MGS available, skipping llog test" && exit 0 -load_llog_test || exit 0 +load_module obdclass/llog_test || exit 0 $LCTL modules > $TMP/ogdb-$(hostname) echo "NOW reload debugging syms.." diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 005aa8f..f432e35 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -11632,12 +11632,11 @@ test_180b() { local rc=0 local rmmod_remote=0 - do_facet ost1 "lsmod | grep -q obdecho || " \ - "{ insmod ${LUSTRE}/obdecho/obdecho.ko || " \ - "modprobe obdecho; }" && rmmod_remote=1 + do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho && + rmmod_remote=true || error "failed to load module obdecho" target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}') [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; } - [ $rmmod_remote -eq 1 ] && do_facet ost1 "rmmod obdecho" + $rmmod_remote && do_facet ost1 "rmmod obdecho" return $rc } run_test 180b "test obdecho directly on obdfilter" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 8a33852..6ed34d0 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -442,6 +442,33 @@ module_loaded () { /sbin/lsmod | grep -q "^\<$1\>" } +PRLFS=false +lustre_insmod() { + local module=$1 + shift + local args="$@" + local msg + local rc=0 + + if ! $PRLFS; then + msg="$(insmod $module $args 2>&1)" && return 0 || rc=$? + fi + + # parallels can't load modules directly from prlfs, use /tmp instead + if $PRLFS || [[ "$(stat -f -c%t $module)" == "7c7c6673" ]]; then + local target="$(mktemp)" + + cp "$module" "$target" + insmod $target $args + rc=$? + [[ $rc == 0 ]] && PRLFS=true + rm -f $target + else + echo "$msg" + fi + return $rc +} + # Load a module on the system where this is running. # # usage: load_module module_name [module arguments for insmod/modprobe] @@ -494,10 +521,10 @@ load_module() { # we're passing options on the command-line. if [[ "$BASE" == "lnet_selftest" ]] && [[ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]]; then - insmod ${LUSTRE}/../lnet/selftest/${module}${EXT} + lustre_insmod ${LUSTRE}/../lnet/selftest/${module}${EXT} elif [[ -f ${LUSTRE}/${module}${EXT} ]]; then [[ "$BASE" != "ptlrpc_gss" ]] || modprobe sunrpc - insmod ${LUSTRE}/${module}${EXT} "$@" + lustre_insmod ${LUSTRE}/${module}${EXT} "$@" else # must be testing a "make install" or "rpm" installation # note failed to load ptlrpc_gss is considered not fatal -- 1.8.3.1