2023-12-05 16:49:45

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v1] perf test: Skip diff test if test_loop is missing

The diff test depends on finding the symbol test_loop in perf and will
fail if perf has been stripped and no debug object is available. In
that case, skip the test instead.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/shell/diff.sh | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/perf/tests/shell/diff.sh b/tools/perf/tests/shell/diff.sh
index 213185763688..14b87af88703 100755
--- a/tools/perf/tests/shell/diff.sh
+++ b/tools/perf/tests/shell/diff.sh
@@ -9,8 +9,15 @@ perfdata1=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
perfdata2=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
perfdata3=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
testprog="perf test -w thloop"
+
+shelldir=$(dirname "$0")
+# shellcheck source=lib/perf_has_symbol.sh
+. "${shelldir}"/lib/perf_has_symbol.sh
+
testsym="test_loop"

+skip_test_missing_symbol ${testsym}
+
cleanup() {
rm -rf "${perfdata1}"
rm -rf "${perfdata1}".old
--
2.43.0.rc2.451.g8631bc7472-goog


2023-12-05 19:22:53

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH v1] perf test: Skip diff test if test_loop is missing

On 5/12/23 18:49, Ian Rogers wrote:
> The diff test depends on finding the symbol test_loop in perf and will
> fail if perf has been stripped and no debug object is available. In
> that case, skip the test instead.
>
> Signed-off-by: Ian Rogers <[email protected]>
> ---
> tools/perf/tests/shell/diff.sh | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/perf/tests/shell/diff.sh b/tools/perf/tests/shell/diff.sh
> index 213185763688..14b87af88703 100755
> --- a/tools/perf/tests/shell/diff.sh
> +++ b/tools/perf/tests/shell/diff.sh
> @@ -9,8 +9,15 @@ perfdata1=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> perfdata2=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> perfdata3=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
> testprog="perf test -w thloop"
> +
> +shelldir=$(dirname "$0")
> +# shellcheck source=lib/perf_has_symbol.sh
> +. "${shelldir}"/lib/perf_has_symbol.sh
> +
> testsym="test_loop"
>
> +skip_test_missing_symbol ${testsym}
> +
> cleanup() {
> rm -rf "${perfdata1}"
> rm -rf "${perfdata1}".old

The verbose output in the error case could also
be tweaked.

Before patch:

$ strip tools/perf/perf
$ tools/perf/perf buildid-cache -p $(realpath tools/perf/perf)
$ tools/perf/perf test -v 'diff test'
85: perf diff tests :
--- start ---
test child forked, pid 8621
Basic two file diff test
./tools/perf/tests/shell/diff.sh: 51: [: Workload: unexpected operator
./tools/perf/tests/shell/diff.sh: 56: [: Workload: unexpected operator
Basic two file diff test [Failed diff]
Basic three file diff test
./tools/perf/tests/shell/diff.sh: 73: [: Workload: unexpected operator
./tools/perf/tests/shell/diff.sh: 78: [: Workload: unexpected operator
./tools/perf/tests/shell/diff.sh: 83: [: Workload: unexpected operator
Basic three file diff test [Failed diff]
test child finished with -1
---- end ----
perf diff tests: FAILED!

After patch:

$ tools/perf/perf test -v 'diff test'
85: perf diff tests :
--- start ---
test child forked, pid 8853
perf does not have symbol 'test_loop'
perf is missing symbols - skipping test
test child finished with -2
---- end ----
perf diff tests: Skip

and with symbols:

$ tools/perf/perf test -v 'diff test'
85: perf diff tests :
--- start ---
test child forked, pid 10122
103e20-103e60 g test_loop
perf does have symbol 'test_loop'
Basic two file diff test
Basic two file diff test [Success]
Basic three file diff test
Basic three file diff test [Success]
test child finished with 0
---- end ----
perf diff tests: Ok



Tested-by: Adrian Hunter <[email protected]>