Skip to content

Commit d346fee

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 d346fee

File tree

5 files changed

+124
-121
lines changed

5 files changed

+124
-121
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/suites/Kernel/FunctionalArea/baseport/adsp_remoteproc/run.sh

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ fi
3232
TESTNAME="adsp_remoteproc"
3333
test_path=$(find_test_case_by_name "$TESTNAME")
3434
cd "$test_path" || exit 1
35-
# shellcheck disable=SC2034
36-
res_file="./$TESTNAME.res"
3735

3836
log_info "-----------------------------------------------------------------------------------------"
3937
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
@@ -46,47 +44,45 @@ adsp_position=$(echo "$firmware_output" | grep -n "adsp" | cut -d: -f1)
4644

4745
# Adjust the position to match the remoteproc numbering (starting from 0)
4846
remoteproc_number=$((adsp_position - 1))
49-
50-
# Construct the remoteproc path based on the adsp position
5147
remoteproc_path="/sys/class/remoteproc/remoteproc${remoteproc_number}"
5248
log_info "Remoteproc node is $remoteproc_path"
53-
# Execute command 1 and check if the output is "running"
54-
state1=$(cat ${remoteproc_path}/state)
5549

50+
# Command 1: Check initial state
51+
state1=$(cat "${remoteproc_path}/state")
5652
if [ "$state1" != "running" ]; then
57-
log_fail "$TESTNAME : Test Failed"
58-
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
53+
log_fail "adsp not in running state initially"
54+
emit_result_and_signal "$TESTNAME" "FAIL"
5955
exit 1
6056
fi
6157

62-
# Execute command 2 (no output expected)
58+
# Command 2: Stop
6359
log_info "Stopping remoteproc"
64-
echo stop > ${remoteproc_path}/state
60+
echo stop > "${remoteproc_path}/state"
6561

66-
# Execute command 3 and check if the output is "offline"
67-
state3=$(cat ${remoteproc_path}/state)
62+
# Command 3: Check state after stop
63+
state3=$(cat "${remoteproc_path}/state")
6864
if [ "$state3" != "offline" ]; then
6965
log_fail "adsp stop failed"
70-
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
66+
emit_result_and_signal "$TESTNAME" "FAIL"
7167
exit 1
7268
else
7369
log_pass "adsp stop successful"
7470
fi
71+
72+
# Command 4: Start
7573
log_info "Restarting remoteproc"
76-
# Execute command 4 (no output expected)
77-
echo start > ${remoteproc_path}/state
74+
echo start > "${remoteproc_path}/state"
7875

79-
# Execute command 5 and check if the output is "running"
80-
state5=$(cat ${remoteproc_path}/state)
76+
# Command 5: Check state after start
77+
state5=$(cat "${remoteproc_path}/state")
8178
if [ "$state5" != "running" ]; then
8279
log_fail "adsp start failed"
83-
echo "$TESTNAME FAIL" > "$res_file"
80+
emit_result_and_signal "$TESTNAME" "FAIL"
8481
exit 1
8582
fi
8683

87-
# If all checks pass, print "PASS"
88-
echo "adsp PASS"
84+
# All checks passed
8985
log_pass "adsp PASS"
90-
echo "$TESTNAME PASS" > "$res_file"
86+
emit_result_and_signal "$TESTNAME" "PASS"
9187
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
9288
exit 0

Runner/suites/Kernel/FunctionalArea/baseport/cdsp_remoteproc/run.sh

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,59 +32,53 @@ fi
3232
TESTNAME="cdsp_remoteproc"
3333
test_path=$(find_test_case_by_name "$TESTNAME")
3434
cd "$test_path" || exit 1
35-
# shellcheck disable=SC2034
36-
res_file="./$TESTNAME.res"
3735

3836
log_info "-----------------------------------------------------------------------------------------"
3937
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
4038
log_info "=== Test Initialization ==="
4139

