Skip to content

Commit 578e1b3

Browse files
authored
Merge pull request qualcomm-linux#130 from smuppand/rproc
baseport/remoteproc: Make ADSP/CDSP/GPDSP/WPSS tests SoC-aware, add RPMsg probe, harden logs & shellcheck
2 parents cd5d00b + 6202cbb commit 578e1b3

File tree

5 files changed

+924
-128
lines changed

5 files changed

+924
-128
lines changed

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

Lines changed: 127 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,139 @@ 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
41+
42+
# Tunables
43+
STOP_TO="${STOP_TO:-10}"
44+
START_TO="${START_TO:-10}"
45+
POLL_I="${POLL_I:-1}"
46+
47+
log_info "DEBUG: STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I"
48+
49+
# DT check for entries
50+
if dt_has_remoteproc_fw "$FW"; then
51+
log_info "DT indicates $FW is present"
52+
else
53+
log_skip "$TESTNAME SKIP – $FW not described in DT"
54+
echo "$TESTNAME SKIP" >"$RES_FILE"
55+
exit 0
4756
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"
57+
58+
# Enumerate ADSP remoteproc entries
59+
# get_remoteproc_by_firmware prints: "path|state|firmware|name"
60+
entries="$(get_remoteproc_by_firmware "$FW" "" all)" || entries=""
61+
if [ -z "$entries" ]; then
62+
fail_and_exit "$FW present in DT but no /sys/class/remoteproc entry found"
63+
fi
64+
65+
count_instances=$(printf '%s\n' "$entries" | wc -l)
66+
log_info "Found $count_instances $FW instance(s)"
67+
68+
inst_fail=0
69+
RESULT_LINES=""
70+
71+
tmp_list="$(mktemp)"
72+
printf '%s\n' "$entries" >"$tmp_list"
73+
74+
while IFS='|' read -r rpath rstate rfirm rname; do
75+
[ -n "$rpath" ] || continue
76+
77+
inst_id="$(basename "$rpath")"
78+
log_info "---- $inst_id: path=$rpath state=$rstate firmware=$rfirm name=$rname ----"
79+
80+
boot_res="PASS"
81+
stop_res="NA"
82+
start_res="NA"
83+
ping_res="SKIPPED"
84+
85+
# Boot check
86+
if [ "$rstate" = "running" ]; then
87+
log_pass "$inst_id: boot check PASS"
88+
else
89+
log_fail "$inst_id: boot check FAIL (state=$rstate)"
90+
boot_res="FAIL"
91+
inst_fail=$((inst_fail + 1))
92+
RESULT_LINES="$RESULT_LINES
93+
$inst_id: boot=$boot_res, stop=$stop_res, start=$start_res, ping=$ping_res"
94+
continue
95+
fi
96+
97+
# Stop
98+
dump_rproc_logs "$rpath" before-stop
99+
t0=$(date +%s)
100+
log_info "$inst_id: stopping"
101+
if stop_remoteproc "$rpath" && wait_remoteproc_state "$rpath" offline "$STOP_TO" "$POLL_I"; then
102+
t1=$(date +%s)
103+
log_pass "$inst_id: stop PASS ($((t1 - t0))s)"
104+
stop_res="PASS"
105+
else
106+
dump_rproc_logs "$rpath" after-stop-fail
107+
log_fail "$inst_id: stop FAIL"
108+
stop_res="FAIL"
109+
inst_fail=$((inst_fail + 1))
110+
RESULT_LINES="$RESULT_LINES
111+
$inst_id: boot=$boot_res, stop=$stop_res, start=$start_res, ping=$ping_res"
112+
continue
113+
fi
114+
dump_rproc_logs "$rpath" after-stop
115+
116+
# Start
117+
dump_rproc_logs "$rpath" before-start
118+
t2=$(date +%s)
119+
log_info "$inst_id: starting"
120+
if start_remoteproc "$rpath" && wait_remoteproc_state "$rpath" running "$START_TO" "$POLL_I"; then
121+
t3=$(date +%s)
122+
log_pass "$inst_id: start PASS ($((t3 - t2))s)"
123+
start_res="PASS"
124+
else
125+
dump_rproc_logs "$rpath" after-start-fail
126+
log_fail "$inst_id: start FAIL"
127+
start_res="FAIL"
128+
inst_fail=$((inst_fail + 1))
129+
RESULT_LINES="$RESULT_LINES
130+
$inst_id: boot=$boot_res, stop=$stop_res, start=$start_res, ping=$ping_res"
131+
continue
132+
fi
133+
dump_rproc_logs "$rpath" after-start
134+
135+
# Optional RPMsg ping
136+
if CTRL_DEV=$(find_rpmsg_ctrl_for "$FW"); then
137+
log_info "$inst_id: RPMsg ctrl dev: $CTRL_DEV"
138+
if rpmsg_ping_generic "$CTRL_DEV"; then
139+
log_pass "$inst_id: rpmsg ping PASS"
140+
ping_res="PASS"
141+
else
142+
log_warn "$inst_id: rpmsg ping FAIL"
143+
ping_res="FAIL"
144+
inst_fail=$((inst_fail + 1))
145+
fi
146+
else
147+
log_info "$inst_id: no RPMsg channel, skipping ping"
148+
fi
149+
150+
RESULT_LINES="$RESULT_LINES
151+
$inst_id: boot=$boot_res, stop=$stop_res, start=$start_res, ping=$ping_res"
152+
153+
done <"$tmp_list"
154+
rm -f "$tmp_list"
155+
156+
# Summary
157+
log_info "Instance results:$RESULT_LINES"
158+
159+
if [ "$inst_fail" -gt 0 ]; then
160+
log_fail "One or more $FW instance(s) failed ($inst_fail/$count_instances)"
161+
echo "$TESTNAME FAIL" >"$RES_FILE"
64162
exit 1
65-
}
66-
67-
log_pass "$firmware_name PASS"
68-
echo "$TESTNAME PASS" > "$res_file"
69-
70-
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"
163+
fi
164+
165+
log_pass "All $count_instances $FW instance(s) passed"
166+
echo "$TESTNAME PASS" >"$RES_FILE"
71167
exit 0
72-

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

