Skip to content

Fix for WPSS Remoteproc test #64

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

Merged
merged 1 commit into from
Jun 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 75 additions & 40 deletions Runner/suites/Kernel/FunctionalArea/baseport/wpss_remoteproc/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# Robustly find and source init_env
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INIT_ENV=""
SEARCH="$SCRIPT_DIR"
while [ "$SEARCH" != "/" ]; do
if [ -f "$SEARCH/init_env" ]; then
INIT_ENV="$SEARCH/init_env"
break
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
. "$INIT_ENV"
fi
# Always source functestlib.sh, using $TOOLS exported by init_env
# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"

TESTNAME="wpss_remoteproc"
test_path=$(find_test_case_by_name "$TESTNAME")
cd "$test_path" || exit 1
Expand All @@ -13,50 +39,59 @@ log_info "----------------------------------------------------------------------
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
log_info "=== Test Initialization ==="

# Get the firmware output and find the position of wpss
firmware_output=$(cat /sys/class/remoteproc/remoteproc*/firmware)
wpss_position=$(echo "$firmware_output" | grep -n "wpss" | cut -d: -f1)

# Adjust the position to match the remoteproc numbering (starting from 0)
remoteproc_number=$((wpss_position - 1))

# Construct the remoteproc path based on the wpss position
remoteproc_path="/sys/class/remoteproc/remoteproc${remoteproc_number}"

# 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
exit 1
log_info "=== Detecting and validating WPSS remoteproc instance ==="

log_info "Looking for remoteproc device exposing WPSS..."
wpss_path=""
for node in /sys/class/remoteproc/remoteproc*; do
[ -f "$node/name" ] || continue
name=$(cat "$node/name" 2>/dev/null | tr '[:upper:]' '[:lower:]')
if echo "$name" | grep -qi "wpss"; then
wpss_path="$node"
break
fi
done

if [ -z "$wpss_path" ]; then
log_skip "WPSS remoteproc node not found"
echo "$TESTNAME SKIP" > "$res_file"
exit 0
fi

# Execute command 2 (no output expected)
echo stop > ${remoteproc_path}/state

# Execute command 3 and check if the output is "offline"
state3=$(cat ${remoteproc_path}/state)
if [ "$state3" != "offline" ]; then
log_fail "wpss stop failed"
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
exit 1

log_info "Found WPSS remoteproc node at: $wpss_path"
firmware=$(cat "$wpss_path/firmware" 2>/dev/null)
log_info "WPSS firmware: $firmware"

# Capture state before any change
orig_state=$(cat "$wpss_path/state" 2>/dev/null)
log_info "Original state: $orig_state"

log_info "Attempting to stop WPSS..."
if echo stop > "$wpss_path/state" 2>/dev/null; then
sleep 1
new_state=$(cat "$wpss_path/state" 2>/dev/null)
if [ "$new_state" != "offline" ]; then
log_warn "Expected offline state after stop, got: $new_state"
fi
else
log_pass "wpss stop successful"
log_warn "Could not stop WPSS; may already be offline"
fi

# Execute command 4 (no output expected)
echo start > ${remoteproc_path}/state

# Execute command 5 and check if the output is "running"
state5=$(cat ${remoteproc_path}/state)
if [ "$state5" != "running" ]; then
log_fail "wpss start failed"

log_info "Attempting to start WPSS..."
if echo start > "$wpss_path/state" 2>/dev/null; then
sleep 1
final_state=$(cat "$wpss_path/state" 2>/dev/null)
if [ "$final_state" = "running" ]; then
log_pass "WPSS remoteproc started successfully"
echo "$TESTNAME PASS" > "$res_file"
else
log_fail "WPSS remoteproc failed to start, state: $final_state"
echo "$TESTNAME FAIL" > "$res_file"
exit 1
fi
else
log_fail "Failed to write 'start' to $wpss_path/state"
echo "$TESTNAME FAIL" > "$res_file"
exit 1
fi

# If all checks pass, print "PASS"
echo "wpss PASS"
log_pass "wpss PASS"
echo "$TESTNAME PASS" > "$res_file"
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Loading