From 2c2e0478f81bf868f57d702e2a514441ecf3c65a Mon Sep 17 00:00:00 2001 From: Zygmunt Krynicki Date: Fri, 10 Jan 2025 11:52:16 +0100 Subject: [PATCH] tests: regression: separate bash traces from errors The BASH_XTRACEFD variable can be used to redirect "set -x" traces to a dedicated file. We can use it to split the execution trace (what has actually happened) from the failure messages. On a failing test this does provide improved clarity when debugging interactively with "spread -debug". On non-interactive runs the now shorter error list is also implicitly printed. Signed-off-by: Zygmunt Krynicki --- tests/regression/apparmor/task.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/regression/apparmor/task.yaml b/tests/regression/apparmor/task.yaml index e9983dcbc..02fe532b2 100644 --- a/tests/regression/apparmor/task.yaml +++ b/tests/regression/apparmor/task.yaml @@ -104,12 +104,13 @@ environment: artifacts: - bash.log - bash.err + - bash.trace execute: | # Run the shell script that is named after the spread variant we are running # now. The makefile runs them all sequentially via the "alltests" goal. Here # we can parallelize it through spread and also have a way to run precisely # the test we want, especially for debugging. - if ! bash -x "$SPREAD_VARIANT".sh >bash.log 2>bash.err; then + if ! BASH_XTRACEFD=42 bash -x "$SPREAD_VARIANT".sh >bash.log 2>bash.err 42>bash.trace; then for xfail in ${XFAIL:-}; do if [ "$SPREAD_SYSTEM" = "$xfail" ]; then echo "Ignoring expected failure of $SPREAD_TASK on $SPREAD_SYSTEM" @@ -118,13 +119,17 @@ execute: | done echo "Test $SPREAD_VARIANT has unexpectedly failed" - echo "Test execution logs are in the files bash.{log.err} and are collected as artifacts" + echo "Test execution logs are in the files bash.{log,err,trace} and are collected as artifacts" + echo "Bash errors are listed below:" + cat bash.err exit 1 else for xfail in ${XFAIL:-}; do if [ "$SPREAD_SYSTEM" = "$xfail" ]; then echo "Test $SPREAD_VARIANT has unexpectedly passed" - echo "Test execution logs are in the files bash.{log.err} and are collected as artifacts" + echo "Test execution logs are in the files bash.{log,err,trace} and are collected as artifacts" + echo "Bash errors are listed below:" + cat bash.err exit 1 fi done