Skip to content

Commit 69e4382

Browse files
committed
baseport: remoteproc: adsp/cdsp/wpss tests: SoC-aware skips, RPMsg probe, shellcheck fixes
- Discover RProc nodes via find_remoteproc_by_firmware() instead of hardcoded IDs. - Skip cleanly when a core isn’t present on the SoC (no more false FAILs). - Stop/Start paths now wait_for_state()/wait_remoteproc_state() with timeouts & polling. - Dump rproc logs around each transition (before/after stop/start) for easier CI debug. - Add generic RPMsg exercise: * Map rpmsg_ctrl* to the owning remoteproc. * Reuse/create endpoints and try an echo; mark PASS/FAIL/SKIPPED accordingly. - CDSP: handle multi-instance (cdsp0/cdsp1…) and print per-instance boot/stop/start/ping results. - WPSS: keep driver fallback (ath11k/ath11xx) if remoteproc is absent: * Validate firmware via /lib/firmware/ath11k blobs, dmesg strings, and wlan*/ath* netdev presence. * POSIX-safe globbing instead of grep-regex for interface detection. - Ensure .res contains only “TESTNAME <RESULT>”; everything else goes to log. - ShellCheck cleanup: SC2143, SC2181, SC3037, SC2034, etc. (no unused vars, no `$?` chains, printf over echo -e). - Added/updated helpers in functestlib.sh (rpmsg_* helpers, dump_rproc_logs, wait_remoteproc_state, etc.). - Protect concurrent runs with acquire_test_lock()/release_test_lock(). Signed-off-by: Srikanth Muppandam <[email protected]>
1 parent 0ac513b commit 69e4382

File tree

4 files changed

+649
-125
lines changed

4 files changed

+649
-125
lines changed

Runner/suites/Kernel/Baseport/adsp_remoteproc/run.sh

Lines changed: 81 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,93 @@ fi
2929
. "$TOOLS/functestlib.sh"
3030

3131
TESTNAME="adsp_remoteproc"
32-
firmware_name="adsp"
33-
res_file="./$TESTNAME.res"
34-
LOG_FILE="./$TESTNAME.log"
35-
32+
RES_FILE="./$TESTNAME.res"
33+
FW="adsp"
34+
3635
test_path=$(find_test_case_by_name "$TESTNAME")
3736
cd "$test_path" || exit 1
3837

