blob: 933354751a020d5b3f373fc5881d42cf76698651 [file] [log] [blame]
Chase Qi09edc7f2016-08-18 13:18:50 +08001#!/bin/sh
2
3RESULT_FILE="$1"
Antonio Terceiro45a4d4a2025-03-10 16:41:00 -03004RESULT_DIR="$2"
5if [ -z "${RESULT_DIR}" ]; then
6 RESULT_DIR="$(dirname "${RESULT_FILE}")"
7fi
8
Antonio Terceiro11619492025-04-17 10:28:30 -03009signal() {
10 if [ -z ${KMSG} ]
11 then
12 echo "${1}"
13 else
14 echo "<0>${1}" > /dev/kmsg
15 fi
16}
17
Antonio Terceiro45a4d4a2025-03-10 16:41:00 -030018show_output() {
19 test_name="$1"
20 test_output="${RESULT_DIR}/${test_name}.log"
21 if [ -r "$test_output" ]; then
Antonio Terceiro11619492025-04-17 10:28:30 -030022 signal "<LAVA_SIGNAL_STARTTC $test_name>"
Antonio Terceiro45a4d4a2025-03-10 16:41:00 -030023 cat "$test_output"
Antonio Terceiro11619492025-04-17 10:28:30 -030024 signal "<LAVA_SIGNAL_ENDTC $test_name>"
Antonio Terceiro45a4d4a2025-03-10 16:41:00 -030025 fi
26}
Chase Qi09edc7f2016-08-18 13:18:50 +080027
Daniel Wagnerce874802021-08-04 09:22:37 +020028command -v lava-test-case > /dev/null 2>&1
Chase Qic1a3f882016-10-21 09:00:15 +080029lava_test_case="$?"
Daniel Wagnerce874802021-08-04 09:22:37 +020030command -v lava-test-set > /dev/null 2>&1
Oleksandr Terentiev03e82bc2018-11-28 04:38:52 -080031lava_test_set="$?"
Chase Qic1a3f882016-10-21 09:00:15 +080032
Chase Qi09edc7f2016-08-18 13:18:50 +080033if [ -f "${RESULT_FILE}" ]; then
Chase Qic763b9a2016-11-07 15:49:06 +080034 while read -r line; do
Aníbal Limón34cf65d2020-10-05 14:09:23 -050035 if echo "${line}" | grep -iq -E ".* +(pass|fail|skip|unknown)$"; then
Daniel Díaz372c5052022-12-07 10:20:31 -060036 test="${line%% *}"
37 result="${line##* }"
Chase Qi09edc7f2016-08-18 13:18:50 +080038
Antonio Terceiro45a4d4a2025-03-10 16:41:00 -030039 show_output "${test}"
Chase Qic1a3f882016-10-21 09:00:15 +080040 if [ "${lava_test_case}" -eq 0 ]; then
Chase Qi09edc7f2016-08-18 13:18:50 +080041 lava-test-case "${test}" --result "${result}"
42 else
43 echo "<TEST_CASE_ID=${test} RESULT=${result}>"
44 fi
Aníbal Limón34cf65d2020-10-05 14:09:23 -050045 elif echo "${line}" | grep -iq -E ".*+ (pass|fail|skip|unknown)+ .*+"; then
Chase Qi09edc7f2016-08-18 13:18:50 +080046 test="$(echo "${line}" | awk '{print $1}')"
47 result="$(echo "${line}" | awk '{print $2}')"
48 measurement="$(echo "${line}" | awk '{print $3}')"
49 units="$(echo "${line}" | awk '{print $4}')"
50
Antonio Terceiro45a4d4a2025-03-10 16:41:00 -030051 show_output "${test}"
Chase Qic1a3f882016-10-21 09:00:15 +080052 if [ "${lava_test_case}" -eq 0 ]; then
Nicolas Dechesne3d25d432017-01-19 15:47:09 +010053 if [ -n "${units}" ]; then
54 lava-test-case "${test}" --result "${result}" --measurement "${measurement}" --units "${units}"
55 else
56 lava-test-case "${test}" --result "${result}" --measurement "${measurement}"
57 fi
Chase Qi09edc7f2016-08-18 13:18:50 +080058 else
Chase Qib6e54582018-08-01 17:29:45 +080059 echo "<TEST_CASE_ID=${test} RESULT=${result} MEASUREMENT=${measurement} UNITS=${units}>"
Chase Qi09edc7f2016-08-18 13:18:50 +080060 fi
Milosz Wasilewski60152062020-03-02 18:53:29 +000061 elif echo "${line}" | grep -iq -E "^lava-test-set.*"; then
Oleksandr Terentiev03e82bc2018-11-28 04:38:52 -080062 test_set_status="$(echo "${line}" | awk '{print $2}')"
63 test_set_name="$(echo "${line}" | awk '{print $3}')"
64 if [ "${lava_test_set}" -eq 0 ]; then
65 lava-test-set "${test_set_status}" "${test_set_name}"
66 else
67 if [ "${test_set_status}" = "start" ]; then
Antonio Terceiro11619492025-04-17 10:28:30 -030068 signal "<LAVA_SIGNAL_TESTSET START ${test_set_name}>"
Oleksandr Terentiev03e82bc2018-11-28 04:38:52 -080069 else
Antonio Terceiro11619492025-04-17 10:28:30 -030070 signal "<LAVA_SIGNAL_TESTSET STOP>"
Oleksandr Terentiev03e82bc2018-11-28 04:38:52 -080071 fi
72 fi
Chase Qi09edc7f2016-08-18 13:18:50 +080073 fi
74 done < "${RESULT_FILE}"
75else
76 echo "WARNING: result file is missing!"
77fi