Skip to content

Commit c06adc9

Browse files
committed
Remove dependency on send-to-lava.sh; emit test results directly from run.sh
- All test scripts now use emit_result_and_signal() from functestlib.sh to report results inline using <LAVA_SIGNAL_TESTCASE ...> format. - Eliminated the need to call Runner/utils/send-to-lava.sh at the end of test jobs. - This enables LAVA to capture and display test results immediately as each test completes, improving granularity and reducing parser dependency. - Verified that both standalone and suite-level runs continue to write .res files. Note: YAML job files must no longer include send-to-lava.sh in the test step. Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
1 parent 25a36b1 commit c06adc9

File tree

3 files changed

+73
-61
lines changed

3 files changed

+73
-61
lines changed

Runner/plans/qcom-next-ci-premerge.yaml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,4 @@ run:
1818
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/adsp_remoteproc.res || true
1919
- $PWD/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh || true
2020
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/cdsp_remoteproc.res || true
21-
- $PWD/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/run.sh || true
22-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/CPUFreq_Validation/CPUFreq_Validation.res || true
23-
- $PWD/suites/Kernel/FunctionalArea/baseport/GIC/run.sh || true
24-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/GIC/GIC.res || true
25-
- $PWD/suites/Kernel/FunctionalArea/baseport/hotplug/run.sh || true
26-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/hotplug/hotplug.res || true
27-
- $PWD/suites/Kernel/FunctionalArea/baseport/Interrupts/run.sh || true
28-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/Interrupts/Interrupts.res || true
29-
- $PWD/suites/Kernel/FunctionalArea/baseport/irq/run.sh || true
30-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/irq/irq.res || true
31-
- $PWD/suites/Kernel/FunctionalArea/baseport/kaslr/run.sh || true
32-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/kaslr/kaslr.res || true
33-
- $PWD/suites/Kernel/FunctionalArea/baseport/MEMLAT/run.sh || true
34-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/MEMLAT/MEMLAT.res || true
35-
- $PWD/suites/Kernel/FunctionalArea/baseport/pinctrl/run.sh || true
36-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/pinctrl/pinctrl.res || true
37-
- $PWD/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/run.sh || true
38-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/Reboot_health_check/Reboot_health_check.res || true
39-
- $PWD/suites/Kernel/FunctionalArea/baseport/remoteproc/run.sh || true
40-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/remoteproc/remoteproc.res || true
41-
- $PWD/suites/Kernel/FunctionalArea/baseport/RMNET/run.sh || true
42-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/RMNET/RMNET.res || true
43-
- $PWD/suites/Kernel/FunctionalArea/baseport/IPA/run.sh || true
44-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/IPA/IPA.res || true
45-
- $PWD/suites/Kernel/FunctionalArea/baseport/Probe_Failure_Check/run.sh || true
46-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/Probe_Failure_Check/Probe_Failure_Check.res || true
47-
- $PWD/suites/Kernel/FunctionalArea/baseport/rngtest/run.sh || true
48-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/rngtest/rngtest.res || true
49-
- $PWD/suites/Kernel/FunctionalArea/baseport/smmu/run.sh || true
50-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/smmu/smmu.res || true
51-
- $PWD/suites/Kernel/FunctionalArea/baseport/storage/run.sh || true
52-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/storage/storage.res || true
53-
- $PWD/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/run.sh || true
54-
- $PWD/utils/send-to-lava.sh $PWD/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/wpss_remoteproc.res || true
5521
- $PWD/utils/result_parse.sh

Runner/utils/functestlib.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,37 @@ weston_start() {
391391
fi
392392
}
393393

394+
# Determine if the test is being run as part of a suite (i.e., run-test.sh is the parent)
395+
is_suite_run() {
396+
grep -q "run-test.sh" "/proc/$PPID/cmdline" 2>/dev/null
397+
}
398+
399+
# emit_result_and_signal TESTCASE RESULT
400+
#
401+
# Logs the test result to the .res file and emits a LAVA-compatible signal.
402+
# This function ensures that:
403+
# - The result is appended to the per-test .res file (PASS, FAIL, SKIP).
404+
# - A LAVA_SIGNAL_TESTCASE is sent to stderr in atomic format.
405+
# - If the test is run standalone (not via run-test.sh), the file is created.
406+
#
407+
# Arguments:
408+
# TESTCASE : The name of the test case (e.g., "rngtest")
409+
# RESULT : One of PASS, FAIL, or SKIP
410+
#
411+
# This allows both suite-level and individual test executions to remain compatible
412+
# with LAVA's result parsing, without losing debug logs to stdout.
413+
emit_result_and_signal() {
414+
TESTCASE="$1"
415+
RESULT="$2"
416+
res_file="./${TESTCASE}.res"
417+
418+
# Only create .res file during standalone (not suite) runs
419+
if ! is_suite_run && [ ! -f "$res_file" ]; then
420+
: > "$res_file"
421+
fi
422+
echo "$TESTCASE $RESULT" >> "$res_file"
423+
424+
# Emit cleanly to stdout to avoid dmesg or stderr interleaving
425+
printf "<<<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>>>\n" "$TESTCASE" "$RESULT"
426+
sleep 0.1
427+
}