42-
# Get the firmware output and find the position of cdsp
4340
log_info "Get the firmware output and find the position of cdsp"
4441
firmware_output=$(cat /sys/class/remoteproc/remoteproc*/firmware)
4542
cdsp_position=$(echo "$firmware_output" | grep -n "cdsp" | cut -d: -f1)
4643

47-
# Adjust the position to match the remoteproc numbering (starting from 0)
4844
remoteproc_number=$((cdsp_position - 1))
49-
50-
# Construct the remoteproc path based on the cdsp position
5145
remoteproc_path="/sys/class/remoteproc/remoteproc${remoteproc_number}"
46+
log_info "Remoteproc node is $remoteproc_path"
5247

53-
# Execute command 1 and check if the output is "running"
54-
state1=$(cat ${remoteproc_path}/state)
48+
# Check initial state
49+
state1=$(cat "${remoteproc_path}/state")
5550
if [ "$state1" != "running" ]; then
56-
log_fail "$TESTNAME : Test Failed"
57-
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
51+
log_fail "$TESTNAME : not in running state initially"
52+
emit_result_and_signal "$TESTNAME" "FAIL"
5853
exit 1
5954
fi
6055

61-
# Execute command 2 (no output expected)
62-
echo stop > ${remoteproc_path}/state
56+
# Stop remoteproc
57+
log_info "Stopping remoteproc"
58+
echo stop > "${remoteproc_path}/state"
6359

64-
# Execute command 3 and check if the output is "offline"
65-
state3=$(cat ${remoteproc_path}/state)
60+
# Verify stop
61+
state3=$(cat "${remoteproc_path}/state")
6662
if [ "$state3" != "offline" ]; then
6763
log_fail "cdsp stop failed"
68-
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
64+
emit_result_and_signal "$TESTNAME" "FAIL"
6965
exit 1
7066
else
7167
log_pass "cdsp stop successful"
7268
fi
69+
7370
log_info "Restarting remoteproc"
74-
# Execute command 4 (no output expected)
75-
echo start > ${remoteproc_path}/state
71+
echo start > "${remoteproc_path}/state"
7672

77-
# Execute command 5 and check if the output is "running"
78-
state5=$(cat ${remoteproc_path}/state)
73+
# Verify restart
74+
state5=$(cat "${remoteproc_path}/state")
7975
if [ "$state5" != "running" ]; then
8076
log_fail "cdsp start failed"
81-
echo "$TESTNAME FAIL" > "$res_file"
77+
emit_result_and_signal "$TESTNAME" "FAIL"
8278
exit 1
8379
fi
8480

85-
# If all checks pass, print "PASS"
86-
echo "cdsp PASS"
8781
log_pass "cdsp PASS"
88-
echo "$TESTNAME PASS" > "$res_file"
82+
emit_result_and_signal "$TESTNAME" "PASS"
8983
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
9084
exit 0

Runner/utils/functestlib.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,36 @@ 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+
# One-time FD setup
414+
emit_result_and_signal() {
415+
TESTCASE="$1"
416+
RESULT="$2"
417+
res_file="./${TESTCASE}.res"
418+
signal_file="./${TESTCASE}.signal"
419+
420+
if ! is_suite_run && [ ! -f "$res_file" ]; then
421+
: > "$res_file"
422+
fi
423+
424+
echo "$TESTCASE $RESULT" >> "$res_file"
425+
printf "<<<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>>>\n" "$TESTCASE" "$RESULT" >> "$signal_file"
426+
}

Runner/utils/send-to-lava.sh

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,65 @@
22

33
RESULT_FILE="$1"
44

