History log of /linux-master/tools/perf/tests/shell/test_task_analyzer.sh
Revision Date Author Comments
# 11cb1ed4 25-Jul-2023 Aditya Gupta <adityag@linux.ibm.com>

perf tests task_analyzer: Check perf build options for libtraceevent support

Currently we depend on output of 'perf record -e "sched:sched_switch"', to
check whether perf was built with libtraceevent support.

Instead, a more straightforward approach can be to check the build options,
using 'perf version --build-options', to check for libtraceevent support.

When perf is compiled WITHOUT libtraceevent ('make NO_LIBTRACEEVENT=1'),
'perf version --build-options' outputs (output trimmed):

...
libtraceevent: [ OFF ] # HAVE_LIBTRACEEVENT
...

While, when perf is compiled WITH libtraceevent,

'perf version --build-options' outputs:

...
libtraceevent: [ on ] # HAVE_LIBTRACEEVENT
...

Committer notes:

Removed one grep in the pipleline by combining the two into just one
expression that covers the OFF + HAVE_LIBTRACEEVENT.

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230725061649.34937-1-adityag@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# e4ef3ef1 22-Jun-2023 Namhyung Kim <namhyung@kernel.org>

perf test: Set PERF_EXEC_PATH for script execution

The task-analyzer.py script (actually every other scripts too) requires
PERF_EXEC_PATH env to find dependent libraries and scripts. For scripts
test to run correctly, it needs to set PERF_EXEC_PATH to the perf tool
source directory.

Instead of blindly update the env, let's check the directory structure
to make sure it points to the correct location.

Fixes: e8478b84d6ba ("perf test: add new task-analyzer tests")
Cc: Petar Gligoric <petar.gligoric@rohde-schwarz.com>
Cc: Hagen Paul Pfeifer <hagen@jauu.net>
Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>


# c3ac3b07 13-Jun-2023 Aditya Gupta <adityag@linux.ibm.com>

perf tests task_analyzer: Skip tests if no libtraceevent support

Test "perf script task-analyzer tests" fails in environment with missing
libtraceevent support, as perf record fails to create the perf.data
file, which further tests depend on.

Instead, when perf is not compiled with libtraceevent support, skip
those tests instead of failing them, by checking the output of `perf
record --dry-run` to see if it prints the error "libtraceevent is
necessary for tracepoint support"

For the following output, perf compiled with: `make NO_LIBTRACEEVENT=1`

Before the patch:

108: perf script task-analyzer tests :
test child forked, pid 24105
failed to open perf.data: No such file or directory (try 'perf record' first)
FAIL: "invokation of perf script report task-analyzer command failed" Error message: ""
FAIL: "test_basic" Error message: "Failed to find required string:'Comm'."
failed to open perf.data: No such file or directory (try 'perf record' first)
FAIL: "invokation of perf script report task-analyzer --ns --rename-comms-by-tids 0:random command failed" Error message: ""
FAIL: "test_ns_rename" Error message: "Failed to find required string:'Comm'."
failed to open perf.data: No such file or directory (try 'perf record' first)
<...>
perf script task-analyzer tests: FAILED!

With this patch, the script instead returns 2 signifying SKIP, and after
the patch:

108: perf script task-analyzer tests :
test child forked, pid 26010
libtraceevent is necessary for tracepoint support
WARN: Skipping tests. No libtraceevent support
test child finished with -2
perf script task-analyzer tests: Skip

Fixes: e8478b84d6ba9ccf ("perf test: Add new task-analyzer tests")
Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Petar Gligoric <petar.gligoric@rohde-schwarz.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230613164145.50488-18-atrajeev@linux.vnet.ibm.com
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# b8e55fde 13-Jun-2023 Aditya Gupta <adityag@linux.ibm.com>

perf tests task_analyzer: Print command that failed instead of just "perf"

Instead of printing "perf command failed" everytime, print the exact
command that run earlier

Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
Acked-by: Hagen Paul Pfeifer <hagen@jauu.net>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230613164145.50488-17-atrajeev@linux.vnet.ibm.com
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 5c4396ef 13-Jun-2023 Aditya Gupta <adityag@linux.ibm.com>

perf tests task_analyzer: Fix bad substitution ${$1}

${$1} gives bad substitution error on sh, bash, and zsh. This seems like
a typo, and this patch modifies it to $1, since that is what it's usage
looks like from wherever `check_exec_0` is called.

This issue due to ${$1} caused all function calls to give error in
`find_str_or_fail` line, and so no test runs completely. But
'perf test "perf script task-analyzer tests"' wrongly reports
that tests passed with the status OK, which is wrong considering
the tests didn't even run completely

