projects/linux·blob master · refs

63 lines · 1.1 KiB

1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3# perf test junit XML output validation
4
5set -e
6
7err=0
8
9shelldir=$(dirname "$0")
10# shellcheck source=lib/setup_python.sh
11. "${shelldir}"/lib/setup_python.sh
12
13result=$(mktemp /tmp/__perf_test.output.xml.XXXXX)
14
15cleanup()
16{
17 rm -f "${result}"
18 trap - exit term int
19}
20
21trap_cleanup()
22{
23 echo "Unexpected signal in ${FUNCNAME[1]}"
24 cleanup
25 exit 1
26}
27trap trap_cleanup exit term int
28
29test_junit_output()
30{
31 echo "Testing perf test JUnit XML output command"
32 perf test -v -j"$result" util || true
33 if [ -s "$result" ] ; then
34 echo "perf test JUnit XML output command [SUCCESS]"
35 else
36 echo "perf test JUnit XML output command [FAILED]"
37 err=1
38 fi
39}
40
41validate_xml_format()
42{
43 echo "Validating perf test converted JUnit XML file"
44 if [ -f "$result" ] ; then
45 if $PYTHON -c \
46 "import xml.etree.ElementTree as ET; ET.parse('$result')" \
47 >/dev/null 2>&1 ; then
48 echo "The file contains valid XML format [SUCCESS]"
49 else
50 echo "The file does not contain valid XML format [FAILED]"
51 err=1
52 fi
53 else
54 echo "File not found [FAILED]"
55 err=1
56 fi
57}
58
59test_junit_output
60validate_xml_format
61
62cleanup
63exit ${err}