5-
command -v lava-test-case > /dev/null 2>&1
6-
lava_test_case="$?"
7-
command -v lava-test-set > /dev/null 2>&1
8-
lava_test_set="$?"
9-
10-
if [ -f "${RESULT_FILE}" ]; then
11-
while read -r line; do
12-
if echo "${line}" | grep -iq -E ".* +(pass|fail|skip|unknown)$"; then
13-
test="${line%% *}"
14-
result="${line##* }"
15-
16-
if [ "${lava_test_case}" -eq 0 ]; then
17-
lava-test-case "${test}" --result "${result}"
18-
else
19-
echo "<TEST_CASE_ID=${test} RESULT=${result}>"
20-
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}"
30-
else
31-
lava-test-case "${test}" --result "${result}" --measurement "${measurement}"
32-
fi
5+
# Default to any *.res file if none provided
6+
if [ -z "$RESULT_FILE" ]; then
7+
RESULT_FILE=$(find . -type f -name "*.res" | head -n1)
8+
fi
9+
10+
if [ ! -f "$RESULT_FILE" ]; then
11+
echo "WARNING: result file is missing: $RESULT_FILE"
12+
exit 0
13+
fi
14+
15+
command -v lava-test-case >/dev/null 2>&1
16+
lava_test_case=$?
17+
command -v lava-test-set >/dev/null 2>&1
18+
lava_test_set=$?
19+
20+
while IFS= read -r line || [ -n "$line" ]; do
21+
# Match basic result lines: "testname PASS", "testname FAIL"
22+
if echo "$line" | grep -iqE '^[[:alnum:]_.-]+[[:space:]]+(pass|fail|skip|unknown)$'; then
23+
test=$(echo "$line" | awk '{print $1}')
24+
result=$(echo "$line" | awk '{print $2}')
25+
26+
if [ "$lava_test_case" -eq 0 ]; then
27+
lava-test-case "$test" --result "$result"
28+
else
29+
echo "<<<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=${test} RESULT=${result}>>>"
30+
fi
31+
32+
# Extended result with measurement and units
33+
elif echo "$line" | grep -iqE '^[[:alnum:]_.-]+[[:space:]]+(pass|fail|skip|unknown)[[:space:]]+[0-9.]+( [a-zA-Z%]+)?$'; then
34+
test=$(echo "$line" | awk '{print $1}')
35+
result=$(echo "$line" | awk '{print $2}')
36+
measurement=$(echo "$line" | awk '{print $3}')
37+
units=$(echo "$line" | awk '{print $4}')
38+
39+
if [ "$lava_test_case" -eq 0 ]; then
40+
if [ -n "$units" ]; then
41+
lava-test-case "$test" --result "$result" --measurement "$measurement" --units "$units"
3342
else
34-
echo "<TEST_CASE_ID=${test} RESULT=${result} MEASUREMENT=${measurement} UNITS=${units}>"
43+
lava-test-case "$test" --result "$result" --measurement "$measurement"
3544
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}"
45+
else
46+
echo "<<<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=${test} RESULT=${result} MEASUREMENT=${measurement} UNITS=${units}>>>"
47+
fi
48+
49+
# Match test set start/stop signals
50+
elif echo "$line" | grep -iqE '^lava-test-set +(start|stop)'; then
51+
action=$(echo "$line" | awk '{print $2}')
52+
name=$(echo "$line" | awk '{print $3}')
53+
54+
if [ "$lava_test_set" -eq 0 ]; then
55+
lava-test-set "$action" "$name"
56+
else
57+
if [ "$action" = "start" ]; then
58+
echo "<<<LAVA_SIGNAL_TESTSET START ${name}>>>"
4159
else
42-
if [ "${test_set_status}" = "start" ]; then
43-
echo "<LAVA_SIGNAL_TESTSET START ${test_set_name}>"
44-
else
45-
echo "<LAVA_SIGNAL_TESTSET STOP>"
46-
fi
60+
echo "<<<LAVA_SIGNAL_TESTSET STOP>>>"
4761
fi
4862
fi
49-
done < "${RESULT_FILE}"
50-
else
51-
echo "WARNING: result file is missing!"
52-
fi
63+
else
64+
echo "Skipping unrecognized line: $line"
65+
fi
66+
done < "$RESULT_FILE"

0 commit comments

Comments
 (0)