From: Emoly Liu Date: Sun, 3 Nov 2024 10:31:12 +0000 (+0800) Subject: LU-18390 tests: dump debug logs during module unload correctly X-Git-Tag: 2.16.51~188 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a29cff26051888a986380d57f0501d70d11dd743;p=fs%2Flustre-release.git LU-18390 tests: dump debug logs during module unload correctly If DEBUG is enabled, debug logs will be dumped to: - $TMP/debug by default if DEBUG_RMMOD is unset. And if memory leak is found, $TMP/debug will be renamed to $TMP/debug-leak.xxx; - $DEBUG_RMMOD if $DEBUG_RMMOD is a full path name; - $TMP/DEBUG_RMMOD if $DEBUG_RMMOD is a filename; - standard output if DEBUG_RMMOD=- . Memory leak in conf-sanity.sh test_29 in interop testing(LU-17962) is used to verify this patch. Test-Parameters: env=DEBUG=true,IGNORE_LEAK=yes,ONLY=29 \ testlist=conf-sanity serverversion=2.15 clientdistro=el8.10 \ serverdistro=el8.10 mdscount=2 mdtcount=4 ostcount=8 Test-Parameters: env=DEBUG_RMMOD=lu18390,IGNORE_LEAK=yes,ONLY=29 \ testlist=conf-sanity serverversion=2.15 clientdistro=el8.10 \ serverdistro=el8.10 mdscount=2 mdtcount=4 ostcount=8 Test-Parameters:trivial Fixes: 255102e84e ("LU-16384 tests: dump lustre log if DEBUG_RMMOD set") Signed-off-by: Emoly Liu Change-Id: I23a584541d0f9b313cf00e56f63dc4ac356c3cbc Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56767 Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/scripts/lustre_rmmod b/lustre/scripts/lustre_rmmod index 9dca753..bb4fe03 100755 --- a/lustre/scripts/lustre_rmmod +++ b/lustre/scripts/lustre_rmmod @@ -7,8 +7,13 @@ SCRIPT_NAME="$(basename "$0")" LCTL=${LCTL:-lctl} -DEBUG='false' -[[ -n $DEBUG_RMMOD ]] && DEBUG='true' +if [[ -z "$DEBUG" ]]; then + if [[ -n "$DEBUG_RMMOD" ]]; then + DEBUG=true + else + DEBUG=false + fi +fi # Print help message print_usage() { @@ -28,11 +33,14 @@ print_debug() { $LCTL mark "$SCRIPT_NAME : Stop debug" if [[ $DEBUG_RMMOD == "-" ]]; then debug_file="" # dump to stdout + elif [[ "${DEBUG_RMMOD:0:1}" == "/" ]]; then + debug_file="$DEBUG_RMMOD" else - debug_file=$DEBUG_RMMOD + debug_file=$TMP/${DEBUG_RMMOD:-debug} fi + echo "Dump memory leak logs to $debug_file" $LCTL debug_kernel $debug_file - DEBUG='false' + DEBUG=false } # Unload all modules dependent on $1 (exclude removal of $1) diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index e8fa12b..c3f59fb 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -1188,9 +1188,13 @@ check_mem_leak () { if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then echo "$LEAK_LUSTRE" 1>&2 echo "$LEAK_PORTALS" 1>&2 - mv $TMP/debug $TMP/debug-leak.`date +%s` || true echo "Memory leaks detected" - [ -n "$IGNORE_LEAK" ] && + if [ $DEBUG -a -z $DEBUG_RMMOD ]; then + debug_file=$TMP/debug-leak.$(date +%s) + mv $TMP/debug $debug_file && + echo "Save $TMP/debug to $debug_file" + fi + [[ -n "$IGNORE_LEAK" ]] && { echo "ignoring leaks" && return 0; } || true return 1 fi