Fixes: e8478b84d6ba9ccf ("perf test: add new task-analyzer tests")
Signed-off-by: Aditya Gupta <adityag@linux.ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Hagen Paul Pfeifer <hagen@jauu.net>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Petar Gligoric <petar.gligoric@rohde-schwarz.com>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230613164145.50488-16-atrajeev@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# 9694dfe0 13-Jun-2023 Aboorva Devarajan <aboorvad@linux.vnet.ibm.com>

perf tests test_task_analyzer: Fix shellcheck issues

Fixed the following shellcheck issues in test_task_analyzer.sh file:

SC2086: Double quote to prevent globbing and word splitting
warnings in shell-check.
Fixes the following shellcheck issues,

SC2086: Double quote to prevent globbing and word splitting
warnings in shell-check.

Before Patch:

$ shellcheck ./test_task_analyzer.sh | grep "SC2086" | ...
In ./test_task_analyzer.sh line 13:
SC2086: Double quote to prevent globbing and word splitting.
In ./test_task_analyzer.sh line 24:
SC2086: Double quote to prevent globbing and word splitting.
In ./test_task_analyzer.sh line 39:
SC2086: Double quote to prevent globbing and word splitting.

After Patch:
$ shellcheck ./test_task_analyzer.sh | grep -i "SC2086"
None

perf test result after patch:

PASS: "test_basic"
PASS: "test_ns_rename"
PASS: "test_ms_filtertasks_highlight"
PASS: "test_extended_times_timelimit_limittasks"
PASS: "test_summary"
PASS: "test_summaryextended"
PASS: "test_summaryonly"
PASS: "test_extended_times_summary_ns"
PASS: "test_extended_times_summary_ns"
PASS: "test_csv"
PASS: "test_csvsummary"
PASS: "test_csv_extended_times"
PASS: "test_csvsummary_extended"

Signed-off-by: Aboorva Devarajan <aboorvad@linux.vnet.ibm.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230613164145.50488-10-atrajeev@linux.vnet.ibm.com
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>


# e8478b84 06-Dec-2022 Petar Gligoric <petar.gligoric@rohde-schwarz.com>

perf test: add new task-analyzer tests

Provide task-analyzer test cases for all possible arguments and a subset of possible
combinations.

12 Tests in total.

test_basic:
- cmd:"perf script report task-analyzer"
- Fundamental test of script without arguments.
- Check for standard output.

test_ns_rename:
- cmd:"perf script report task-analyzer --ns --rename-comms-by-tids 0:random"
- Standard task with timestamps in nanoseconds and comm renamed.
- Check for standard output.

test_ms_filtertasks_highlight:
- cmd:"perf script report task-analyzer --ms --filter-tasks perf --highlight-tasks perf"
- Standard task with timestamps in milliseconds, task filtered out and highlighted.
- Check for standard output.

test_extended_times_timelimit_limittasks:
- cmd "perf script report task-analyzer --extended-times --time-limit :99999"
- Standard task with additional schedule out/in info and timlimit active at 99999.
- Check for extended table output.

test_summary:
- cmd:"perf script report task-analyzer --summary"
- Standard task with additional summary output.
- Check for summary print.

test_summary_extended:
- cmd:"perf script report task-analyzer --summary-extended"
- Standard task with summary and additional schedule in/out info.
- Chceck for extended table print.

test_summaryonly:
- cmd:"perf script report task-analyzer --summary-only"
- Only summary should be printed.
- Check for summary print.

test_extended_times_summary_ns:
- cmd:"perf script report task-analyzer --extended-times --summary --ns"
- Standard task with extended schedule in/out information and summary in ns.
- Check for extended table and summary.

test_csv:
- cmd:"perf script report task-analyzer --csv csv"
- Print standard task to csv file in csv format.
- Check for csv format.

test_csv_extended_times:
- cmd:"perf script report task-analyzer --csv csv --extended-times"
- Print standard task to csv file in csv format with additional schedule in/out
information.
- Check for additional information and csv format.

test_csvsummary:
- cmd:"perf script report task-analyzer --csv-summary csvsummary"
- Print summary to csvsummary file in csv format.
- Check for csv format.

test_csvsummary_extended:
- cmd:"perf script report task-analyzer --csv-summary csvsummary --summary-extended"
- Print summary to csvsummary file in csv format with additional schedule in/out
information.
- Check for additional information and csv format.

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Petar Gligoric <petar.gligoric@rohde-schwarz.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20221206154406.41941-4-petar.gligor@gmail.com
Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>