mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
perf test: Add shell test to validate JUnit XML reporting output
Add a shell test script (test_test_junit_output.sh) to execute perf test with the -j/--junit option and validate that the generated test report complies perfectly with standard XML formatting using Python's ElementTree XML parser. Assisted-by: Gemini-CLI:Google Gemini 3 Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@linaro.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
e2c545737b
commit
0dd6025171
63
tools/perf/tests/shell/test_test_junit_output.sh
Executable file
63
tools/perf/tests/shell/test_test_junit_output.sh
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# perf test junit XML output validation
|
||||
|
||||
set -e
|
||||
|
||||
err=0
|
||||
|
||||
shelldir=$(dirname "$0")
|
||||
# shellcheck source=lib/setup_python.sh
|
||||
. "${shelldir}"/lib/setup_python.sh
|
||||
|
||||
result=$(mktemp /tmp/__perf_test.output.xml.XXXXX)
|
||||
|
||||
cleanup()
|
||||
{
|
||||
rm -f "${result}"
|
||||
trap - exit term int
|
||||
}
|
||||
|
||||
trap_cleanup()
|
||||
{
|
||||
echo "Unexpected signal in ${FUNCNAME[1]}"
|
||||
cleanup
|
||||
exit 1
|
||||
}
|
||||
trap trap_cleanup exit term int
|
||||
|
||||
test_junit_output()
|
||||
{
|
||||
echo "Testing perf test JUnit XML output command"
|
||||
perf test -v -j"$result" util || true
|
||||
if [ -s "$result" ] ; then
|
||||
echo "perf test JUnit XML output command [SUCCESS]"
|
||||
else
|
||||
echo "perf test JUnit XML output command [FAILED]"
|
||||
err=1
|
||||
fi
|
||||
}
|
||||
|
||||
validate_xml_format()
|
||||
{
|
||||
echo "Validating perf test converted JUnit XML file"
|
||||
if [ -f "$result" ] ; then
|
||||
if $PYTHON -c \
|
||||
"import xml.etree.ElementTree as ET; ET.parse('$result')" \
|
||||
>/dev/null 2>&1 ; then
|
||||
echo "The file contains valid XML format [SUCCESS]"
|
||||
else
|
||||
echo "The file does not contain valid XML format [FAILED]"
|
||||
err=1
|
||||
fi
|
||||
else
|
||||
echo "File not found [FAILED]"
|
||||
err=1
|
||||
fi
|
||||
}
|
||||
|
||||
test_junit_output
|
||||
validate_xml_format
|
||||
|
||||
cleanup
|
||||
exit ${err}
|
||||
Loading…
Reference in New Issue
Block a user