3938
log_info "-----------------------------------------------------------------------------------------"
4039
log_info "------------------- Starting $TESTNAME Testcase ----------------------------"
4140
log_info "=== Test Initialization ==="
42-
43-
if ! validate_remoteproc_running "$firmware_name" "$LOG_FILE" 15 2; then
44-
log_fail "$firmware_name remoteproc is not in running state after bootup"
45-
echo "$TESTNAME FAIL" > "$res_file"
46-
exit 1
47-
fi
48-
49-
log_pass "$firmware_name remoteproc validated as running"
50-
51-
rproc_path=$(get_remoteproc_path_by_firmware "$firmware_name")
52-
53-
stop_remoteproc "$rproc_path" || {
54-
log_fail "$TESTNAME stop failed"
55-
echo "$TESTNAME FAIL" > "$res_file"
56-
exit 1
57-
}
58-
log_pass "$firmware_name stop successful"
59-
60-
log_info "Restarting $firmware_name"
61-
start_remoteproc "$rproc_path" || {
62-
log_fail "$TESTNAME start failed"
63-
echo "$TESTNAME FAIL" > "$res_file"
41+
42+
fail() {
43+
log_fail "$1"
44+
echo "${TESTNAME} FAIL" >"$RES_FILE"
45+
release_test_lock
6446
exit 1
6547
}
66-
67-
log_pass "$firmware_name PASS"
68-
echo "$TESTNAME PASS" > "$res_file"
69-
70-
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"
48+
49+
# Defaults (can be overridden)
50+
STOP_TO="${STOP_TO:-10}"
51+
START_TO="${START_TO:-10}"
52+
POLL_I="${POLL_I:-1}"
53+
54+
acquire_test_lock "$TESTNAME"
55+
log_info "Starting $TESTNAME Testcase"
56+
57+
#Discover
58+
entry=$(get_remoteproc_by_firmware "$FW") || entry=""
59+
if [ -z "$entry" ]; then
60+
log_skip "$TESTNAME SKIP – $FW unsupported"
61+
echo "${TESTNAME} SKIP" >"$RES_FILE"
62+
release_test_lock
63+
exit 0
64+
fi
65+
rpath=${entry%% *}; rstate=${entry#* }
66+
log_info "Found $rpath (state=$rstate)"
67+
68+
#Boot‐state
69+
[ "$rstate" = running ] || fail "$FW offline at boot"
70+
log_pass "$FW is running at boot"
71+
72+
#Stop
73+
dump_rproc_logs "$rpath" before-stop
74+
start_stop=$(date +%s)
75+
log_info "Stopping $FW"
76+
stop_remoteproc "$rpath" || { dump_rproc_logs "$rpath" after-stop-fail; fail "stop failed"; }
77+
wait_remoteproc_state "$rpath" offline "$STOP_TO" "$POLL_I" \
78+
|| { dump_rproc_logs "$rpath" after-stop-timeout; fail "no offline after timeout"; }
79+
end_stop=$(date +%s)
80+
log_pass "$FW stopped in $((end_stop-start_stop))s"
81+
dump_rproc_logs "$rpath" after-stop
82+
83+
#Start
84+
dump_rproc_logs "$rpath" before-start
85+
start_start=$(date +%s)
86+
log_info "Starting $FW"
87+
start_remoteproc "$rpath" || { dump_rproc_logs "$rpath" after-start-fail; fail "start failed"; }
88+
wait_remoteproc_state "$rpath" running "$START_TO" "$POLL_I" \
89+
|| { dump_rproc_logs "$rpath" after-start-timeout; fail "no running after timeout"; }
90+
end_start=$(date +%s)
91+
log_pass "$FW restarted in $((end_start-start_start))s"
92+
dump_rproc_logs "$rpath" after-start
93+
94+
#Optional RPMsg ping via /dev/rpmsg_ctrl*
95+
rpmsg_res="skipped"
96+
if CTRL_DEV=$(find_rpmsg_ctrl_for "$FW"); then
97+
log_info "Using RPMSG control device: $CTRL_DEV"
98+
# POSIX-safe send
99+
printf 'PING\n' >"$CTRL_DEV" 2>/dev/null
100+
if REPLY=$(timeout 2 cat "$CTRL_DEV"); then
101+
if printf '%s' "$REPLY" | grep -q '^PONG'; then
102+
log_pass "RPMSG ping passed"
103+
rpmsg_res="passed"
104+
else
105+
log_warn "RPMSG ping failed: unexpected reply '$REPLY'"
106+
rpmsg_res="failed"
107+
fi
108+
else
109+
log_warn "RPMSG ping timed out (no reply within 2s)"
110+
rpmsg_res="failed"
111+
fi
112+
else
113+
log_info "No RPMSG control channel for '$FW' found; skipping ping"
114+
fi
115+
116+
release_test_lock
117+
summary_report "$TESTNAME" remoteproc $((end_stop-start_stop)) $((end_start-start_start)) $rpmsg_res
118+
119+
log_pass "All ADSP checks passed"
120+
echo "${TESTNAME} PASS" >"$RES_FILE"
71121
exit 0
72-

Runner/suites/Kernel/Baseport/cdsp_remoteproc/run.sh

Lines changed: 158 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
44
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
56
# Robustly find and source init_env
67
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
78
INIT_ENV=""
@@ -29,44 +30,173 @@ fi
2930
. "$TOOLS/functestlib.sh"
3031

3132
TESTNAME="cdsp_remoteproc"
32-
firmware_name="cdsp"
33-
res_file="./$TESTNAME.res"
34-
LOG_FILE="./$TESTNAME.log"
33+
RES_FILE="./$TESTNAME.res"
34+
FW="cdsp"
3535

3636
test_path=$(find_test_case_by_name "$TESTNAME")
3737
cd "$test_path" || exit 1
3838

3939
log_info "-----------------------------------------------------------------------------------------"
4040
log_info "------------------- Starting $TESTNAME Testcase ----------------------------"
4141
log_info "=== Test Initialization ==="
42-
43-
if ! validate_remoteproc_running "$firmware_name" "$LOG_FILE" 15 2; then
44-
log_fail "$firmware_name remoteproc is not in running state after bootup"
45-
echo "$TESTNAME FAIL" > "$res_file"
42+
log_info "DEBUG: STOP_TO=$STOP_TO, START_TO=$START_TO, POLL_I=$POLL_I"
43+
44+
# Timeouts & polling (override via env)
45+
STOP_TO=${STOP_TO:-10}
46+
START_TO=${START_TO:-10}
47+
POLL_I=${POLL_I:-1}
48+
49+
fail() {
50+
log_fail "$1"
51+
printf '%s\n' "${TESTNAME} FAIL" >"$RES_FILE"
52+
release_test_lock
4653
exit 1
54+
}
55+
56+
acquire_test_lock "$TESTNAME"
57+
58+
entries=$(get_remoteproc_by_firmware "$FW") || entries=''
59+
log_info "DEBUG: raw entries='$entries'"
60+
61+
count=$(printf '%s\n' "$entries" | grep -c .)
62+
log_info "Found $count instance(s) for firmware '$FW'"
63+
64+
if [ "$count" -eq 0 ]; then
65+
log_skip "$TESTNAME SKIP – $FW unsupported on this SoC"
66+
printf '%s\n' "${TESTNAME} SKIP" >"$RES_FILE"
67+
release_test_lock
68+
exit 0
4769
fi
70+
71+
overall_fail=0
72+
summary_lines=""
73+
74+
OLDIFS=$IFS
75+
IFS='
76+
'
77+
for ent in $entries; do
78+
IFS=$OLDIFS
79+
rpath=$(printf '%s\n' "$ent" | awk '{print $1}')
80+
rstate=$(printf '%s\n' "$ent" | awk '{print $2}')
81+
inst=$(basename "$rpath")
82+
83+
log_info "---- $inst: path=$rpath state=$rstate ----"
84+
85+
boot_stat="PASS"
86+
stop_stat="SKIPPED"
87+
start_stat="SKIPPED"
88+
ping_stat="SKIPPED"
89+
90+
# Boot check
91+
if [ "$rstate" != running ]; then
92+
log_fail "$inst: boot check FAILED (state=$rstate)"
93+
boot_stat="FAIL"
94+
overall_fail=1
95+
summary_lines="${summary_lines}${inst}: boot=${boot_stat}\n"
96+
continue
97+
fi
98+
log_pass "$inst: boot check PASS"
99+
100+
# Stop
101+
dump_rproc_logs "$rpath" before-stop
102+
t0=$(date +%s)
103+
log_info "$inst: stopping"
104+
if stop_remoteproc "$rpath"; then
105+
if wait_remoteproc_state "$rpath" offline "$STOP_TO" "$POLL_I"; then
106+
t1=$(date +%s)
107+
stop_stat="PASS"
108+
log_pass "$inst: stop PASS ($((t1-t0))s)"
109+
else
110+
log_fail "$inst: stop TIMEOUT"
111+
stop_stat="FAIL"
112+
overall_fail=1
113+
fi
114+
else
115+
log_fail "$inst: stop command FAILED"
116+
stop_stat="FAIL"
117+
overall_fail=1
118+
fi
119+
dump_rproc_logs "$rpath" after-stop
120+
121+
# Start
122+
dump_rproc_logs "$rpath" before-start
123+
t2=$(date +%s)
124+
log_info "$inst: starting"
125+
if start_remoteproc "$rpath"; then
126+
if wait_remoteproc_state "$rpath" running "$START_TO" "$POLL_I"; then
127+
t3=$(date +%s)
128+
start_stat="PASS"
129+
log_pass "$inst: start PASS ($((t3-t2))s)"
130+
else
131+
log_fail "$inst: start TIMEOUT"
132+
start_stat="FAIL"
133+
overall_fail=1
134+
fi
135+
else
136+
log_fail "$inst: start command FAILED"
137+
start_stat="FAIL"
138+
overall_fail=1
139+
fi
140+
dump_rproc_logs "$rpath" after-start
141+
142+
# Optional RPMsg ping (using your helper if present)
143+
ping_stat="SKIPPED"
48144

49-
log_pass "$firmware_name remoteproc validated as running"
50-
51-
rproc_path=$(get_remoteproc_path_by_firmware "$firmware_name")
52-
53-
stop_remoteproc "$rproc_path" || {
54-
log_fail "$TESTNAME stop failed"
55-
echo "$TESTNAME FAIL" > "$res_file"
56-
exit 1
57-
}
58-
log_pass "$firmware_name stop successful"
145+
# Map this instance's rproc path -> ctrl sysfs
146+
ctrl_sys=$(find_rpmsg_ctrl_for_rproc "$rpath" 2>/dev/null) || ctrl_sys=""
147+
if [ -n "$ctrl_sys" ]; then
148+
log_info "$inst: found ctrl sysfs: $ctrl_sys"
149+
ctrl_dev=$(rpmsg_sys_to_dev "$ctrl_sys") || ctrl_dev=""
150+
if [ -n "$ctrl_dev" ]; then
151+
# Try existing endpoints first
152+
data_nodes=$(find_rpmsg_data_for_rproc "$rpath" 2>/dev/null) || data_nodes=""
153+
if [ -z "$data_nodes" ]; then
154+
log_info "$inst: no data endpoints; creating one generically"
155+
data_nodes=$(rpmsg_create_ep_generic "$ctrl_sys") || data_nodes=""
156+
fi
59157

60-
log_info "Restarting $firmware_name"
61-
start_remoteproc "$rproc_path" || {
62-
log_fail "$TESTNAME start failed"
63-
echo "$TESTNAME FAIL" > "$res_file"
158+
if [ -n "$data_nodes" ]; then
159+
for dn in $data_nodes; do
160+
log_info "$inst: trying RPMsg echo on $dn"
161+
if rpmsg_try_echo "$dn"; then
162+
log_pass "$inst: RPMsg activity detected on $dn"
163+
ping_stat="PASS"
164+
break
165+
fi
166+
done
167+
[ "$ping_stat" = "PASS" ] || {
168+
log_warn "$inst: no RPMsg reply on any endpoint"
169+
ping_stat="FAIL"
170+
overall_fail=1
171+
}
172+
else
173+
log_info "$inst: failed to create/find rpmsg data node"
174+
fi
175+
else
176+
log_info "$inst: cannot build /dev for ctrl; skipping"
177+
fi
178+
else
179+
log_info "$inst: no rpmsg_ctrl mapped to this rproc; skipping RPMsg"
180+
fi
181+
182+
summary_lines="${summary_lines}${inst}: boot=${boot_stat}, stop=${stop_stat}, start=${start_stat}, ping=${ping_stat}\n"
183+
done
184+
IFS=$OLDIFS
185+
186+
release_test_lock
187+
188+
log_info "Instance results:"
189+
printf '%b' "$summary_lines" | while IFS= read -r line; do
190+
[ -n "$line" ] && log_info " $line"
191+
done
192+
193+
if [ "$overall_fail" -ne 0 ]; then
194+
log_fail "One or more CDSP instances failed"
195+
printf '%s\n' "${TESTNAME} FAIL" >"$RES_FILE"
64196
exit 1
65-
}
66-
67-
log_pass "$firmware_name PASS"
68-
echo "$TESTNAME PASS" > "$res_file"
69-
70-
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"
197+
fi
198+
199+
log_pass "All $count CDSP instances passed"
200+
printf '%s\n' "${TESTNAME} PASS" >"$RES_FILE"
71201
exit 0
72-
202+

0 commit comments

Comments
 (0)