git: a1100e795ef1 - main - tests/sys/pmc: Keep atf_fail reasons on a single line

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Tue, 17 Nov 2026 13:49:15 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=a1100e795ef1e15df416a8d822f42e731783fe84

commit a1100e795ef1e15df416a8d822f42e731783fe84
Author:     Osvaldo Janeri Filho <ojanerif@amd.com>
AuthorDate: 2026-11-17 13:47:29 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-11-17 13:49:08 +0000

    tests/sys/pmc: Keep atf_fail reasons on a single line
    
    Several tests put the output of pmc record, pmc info or pmcstat into the
    atf_fail reason.  That output spans several lines, and ATF reports a
    multi-line reason as a broken test instead of a failed one, with the
    captured output mangled into the error.
    
    Copy the output to stderr, where kyua keeps it in the report, and use a
    single-line reason.
    
    Reviewed by:    mhorne
    Fixes:          546a76463123 ("tests/sys/pmc: add pidtrack, callchain, ...")
    Sponsored by:   Advanced Micro Devices, Inc.
    Signed-off-by:  Osvaldo Janeri Filho <ojanerif@amd.com>
    Differential Revision:  https://reviews.freebsd.org/D61459
---
 tests/sys/pmc/amd/pmc_frontend_test.sh | 6 ++++--
 tests/sys/pmc/pmc_cli_test.sh          | 9 ++++++---
 tests/sys/pmc/pmcstat_tsc_test.sh      | 3 ++-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tests/sys/pmc/amd/pmc_frontend_test.sh b/tests/sys/pmc/amd/pmc_frontend_test.sh
index 97964bebead0..36f33a3b641a 100644
--- a/tests/sys/pmc/amd/pmc_frontend_test.sh
+++ b/tests/sys/pmc/amd/pmc_frontend_test.sh
@@ -36,8 +36,10 @@ pmc_frontend_ibs_body()
 	rc=$?
 	kill "$load" 2>/dev/null
 	wait
-	[ "$rc" -eq 0 ] || \
-	    atf_fail "pmc record -s frontend failed: $(cat record.out)"
+	if [ "$rc" -ne 0 ]; then
+		cat record.out >&2
+		atf_fail "pmc record -s frontend failed"
+	fi
 
 	# Each decoded sample row of the analysis carries miss percentages.
 	atf_check -s exit:0 -o save:frontend.txt -e ignore \
diff --git a/tests/sys/pmc/pmc_cli_test.sh b/tests/sys/pmc/pmc_cli_test.sh
index e59e83370709..00e6fe56470c 100644
--- a/tests/sys/pmc/pmc_cli_test.sh
+++ b/tests/sys/pmc/pmc_cli_test.sh
@@ -76,7 +76,8 @@ pmc_record_then_info_body()
 	if ! pmc_record -c instructions -t 2 record.pmc; then
 		grep -q "Cannot allocate event" record.out && \
 		    atf_skip "no instructions event on this CPU"
-		atf_fail "pmc record failed: $(cat record.out)"
+		cat record.out >&2
+		atf_fail "pmc record failed"
 	fi
 
 	atf_check -s exit:0 -o save:info.txt -e ignore pmc info record.pmc
@@ -84,8 +85,10 @@ pmc_record_then_info_body()
 	# listed under the name libpmc resolved it to.
 	awk '/^Counter/ { t = 1; next }
 	    t && $NF ~ /^[0-9]+$/ && $NF > 0 { found = 1 }
-	    END { exit(found ? 0 : 1) }' info.txt || \
-	    atf_fail "pmc info shows no samples: $(tail -5 info.txt)"
+	    END { exit(found ? 0 : 1) }' info.txt || {
+		cat info.txt >&2
+		atf_fail "pmc info shows no samples"
+	}
 }
 
 atf_init_test_cases()
diff --git a/tests/sys/pmc/pmcstat_tsc_test.sh b/tests/sys/pmc/pmcstat_tsc_test.sh
index b4c589634d4a..e7c398ab9364 100644
--- a/tests/sys/pmc/pmcstat_tsc_test.sh
+++ b/tests/sys/pmc/pmcstat_tsc_test.sh
@@ -21,7 +21,8 @@ pmc_capture()
 	    2> pmcstat.err; then
 		grep -q "Cannot allocate system-mode pmc" pmcstat.err && \
 		    atf_skip "cannot allocate a system-mode instructions PMC"
-		atf_fail "pmcstat failed: $(cat pmcstat.err)"
+		cat pmcstat.err >&2
+		atf_fail "pmcstat failed"
 	fi
 	[ -s "$1" ] || atf_fail "pmcstat produced an empty log"
 }