Lines changed: 128 additions & 31 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,140 @@ 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"
46-
exit 1
42+
43+
# Timeouts (can be overridden via env)
44+
STOP_TO="${STOP_TO:-10}"
45+
START_TO="${START_TO:-10}"
46+
POLL_I="${POLL_I:-1}"
47+
48+
log_info "DEBUG: STOP_TO=$STOP_TO START_TO=$START_TO POLL_I=$POLL_I"
49+
50+
# --- Device Tree gate ----------------------------------------------------
51+
if dt_has_remoteproc_fw "$FW"; then
52+
log_info "DT indicates $FW is present"
53+
else
54+
log_skip "$TESTNAME SKIP – $FW not described in DT"
55+
echo "${TESTNAME} SKIP" >"$RES_FILE"
56+
exit 0
4757
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"
58+
59+
# ---------- Discover all matching remoteproc entries ----------
60+
# get_remoteproc_by_firmware prints: "path|state|firmware|name"
61+
entries="$(get_remoteproc_by_firmware "$FW" "" all)" || entries=""
62+
if [ -z "$entries" ]; then
63+
fail_and_exit "$FW present in DT but no /sys/class/remoteproc entry found"
64+
fi
65+
66+
count_instances=$(printf '%s\n' "$entries" | wc -l)
67+
log_info "Found $count_instances $FW instance(s)"
68+
69+
inst_fail=0
70+
RESULT_LINES=""
71+
72+
# Avoid subshell var-scope issues: feed loop from a temp file
73+
tmp_list="$(mktemp)"
74+
printf '%s\n' "$entries" >"$tmp_list"
75+
76+
while IFS='|' read -r rpath rstate rfirm rname; do
77+
[ -n "$rpath" ] || continue # safety
78+
79+
inst_id="$(basename "$rpath")"
80+
log_info "---- $inst_id: path=$rpath state=$rstate firmware=$rfirm name=$rname ----"
81+
82+
boot_res="PASS"
83+
stop_res="NA"
84+
start_res="NA"
85+
ping_res="SKIPPED"
86+
87+
# Boot check
88+
if [ "$rstate" = "running" ]; then
89+
log_pass "$inst_id: boot check PASS"
90+
else
91+
log_fail "$inst_id: boot check FAIL (state=$rstate)"
92+
boot_res="FAIL"
93+
inst_fail=$((inst_fail + 1))
94+
RESULT_LINES="$RESULT_LINES
95+
$inst_id: boot=$boot_res, stop=$stop_res, start=$start_res, ping=$ping_res"
96+
continue
97+
fi
98+
99+
# Stop
100+
dump_rproc_logs "$rpath" before-stop
101+
t0=$(date +%s)
102+
log_info "$inst_id: stopping"
103+
if stop_remoteproc "$rpath" && wait_remoteproc_state "$rpath" offline "$STOP_TO" "$POLL_I"; then
104+
t1=$(date +%s)
105+
log_pass "$inst_id: stop PASS ($((t1 - t0))s)"
106+
stop_res="PASS"
107+
else
108+
dump_rproc_logs "$rpath" after-stop-fail
109+
log_fail "$inst_id: stop FAIL"
110+
stop_res="FAIL"
111+
inst_fail=$((inst_fail + 1))
112+
RESULT_LINES="$RESULT_LINES
113+
$inst_id: boot=$boot_res, stop=$stop_res, start=$start_res, ping=$ping_res"
114+
continue
115+
fi
116+
dump_rproc_logs "$rpath" after-stop
117+
118+
# Start
119+
dump_rproc_logs "$rpath" before-start
120+
t2=$(date +%s)
121+
log_info "$inst_id: starting"
122+
if start_remoteproc "$rpath" && wait_remoteproc_state "$rpath" running "$START_TO" "$POLL_I"; then
123+
t3=$(date +%s)
124+
log_pass "$inst_id: start PASS ($((t3 - t2))s)"
125+
start_res="PASS"
126+
else
127+
dump_rproc_logs "$rpath" after-start-fail
128+
log_fail "$inst_id: start FAIL"
129+
start_res="FAIL"
130+
inst_fail=$((inst_fail + 1))
131+
RESULT_LINES="$RESULT_LINES
132+
$inst_id: boot=$boot_res, stop=$stop_res, start=$start_res, ping=$ping_res"
133+
continue
134+
fi
135+
dump_rproc_logs "$rpath" after-start
136+
137+
# Optional RPMsg ping
138+
if CTRL_DEV=$(find_rpmsg_ctrl_for "$FW"); then
139+
log_info "$inst_id: RPMsg ctrl dev: $CTRL_DEV"
140+
if rpmsg_ping_generic "$CTRL_DEV"; then
141+
log_pass "$inst_id: rpmsg ping PASS"
142+
ping_res="PASS"
143+
else
144+
log_warn "$inst_id: rpmsg ping FAIL"
145+
ping_res="FAIL"
146+
inst_fail=$((inst_fail + 1))
147+
fi
148+
else
149+
log_info "$inst_id: no RPMsg channel, skipping ping"
150+
fi
151+
152+
RESULT_LINES="$RESULT_LINES
153+
$inst_id: boot=$boot_res, stop=$stop_res, start=$start_res, ping=$ping_res"
154+
155+
done <"$tmp_list"
156+
rm -f "$tmp_list"
157+
158+
# ---------- Summary ----------
159+
log_info "Instance results:$RESULT_LINES"
160+
161+
if [ "$inst_fail" -gt 0 ]; then
162+
log_fail "One or more $FW instance(s) failed ($inst_fail/$count_instances)"
163+
echo "$TESTNAME FAIL" >"$RES_FILE"
64164
exit 1
65-
}
66-
67-
log_pass "$firmware_name PASS"
68-
echo "$TESTNAME PASS" > "$res_file"
69-
70-
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"
165+
fi
166+
167+
log_pass "All $count_instances $FW instance(s) passed"
168+
echo "$TESTNAME PASS" >"$RES_FILE"
71169
exit 0
72-

0 commit comments

Comments
 (0)