Runner/utils/send-to-lava.sh

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,63 @@
22

33
RESULT_FILE="$1"
44

5-
command -v lava-test-case > /dev/null 2>&1
5+
command -v lava-test-case >/dev/null 2>&1
66
lava_test_case="$?"
7-
command -v lava-test-set > /dev/null 2>&1
7+
8+
command -v lava-test-set >/dev/null 2>&1
89
lava_test_set="$?"
910

1011
if [ -f "${RESULT_FILE}" ]; then
1112
while read -r line; do
12-
if echo "${line}" | grep -iq -E ".* +(pass|fail|skip|unknown)$"; then
13+
# Skip empty lines
14+
[ -z "$line" ] && continue
15+
16+
# Handle plain test case results: TESTNAME RESULT
17+
if echo "$line" | grep -iqE "^[^ ]+ +(pass|fail|skip|unknown)$"; then
1318
test="${line%% *}"
1419
result="${line##* }"
1520

16-
if [ "${lava_test_case}" -eq 0 ]; then
17-
lava-test-case "${test}" --result "${result}"
21+
if [ "$lava_test_case" -eq 0 ]; then
22+
lava-test-case "$test" --result "$result"
1823
else
19-
echo "<TEST_CASE_ID=${test} RESULT=${result}>"
24+
echo "<<<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=${test} RESULT=${result}>>>"
2025
fi
21-
elif echo "${line}" | grep -iq -E ".*+ (pass|fail|skip|unknown)+ .*+"; then
22-
test="$(echo "${line}" | awk '{print $1}')"
23-
result="$(echo "${line}" | awk '{print $2}')"
24-
measurement="$(echo "${line}" | awk '{print $3}')"
25-
units="$(echo "${line}" | awk '{print $4}')"
26-
27-
if [ "${lava_test_case}" -eq 0 ]; then
28-
if [ -n "${units}" ]; then
29-
lava-test-case "${test}" --result "${result}" --measurement "${measurement}" --units "${units}"
26+
27+
# Handle test case with measurement
28+
elif echo "$line" | grep -iqE "^[^ ]+ +(pass|fail|skip|unknown) +[0-9.]+( +[a-zA-Z/%]+)?$"; then
29+
test=$(echo "$line" | awk '{print $1}')
30+
result=$(echo "$line" | awk '{print $2}')
31+
measurement=$(echo "$line" | awk '{print $3}')
32+
units=$(echo "$line" | awk '{print $4}')
33+
34+
if [ "$lava_test_case" -eq 0 ]; then
35+
if [ -n "$units" ]; then
36+
lava-test-case "$test" --result "$result" --measurement "$measurement" --units "$units"
3037
else
31-
lava-test-case "${test}" --result "${result}" --measurement "${measurement}"
38+
lava-test-case "$test" --result "$result" --measurement "$measurement"
3239
fi
3340
else
34-
echo "<TEST_CASE_ID=${test} RESULT=${result} MEASUREMENT=${measurement} UNITS=${units}>"
41+
echo "<<<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=${test} RESULT=${result} MEASUREMENT=${measurement} UNITS=${units}>>>"
3542
fi
36-
elif echo "${line}" | grep -iq -E "^lava-test-set.*"; then
37-
test_set_status="$(echo "${line}" | awk '{print $2}')"
38-
test_set_name="$(echo "${line}" | awk '{print $3}')"
39-
if [ "${lava_test_set}" -eq 0 ]; then
40-
lava-test-set "${test_set_status}" "${test_set_name}"
43+
44+
# Handle test set signals
45+
elif echo "$line" | grep -iqE "^lava-test-set (start|stop) "; then
46+
status=$(echo "$line" | awk '{print $2}')
47+
setname=$(echo "$line" | awk '{print $3}')
48+
49+
if [ "$lava_test_set" -eq 0 ]; then
50+
lava-test-set "$status" "$setname"
4151
else
42-
if [ "${test_set_status}" = "start" ]; then
43-
echo "<LAVA_SIGNAL_TESTSET START ${test_set_name}>"
52+
if [ "$status" = "start" ]; then
53+
echo "<<<LAVA_SIGNAL_TESTSET START ${setname}>>>"
4454
else
45-
echo "<LAVA_SIGNAL_TESTSET STOP>"
55+
echo "<<<LAVA_SIGNAL_TESTSET STOP>>>"
4656
fi
4757
fi
58+
else
59+
echo "WARNING: Skipping malformed line: $line"
4860
fi
49-
done < "${RESULT_FILE}"
61+
done < "$RESULT_FILE"
5062
else
51-
echo "WARNING: result file is missing!"
63+
echo "WARNING: result file is missing: $RESULT_FILE"
5264
fi

0 commit comments

Comments
 (0)