From: Crystal Wood <crwood@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-kernel@vger.kernel.org,
John Kacur <jkacur@redhat.com>, Tomas Glozar <tglozar@redhat.com>,
Costa Shulyupin <costa.shul@redhat.com>,
Crystal Wood <crwood@redhat.com>
Subject: [PATCH 6/7] tools/rtla: Add test engine support for unexpected output
Date: Wed, 20 Aug 2025 22:57:18 -0500 [thread overview]
Message-ID: <20250821035719.137161-7-crwood@redhat.com> (raw)
In-Reply-To: <20250821035719.137161-1-crwood@redhat.com>
Add a check() parameter to indicate which text must not appear in the
output.
Simplify the code so that we can print failures as they happen rather
than trying to figure out what went wrong after printing "not ok". This
also means that "not ok" gets printed after the info rather than before,
which seems more intuitive anyway.
Signed-off-by: Crystal Wood <crwood@redhat.com>
---
tools/tracing/rtla/tests/engine.sh | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/tools/tracing/rtla/tests/engine.sh b/tools/tracing/rtla/tests/engine.sh
index a97d644ead99..25cf0822eee5 100644
--- a/tools/tracing/rtla/tests/engine.sh
+++ b/tools/tracing/rtla/tests/engine.sh
@@ -43,6 +43,7 @@ check() {
tested_command=$1
expected_exitcode=${3:-0}
expected_output=$4
+ unexpected_output=$5
# Simple check: run rtla with given arguments and test exit code.
# If TEST_COUNT is set, run the test. Otherwise, just count.
ctr=$(($ctr + 1))
@@ -53,24 +54,29 @@ check() {
# Run rtla; in case of failure, include its output as comment
# in the test results.
result=$(eval stdbuf -oL $TIMEOUT "$RTLA" $2 2>&1); exitcode=$?
+ fail=0
+
# Test if the results matches if requested
- if [ -n "$expected_output" ]
+ if [ -n "$expected_output" ] && ! grep -qE "$expected_output" <<< "$result"
then
- grep -E "$expected_output" <<< "$result" > /dev/null; grep_result=$?
- else
- grep_result=0
+ fail=1
+ printf "# Output match failed: \"%s\"\n" "$expected_output"
fi
- if [ $exitcode -eq $expected_exitcode ] && [ $grep_result -eq 0 ]
+ if [ -n "$unexpected_output" ] && grep -qE "$unexpected_output" <<< "$result"
+ then
+ fail=1
+ printf "# Output non-match failed: \"%s\"\n" "$unexpected_output"
+ fi
+
+ if [ $exitcode -eq $expected_exitcode ] && [ $fail -eq 0 ]
then
echo "ok $ctr - $1"
else
- echo "not ok $ctr - $1"
# Add rtla output and exit code as comments in case of failure
echo "$result" | col -b | while read line; do echo "# $line"; done
printf "#\n# exit code %s\n" $exitcode
- [ -n "$expected_output" ] && [ $grep_result -ne 0 ] && \
- printf "# Output match failed: \"%s\"\n" "$expected_output"
+ echo "not ok $ctr - $1"
fi
fi
}
--
2.48.1
next prev parent reply other threads:[~2025-08-21 3:58 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 3:57 [PATCH 0/7] tools/rtla: Code consolidation and osnoise actions Crystal Wood
2025-08-21 3:57 ` [PATCH 1/7] tools/rtla: Consolidate common parameters into shared structure Crystal Wood
2025-08-26 14:15 ` Tomas Glozar
2025-08-21 3:57 ` [PATCH 2/7] tools/rtla: Move top/hist union members elsewhere Crystal Wood
2025-08-26 13:58 ` Tomas Glozar
2025-08-26 19:42 ` Crystal Wood
2025-08-27 12:55 ` Tomas Glozar
2025-08-26 18:05 ` Costa Shulyupin
2025-08-26 20:39 ` Crystal Wood
2025-08-27 6:51 ` Tomas Glozar
2025-08-21 3:57 ` [PATCH 3/7] tools/rtla: Create common_apply_config() Crystal Wood
2025-08-27 11:33 ` Tomas Glozar
2025-08-29 20:35 ` Crystal Wood
2025-08-21 3:57 ` [PATCH 4/7] tools/rtla: Consolidate code between osnoise/timerlat and hist/top Crystal Wood
2025-08-27 13:34 ` Tomas Glozar
2025-08-29 20:46 ` Crystal Wood
2025-08-21 3:57 ` [PATCH 5/7] tools/rtla: Fix -A option name in test comment Crystal Wood
2025-08-28 6:52 ` Tomas Glozar
2025-08-21 3:57 ` Crystal Wood [this message]
2025-08-28 8:09 ` [PATCH 6/7] tools/rtla: Add test engine support for unexpected output Tomas Glozar
2025-08-29 21:34 ` Crystal Wood
2025-09-01 12:50 ` Tomas Glozar
2025-09-02 19:08 ` Crystal Wood
2025-09-03 16:15 ` Tomas Glozar
2025-08-21 3:57 ` [PATCH 7/7] tools/rtla: Add remaining support for osnoise actions Crystal Wood
2025-08-28 10:57 ` Tomas Glozar
2025-08-29 21:47 ` Crystal Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250821035719.137161-7-crwood@redhat.com \
--to=crwood@redhat.com \
--cc=costa.shul@redhat.com \
--cc=jkacur@redhat.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglozar@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).