-
Notifications
You must be signed in to change notification settings - Fork 17
Modularized adsp, cdsp, and wpss remoteproc tests using common helper functions #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,12 @@ while [ "$SEARCH" != "/" ]; do | |
fi | ||
SEARCH=$(dirname "$SEARCH") | ||
done | ||
|
||
if [ -z "$INIT_ENV" ]; then | ||
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Only source if not already loaded (idempotent) | ||
if [ -z "$__INIT_ENV_LOADED" ]; then | ||
# shellcheck disable=SC1090 | ||
|
@@ -30,61 +30,43 @@ fi | |
. "$TOOLS/functestlib.sh" | ||
|
||
TESTNAME="adsp_remoteproc" | ||
res_file="./$TESTNAME.res" | ||
test_path=$(find_test_case_by_name "$TESTNAME") | ||
cd "$test_path" || exit 1 | ||
# shellcheck disable=SC2034 | ||
res_file="./$TESTNAME.res" | ||
|
||
log_info "-----------------------------------------------------------------------------------------" | ||
log_info "-------------------Starting $TESTNAME Testcase----------------------------" | ||
log_info "=== Test Initialization ===" | ||
log_info "Get the firmware output and find the position of adsp" | ||
|
||
# Get the firmware output and find the position of adsp | ||
log_info "Checking for firmware" | ||
firmware_output=$(cat /sys/class/remoteproc/remoteproc*/firmware) | ||
adsp_position=$(echo "$firmware_output" | grep -n "adsp" | cut -d: -f1) | ||
|
||
# Adjust the position to match the remoteproc numbering (starting from 0) | ||
remoteproc_number=$((adsp_position - 1)) | ||
|
||
# Construct the remoteproc path based on the adsp position | ||
remoteproc_path="/sys/class/remoteproc/remoteproc${remoteproc_number}" | ||
log_info "Remoteproc node is $remoteproc_path" | ||
# Execute command 1 and check if the output is "running" | ||
state1=$(cat ${remoteproc_path}/state) | ||
|
||
if [ "$state1" != "running" ]; then | ||
log_fail "$TESTNAME : Test Failed" | ||
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res" | ||
rproc_path=$(get_remoteproc_path_by_firmware "adsp") || { | ||
log_fail "$TESTNAME" "adsp remoteproc path not found" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
exit 1 | ||
fi | ||
} | ||
log_info "Found adsp remoteproc: $rproc_path" | ||
|
||
# Execute command 2 (no output expected) | ||
log_info "Stopping remoteproc" | ||
echo stop > ${remoteproc_path}/state | ||
state=$(get_remoteproc_state "$rproc_path") | ||
[ "$state" = "running" ] || { | ||
log_fail "$TESTNAME" "adsp remoteproc not running" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about adding logs or checks to confirm if the firmware loads when a particular subsystem isn’t running? This could help with debugging in CI. |
||
exit 1 | ||
} | ||
|
||
# Execute command 3 and check if the output is "offline" | ||
state3=$(cat ${remoteproc_path}/state) | ||
if [ "$state3" != "offline" ]; then | ||
log_fail "adsp stop failed" | ||
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res" | ||
stop_remoteproc "$rproc_path" || { | ||
log_fail "$TESTNAME" "adsp remoteproc stop failed" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
exit 1 | ||
else | ||
log_pass "adsp stop successful" | ||
fi | ||
log_info "Restarting remoteproc" | ||
# Execute command 4 (no output expected) | ||
echo start > ${remoteproc_path}/state | ||
} | ||
log_pass "adsp stop successful" | ||
|
||
# Execute command 5 and check if the output is "running" | ||
state5=$(cat ${remoteproc_path}/state) | ||
if [ "$state5" != "running" ]; then | ||
log_fail "adsp start failed" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
log_info "Restarting remoteproc" | ||
start_remoteproc "$rproc_path" || { | ||
log_fail "$TESTNAME" "adsp remoteproc start failed" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# If all checks pass, print "PASS" | ||
echo "adsp PASS" | ||
log_pass "adsp PASS" | ||
echo "$TESTNAME PASS" > "$res_file" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -391,3 +391,51 @@ weston_start() { | |
fi | ||
} | ||
|
||
# Find the remoteproc path for a given firmware substring (e.g., "adsp", "cdsp", "gdsp"). | ||
get_remoteproc_path_by_firmware() { | ||
name="$1" | ||
local idx path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace |
||
# List all remoteproc firmware nodes, match name, and return the remoteproc path | ||
idx=$(cat /sys/class/remoteproc/remoteproc*/firmware 2>/dev/null | grep -n "$name" | cut -d: -f1 | head -n1) | ||
[ -z "$idx" ] && return 1 | ||
idx=$((idx - 1)) | ||
path="/sys/class/remoteproc/remoteproc${idx}" | ||
[ -d "$path" ] && echo "$path" && return 0 | ||
return 1 | ||
} | ||
|
||
# Get current remoteproc state | ||
get_remoteproc_state() { | ||
rproc_path="$1" | ||
[ -f "$rproc_path/state" ] && cat "$rproc_path/state" | ||
} | ||
|
||
# Wait until remoteproc reaches a given state (with retries) | ||
wait_remoteproc_state() { | ||
rproc_path="$1" | ||
target="$2" | ||
retries="${3:-6}" | ||
i=0 | ||
while [ $i -lt "$retries" ]; do | ||
state=$(get_remoteproc_state "$rproc_path") | ||
[ "$state" = "$target" ] && return 0 | ||
sleep 1 | ||
i=$((i+1)) | ||
done | ||
return 1 | ||
} | ||
|
||
# Stop remoteproc (wait for "offline") | ||
stop_remoteproc() { | ||
rproc_path="$1" | ||
echo stop > "$rproc_path/state" | ||
wait_remoteproc_state "$rproc_path" "offline" 6 | ||
} | ||
|
||
# Start remoteproc (wait for "running") | ||
start_remoteproc() { | ||
rproc_path="$1" | ||
echo start > "$rproc_path/state" | ||
wait_remoteproc_state "$rproc_path" "running" 6 | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s better to mark this as info and skip the test, rather than fail it. Since the node isn’t present, further validation isn’t needed. If any additional steps fail, then it would make sense to mark it as a failure.