From: Ian Rogers <irogers@google.com>
To: andi@firstfloor.org
Cc: acme@kernel.org, ak@kernel.org, ak@linux.intel.com,
linux-perf-users@vger.kernel.org, namhyung@kernel.org,
Ian Rogers <irogers@google.com>
Subject: [PATCH v1 7/7] perf test: Expand top tests for --hybrid-merge
Date: Sun, 23 Aug 2026 23:37:44 -0700 [thread overview]
Message-ID: <20260824063744.1533837-8-irogers@google.com> (raw)
In-Reply-To: <20260824063744.1533837-1-irogers@google.com>
Add shell test coverage for top --hybrid-merge flag to verify
correct behavior specifically on topologies featuring hybrid events.
It safely relies on fallback logic inside perf top.
Signed-off-by: Ian Rogers <irogers@google.com>
Assisted-by: Antigravity:gemini-3.1-pro
---
tools/perf/tests/shell/top.sh | 65 +++++++++++++++++++++++++++++------
1 file changed, 54 insertions(+), 11 deletions(-)
diff --git a/tools/perf/tests/shell/top.sh b/tools/perf/tests/shell/top.sh
index ad7fccd09025..49820bb2d6b2 100755
--- a/tools/perf/tests/shell/top.sh
+++ b/tools/perf/tests/shell/top.sh
@@ -35,26 +35,27 @@ test_basic_perf_top() {
# Use -d 1 to avoid flooding output
# Use -e cpu-clock to ensure we get samples
# Use sleep to keep stdin open but silent, preventing EOF loop or interactive spam
- if ! sleep 10 | timeout 5s perf top --stdio -d 1 -e cpu-clock -p $PID > "${log_file}" 2>&1; then
- retval=$?
- if [ $retval -ne 124 ] && [ $retval -ne 0 ]; then
- echo "Basic perf top test [Failed: perf top failed to start or run (ret=$retval)]"
- head -n 50 "${log_file}"
- kill $PID
- wait $PID 2>/dev/null || true
- err=1
- return
- fi
+ sleep 10 | timeout 5s perf top --stdio -d 1 -e cpu-clock \
+ -p $PID > "${log_file}" 2>&1 || retval=$?
+ if [ "${retval:-0}" -ne 124 ] && [ "${retval:-0}" -ne 0 ]; then
+ echo "Basic perf top test [Failed: perf top failed to start or run (ret=$retval)]"
+ head -n 50 "${log_file}"
+ kill $PID
+ wait $PID 2>/dev/null || true
+ err=1
+ return
fi
kill $PID
wait $PID 2>/dev/null || true
+ sync
+
# Check for some sample data (percentage)
if ! grep -E -q "[0-9]+\.[0-9]+%" "${log_file}"; then
echo "Basic perf top test [Failed: no sample percentage found]"
head -n 50 "${log_file}"
- err=1
+ err=2
return
fi
@@ -69,6 +70,48 @@ test_basic_perf_top() {
echo "Basic perf top test [Success]"
}
+test_hybrid_merge_perf_top() {
+ echo "Perf top hybrid merge test"
+
+ perf test -w thloop 20 &
+ PID=$!
+
+ # Allow it to start
+ sleep 0.1
+
+ # Run without explicitly requesting -e cycles so heavily virtualized
+ # environments can seamlessly fall back to cpu-clock while real
+ # hybrid hardware will naturally cover the merge logic.
+ sleep 10 | timeout 5s perf top -e cpu-clock \
+ --stdio --hybrid-merge -d 1 -p $PID > "${log_file}" 2>&1 || retval=$?
+ if [ "${retval:-0}" -ne 124 ] && [ "${retval:-0}" -ne 0 ]; then
+ echo "Perf top hybrid merge test [Failed: run err=$retval]"
+ head -n 50 "${log_file}"
+ kill $PID
+ wait $PID 2>/dev/null || true
+ err=1
+ return
+ fi
+ sync
+
+ kill $PID
+ wait $PID 2>/dev/null || true
+
+ # Wait a tiny bit for the file system to catch up on the logs
+ sync
+
+ # Check for some sample data (percentage)
+ if ! grep -E -q "[0-9]+\.[0-9]+%" "${log_file}"; then
+ echo "Perf top hybrid merge test [Failed: no sample percentage found]"
+ head -n 50 "${log_file}"
+ err=2
+ return
+ fi
+
+ echo "Perf top hybrid merge test [Success]"
+}
+
test_basic_perf_top
+test_hybrid_merge_perf_top
cleanup
exit $err
--
2.55.0.766.g2966f0265a-goog
next prev parent reply other threads:[~2026-08-24 6:38 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 13:25 [PATCH v1] perf top: Merge hybrid common events Andi Kleen
2026-08-13 13:57 ` sashiko-bot
2026-08-17 19:40 ` Ian Rogers
2026-08-18 17:29 ` Andi Kleen
2026-08-19 2:58 ` Ian Rogers
2026-08-19 3:34 ` Andi Kleen
2026-08-19 4:16 ` Ian Rogers
2026-08-19 16:11 ` Andi Kleen
2026-08-19 17:58 ` Ian Rogers
2026-08-19 18:25 ` Andi Kleen
2026-08-19 22:18 ` Ian Rogers
2026-08-24 6:37 ` [PATCH v1 0/7] perf ui: Implement hybrid event merging for heterogeneous systems Ian Rogers
2026-08-24 6:37 ` [PATCH v1 1/7] perf evlist: Implement evlist__can_merge_hybrid using first_wildcard_match Ian Rogers
2026-08-24 6:53 ` sashiko-bot
2026-08-24 22:49 ` Andi Kleen
2026-08-25 4:01 ` Ian Rogers
2026-08-24 6:37 ` [PATCH v1 2/7] perf ui hist: Add support for aggregated total_period and merging entries cleanly Ian Rogers
2026-08-24 6:53 ` sashiko-bot
2026-08-24 6:37 ` [PATCH v1 3/7] perf ui browsers: Implement interactive 'M' keystroke to toggle hybrid event merging Ian Rogers
2026-08-24 6:49 ` sashiko-bot
2026-08-24 6:37 ` [PATCH v1 4/7] perf tools: Expose opt-in --hybrid-merge Ian Rogers
2026-08-24 6:52 ` sashiko-bot
2026-08-24 22:40 ` Andi Kleen
2026-08-25 3:33 ` Ian Rogers
2026-08-25 22:19 ` Arnaldo Carvalho de Melo
2026-08-24 6:37 ` [PATCH v1 5/7] perf Documentation: Add tip for hybrid event merging Ian Rogers
2026-08-24 6:40 ` sashiko-bot
2026-08-24 6:37 ` [PATCH v1 6/7] perf ui hist: Format group headers iteratively based on proportional visual allocations Ian Rogers
2026-08-24 6:53 ` sashiko-bot
2026-08-24 6:37 ` Ian Rogers [this message]
2026-08-24 6:55 ` [PATCH v1 7/7] perf test: Expand top tests for --hybrid-merge sashiko-bot
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=20260824063744.1533837-8-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=ak@kernel.org \
--cc=ak@linux.intel.com \
--cc=andi@firstfloor.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=namhyung@kernel.org \
/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