From 270f9306bc16676a9ef5e630408f3ec2cf1889b2 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 11 Nov 2024 22:17:05 +0100 Subject: [PATCH] tests: improve tracing messages Avoid printing lvm2 command trace, if the test finds the 'dmeventd' was started unxpectedly during testing as the last command is hardly ever responsible for this Also reorder some messages when doing teardown of devices. Do not print 'help' message from hostname command, when it does not support option '-I'. --- test/lib/aux.sh | 16 ++++++++++------ test/lib/inittest.sh | 4 +++- test/lib/utils.sh | 6 +++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/test/lib/aux.sh b/test/lib/aux.sh index 1b9b8dda7..73ebe82b1 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -430,8 +430,13 @@ teardown_devs_prefixed() { local force="-f" if test "$i" = 0; then if test "$once" = 1 ; then + case "$DM_NAME" in + *pv[0-9]*) ;; # do not report removal of our own PVs + *) once=0 echo "## removing stray mapped devices with names beginning with $prefix: " + ;; + esac fi test "$DM_OPEN" = 0 || break # stop loop with 1st. opened device force="" @@ -607,9 +612,9 @@ teardown() { echo -n . - test -d "$DM_DEV_DIR/mapper" && teardown_devs + echo "ok" - echo -n . + test -d "$DM_DEV_DIR/mapper" && teardown_devs fi @@ -620,11 +625,10 @@ teardown() { } if test "${LVM_TEST_PARALLEL:-0}" = 0 && test -z "$RUNNING_DMEVENTD"; then + rm -f debug.log* # no trace of lvm2 command for this case not pgrep dmeventd &>/dev/null # printed in STACKTRACE fi - echo -n . - test -n "$TESTDIR" && { cd "$TESTOLDPWD" || die "Failed to enter $TESTOLDPWD" # after this delete no further write is possible @@ -641,6 +645,8 @@ teardown() { LEAKED_LINKS=( $(find /dev -path "/dev/mapper/${PREFIX}*" -type l -exec test ! -e {} \; -print -o \ -path "/dev/${PREFIX}*/" -type l -exec test ! -e {} \; -print 2>/dev/null || true) ) + test "${#LEAKED_LINKS[@]}" -eq 0 || echo "## removing stray symlinks the names beginning with ${PREFIX}" + if test "${LVM_TEST_PARALLEL:-0}" = 0 ; then # for non parallel testing erase any dangling links prefixed with LVMTEST find /dev -path "/dev/mapper/${COMMON_PREFIX}*" -type l -exec test ! -e {} \; -print0 -o \ @@ -656,8 +662,6 @@ teardown() { # Fail test with leaked links as most likely somewhere is missing synchronization... test "${#LEAKED_LINKS[@]}" -eq 0 || die "Test leaked these symlinks ${LEAKED_LINKS[@]}" - - echo "ok" } prepare_loop() { diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh index 78b4e9d9c..a9577c90d 100644 --- a/test/lib/inittest.sh +++ b/test/lib/inittest.sh @@ -176,7 +176,9 @@ echo "@PREFIX=$PREFIX" echo "## DATE: $(date || true)" # Hostname IP address -echo "## HOST: $(hostname -I 2>/dev/null || hostname 2>/dev/null || true)" +HOSTNAME=$(hostname -I 2>/dev/null) || HOSTNAME= +HOSTNAME="$(hostname 2>/dev/null) ${HOSTNAME}" || true +echo "## HOST: $HOSTNAME" if test -z "$SKIP_ROOT_DM_CHECK" ; then aux lvmconf diff --git a/test/lib/utils.sh b/test/lib/utils.sh index 5dc6b68f6..64f94369f 100644 --- a/test/lib/utils.sh +++ b/test/lib/utils.sh @@ -128,9 +128,9 @@ STACKTRACE() { stacktrace test "${LVM_TEST_PARALLEL:-0}" -eq 0 && test -z "$RUNNING_DMEVENTD" && \ - test ! -f LOCAL_DMEVENTD && pgrep dmeventd >DPID 2>/dev/null && { - echo "## ERROR: The test started dmeventd ($(< DPID)) unexpectedly." - kill "$(< DPID)" + test ! -f LOCAL_DMEVENTD && DPID=$(pgrep -n dmeventd 2>/dev/null) && { + echo "## ERROR: The test started dmeventd ($DPID) unexpectedly." + kill "$DPID" 2>/dev/null || echo "## ERROR: Failed to kill dmeventd ($DPID)." } # Get backtraces from coredumps