| 1 | |
| 2 | |
| 3 | |
| 4 |
|
| 5 | set -e
|
| 6 |
|
| 7 | err=0
|
| 8 |
|
| 9 | shelldir=$(dirname "$0")
|
| 10 | |
| 11 | . "${shelldir}"/lib/setup_python.sh
|
| 12 |
|
| 13 | result=$(mktemp /tmp/__perf_test.output.xml.XXXXX)
|
| 14 |
|
| 15 | cleanup()
|
| 16 | {
|
| 17 | rm -f "${result}"
|
| 18 | trap - exit term int
|
| 19 | }
|
| 20 |
|
| 21 | trap_cleanup()
|
| 22 | {
|
| 23 | echo "Unexpected signal in ${FUNCNAME[1]}"
|
| 24 | cleanup
|
| 25 | exit 1
|
| 26 | }
|
| 27 | trap trap_cleanup exit term int
|
| 28 |
|
| 29 | test_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 |
|
| 41 | validate_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 |
|
| 59 | test_junit_output
|
| 60 | validate_xml_format
|
| 61 |
|
| 62 | cleanup
|
| 63 | exit ${err}
|