Skip to content

Commit 072ab10

Browse files
committed
Add modular remoteproc test scripts and subsystem support
Includes run.sh scripts for generic remoteproc, CDSP, ADSP, and WPSS validation with enhanced logging and CI-friendly reporting. Common helper functions added to functestlib.sh for reusability. Also fixes ShellCheck warnings (SC2126, SC2002). introvert.com Signed-off-by: Srikanth Muppandam <[email protected]>
1 parent d75bcd4 commit 072ab10

File tree

5 files changed

+209
-145
lines changed

5 files changed

+209
-145
lines changed

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

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,53 +39,37 @@ log_info "----------------------------------------------------------------------
3939
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
4040
log_info "=== Test Initialization ==="
4141

42-
# Get the firmware output and find the position of adsp
43-
log_info "Checking for firmware"
44-
firmware_output=$(cat /sys/class/remoteproc/remoteproc*/firmware)
45-
adsp_position=$(echo "$firmware_output" | grep -n "adsp" | cut -d: -f1)
46-
47-
# Adjust the position to match the remoteproc numbering (starting from 0)
48-
remoteproc_number=$((adsp_position - 1))
49-
50-
# Construct the remoteproc path based on the adsp position
51-
remoteproc_path="/sys/class/remoteproc/remoteproc${remoteproc_number}"
52-
log_info "Remoteproc node is $remoteproc_path"
53-
# Execute command 1 and check if the output is "running"
54-
state1=$(cat ${remoteproc_path}/state)
42+
rproc_path=$(find_remoteproc_node_by_name adsp)
43+
if [ -z "$rproc_path" ]; then
44+
log_skip "Remoteproc for adsp not found"
45+
echo "$TESTNAME SKIP" > "$res_file"
46+
exit 0
47+
fi
48+
log_info "Using remoteproc node: $rproc_path"
5549

56-
if [ "$state1" != "running" ]; then
57-
log_fail "$TESTNAME : Test Failed"
58-
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
50+
if ! check_remoteproc_state "$rproc_path" "running"; then
51+
log_fail "adsp not in 'running' state initially"
52+
echo "$TESTNAME FAIL" > "$res_file"
5953
exit 1
6054
fi
6155

62-
# Execute command 2 (no output expected)
63-
log_info "Stopping remoteproc"
64-
echo stop > ${remoteproc_path}/state
65-
66-
# Execute command 3 and check if the output is "offline"
67-
state3=$(cat ${remoteproc_path}/state)
68-
if [ "$state3" != "offline" ]; then
69-
log_fail "adsp stop failed"
70-
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
56+
log_info "Stopping adsp..."
57+
if ! stop_remoteproc "$rproc_path"; then
58+
log_fail "Failed to stop adsp"
59+
echo "$TESTNAME FAIL" > "$res_file"
7160
exit 1
7261
else
73-
log_pass "adsp stop successful"
62+
log_pass "adsp stopped successfully"
7463
fi
75-
log_info "Restarting remoteproc"
76-
# Execute command 4 (no output expected)
77-
echo start > ${remoteproc_path}/state
7864

79-
# Execute command 5 and check if the output is "running"
80-
state5=$(cat ${remoteproc_path}/state)
81-
if [ "$state5" != "running" ]; then
82-
log_fail "adsp start failed"
83-
echo "$TESTNAME FAIL" > "$res_file"
65+
log_info "Starting adsp..."
66+
if ! start_remoteproc "$rproc_path"; then
67+
log_fail "Failed to start adsp"
68+
echo "$TESTNAME FAIL" > "$res_file"
8469
exit 1
70+
else
71+
log_pass "adsp started successfully"
72+
echo "$TESTNAME PASS" > "$res_file"
8573
fi
8674

87-
# If all checks pass, print "PASS"
88-
echo "adsp PASS"
89-
log_pass "adsp PASS"
90-
echo "$TESTNAME PASS" > "$res_file"
91-
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
75+
log_info "------------------- Completed $TESTNAME -------------------"

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

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -39,51 +39,37 @@ log_info "----------------------------------------------------------------------
3939
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
4040
log_info "=== Test Initialization ==="
4141

42-
# Get the firmware output and find the position of cdsp
43-
log_info "Get the firmware output and find the position of cdsp"
44-
firmware_output=$(cat /sys/class/remoteproc/remoteproc*/firmware)
45-
cdsp_position=$(echo "$firmware_output" | grep -n "cdsp" | cut -d: -f1)
46-
47-
# Adjust the position to match the remoteproc numbering (starting from 0)
48-
remoteproc_number=$((cdsp_position - 1))
49-
50-
# Construct the remoteproc path based on the cdsp position
51-
remoteproc_path="/sys/class/remoteproc/remoteproc${remoteproc_number}"
42+
rproc_path=$(find_remoteproc_node_by_name cdsp)
43+
if [ -z "$rproc_path" ]; then
44+
log_skip "Remoteproc for cdsp not found"
45+
echo "$TESTNAME SKIP" > "$res_file"
46+
exit 0
47+
fi
48+
log_info "Using remoteproc node: $rproc_path"
5249

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

61-
# Execute command 2 (no output expected)
62-
echo stop > ${remoteproc_path}/state
63-
64-
# Execute command 3 and check if the output is "offline"
65-
state3=$(cat ${remoteproc_path}/state)
66-
if [ "$state3" != "offline" ]; then
67-
log_fail "cdsp stop failed"
68-
echo "$TESTNAME FAIL" > $test_path/$TESTNAME.res
56+
log_info "Stopping cdsp..."
57+
if ! stop_remoteproc "$rproc_path"; then
58+
log_fail "Failed to stop cdsp"
59+
echo "$TESTNAME FAIL" > "$res_file"
6960
exit 1
7061
else
71-
log_pass "cdsp stop successful"
62+
log_pass "cdsp stopped successfully"
7263
fi
73-
log_info "Restarting remoteproc"
74-
# Execute command 4 (no output expected)
75-
echo start > ${remoteproc_path}/state
7664

77-
# Execute command 5 and check if the output is "running"
78-
state5=$(cat ${remoteproc_path}/state)
79-
if [ "$state5" != "running" ]; then
80-
log_fail "cdsp start failed"
65+
log_info "Starting cdsp..."
66+
if ! start_remoteproc "$rproc_path"; then
67+
log_fail "Failed to start cdsp"
8168
echo "$TESTNAME FAIL" > "$res_file"
8269
exit 1
70+
else
71+
log_pass "cdsp started successfully"
72+
echo "$TESTNAME PASS" > "$res_file"
8373
fi
8474

85-
# If all checks pass, print "PASS"
86-
echo "cdsp PASS"
87-
log_pass "cdsp PASS"
88-
echo "$TESTNAME PASS" > "$res_file"
89-
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
75+
log_info "------------------- Completed $TESTNAME -------------------"

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

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,74 @@ cd "$test_path" || exit 1
3535
# shellcheck disable=SC2034
3636
res_file="./$TESTNAME.res"
3737

38+
log_info "------------------------------------------------------------------"
39+
log_info "------------------- Starting $TESTNAME Test -----------------------"
40+
log_info "Enumerating remoteproc subsystems..."
41+
42+
#!/bin/sh
43+
44+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
45+
# SPDX-License-Identifier: BSD-3-Clause-Clear
46+
47+
# Robustly find and source init_env
48+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
49+
INIT_ENV=""
50+
SEARCH="$SCRIPT_DIR"
51+
while [ "$SEARCH" != "/" ]; do
52+
if [ -f "$SEARCH/init_env" ]; then
53+
INIT_ENV="$SEARCH/init_env"
54+
break
55+
fi
56+
SEARCH=$(dirname "$SEARCH")
57+
done
58+
59+
if [ -z "$INIT_ENV" ]; then
60+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
61+
exit 1
62+
fi
63+
64+
# Only source if not already loaded (idempotent)
65+
if [ -z "$__INIT_ENV_LOADED" ]; then
66+
# shellcheck disable=SC1090
67+
. "$INIT_ENV"
68+
fi
69+
70+
# Always source functestlib.sh, using $TOOLS exported by init_env
71+
# shellcheck disable=SC1090,SC1091
72+
. "$TOOLS/functestlib.sh"
73+
74+
TESTNAME="remoteproc"
75+
test_path=$(find_test_case_by_name "$TESTNAME")
76+
cd "$test_path" || exit 1
77+
res_file="./$TESTNAME.res"
78+
3879
log_info "-----------------------------------------------------------------------------------------"
39-
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
80+
log_info "------------------- Starting $TESTNAME Testcase ----------------------------"
4081
log_info "=== Test Initialization ==="
4182

42-
log_info "Getting the number of subsystems aavailable"
83+
log_info "Collecting remoteproc firmware list..."
84+
firmware_output=$(cat /sys/class/remoteproc/remoteproc*/firmware 2>/dev/null)
4385

44-
available_rprocs=$(cat /sys/class/remoteproc/remoteproc*/firmware)
45-
46-
# Check if any line contains "modem"
47-
echo "$available_rprocs" | grep -q "modem"
48-
if [ $? -eq 0 ]; then
49-
subsystem_count=$(echo "$available_rprocs" | grep -v "modem" | wc -l)
50-
else
51-
# "modem" not found, count all lines
52-
subsystem_count=$(echo "$available_rprocs" | wc -l)
86+
if [ -z "$firmware_output" ]; then
87+
log_fail "No remoteproc firmware entries found"
88+
echo "$TESTNAME FAIL" > "$res_file"
89+
exit 1
5390
fi
5491

55-
# Execute the command and get the output
56-
log_info "Checking if all the remoteprocs are in running state"
57-
output=$(cat /sys/class/remoteproc/remoteproc*/state)
92+
log_info "Checking for modem exclusion in count..."
93+
expected=$(echo "$firmware_output" | grep -vc "modem")
94+
log_info "Expected remoteprocs (excluding modem): $expected"
5895

59-
# Count the number of "running" values
60-
count=$(echo "$output" | grep -c "running")
61-
log_info "rproc subsystems in running state : $count, expected subsystems : $subsystem_count"
96+
log_info "Checking current remoteproc state..."
97+
running=$(grep -h ^ /sys/class/remoteproc/remoteproc*/state 2>/dev/null | grep -c "running")
98+
log_info "Running remoteprocs: $running"
6299

63-
# Print overall test result
64-
if [ $count -eq $subsystem_count ]; then
65-
log_pass "$TESTNAME : Test Passed"
100+
if [ "$running" -eq "$expected" ]; then
101+
log_pass "$TESTNAME : Test Passed - all remoteprocs are running"
66102
echo "$TESTNAME PASS" > "$res_file"
67103
else
68-
log_fail "$TESTNAME : Test Failed"
104+
log_fail "$TESTNAME : Test Failed - expected $expected running, but got $running"
69105
echo "$TESTNAME FAIL" > "$res_file"
70106
fi
71-
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
107+
108+
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"

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

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -39,59 +39,37 @@ log_info "----------------------------------------------------------------------
3939
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
4040
log_info "=== Test Initialization ==="
4141

42-
log_info "=== Detecting and validating WPSS remoteproc instance ==="
43-
44-
log_info "Looking for remoteproc device exposing WPSS..."
45-
wpss_path=""
46-
for node in /sys/class/remoteproc/remoteproc*; do
47-
[ -f "$node/name" ] || continue
48-
name=$(cat "$node/name" 2>/dev/null | tr '[:upper:]' '[:lower:]')
49-
if echo "$name" | grep -qi "wpss"; then
50-
wpss_path="$node"
51-
break
52-
fi
53-
done
54-
55-
if [ -z "$wpss_path" ]; then
56-
log_skip "WPSS remoteproc node not found"
42+
rproc_path=$(find_remoteproc_node_by_name wpss)
43+
if [ -z "$rproc_path" ]; then
44+
log_skip "Remoteproc for wpss not found"
5745
echo "$TESTNAME SKIP" > "$res_file"
5846
exit 0
5947
fi
60-
61-
log_info "Found WPSS remoteproc node at: $wpss_path"
62-
firmware=$(cat "$wpss_path/firmware" 2>/dev/null)
63-
log_info "WPSS firmware: $firmware"
64-
65-
# Capture state before any change
66-
orig_state=$(cat "$wpss_path/state" 2>/dev/null)
67-
log_info "Original state: $orig_state"
68-
69-
log_info "Attempting to stop WPSS..."
70-
if echo stop > "$wpss_path/state" 2>/dev/null; then
71-
sleep 1
72-
new_state=$(cat "$wpss_path/state" 2>/dev/null)
73-
if [ "$new_state" != "offline" ]; then
74-
log_warn "Expected offline state after stop, got: $new_state"
75-
fi
76-
else
77-
log_warn "Could not stop WPSS; may already be offline"
48+
log_info "Using remoteproc node: $rproc_path"
49+
50+
if ! check_remoteproc_state "$rproc_path" "running"; then
51+
log_fail "wpss not in 'running' state initially"
52+
echo "$TESTNAME FAIL" > "$res_file"
53+
exit 1
7854
fi
79-
80-
log_info "Attempting to start WPSS..."
81-
if echo start > "$wpss_path/state" 2>/dev/null; then
82-
sleep 1
83-
final_state=$(cat "$wpss_path/state" 2>/dev/null)
84-
if [ "$final_state" = "running" ]; then
85-
log_pass "WPSS remoteproc started successfully"
86-
echo "$TESTNAME PASS" > "$res_file"
87-
else
88-
log_fail "WPSS remoteproc failed to start, state: $final_state"
89-
echo "$TESTNAME FAIL" > "$res_file"
90-
exit 1
91-
fi
55+
56+
log_info "Stopping wpss..."
57+
if ! stop_remoteproc "$rproc_path"; then
58+
log_fail "Failed to stop wpss"
59+
echo "$TESTNAME FAIL" > "$res_file"
60+
exit 1
9261
else
93-
log_fail "Failed to write 'start' to $wpss_path/state"
62+
log_pass "wpss stopped successfully"
63+
fi
64+
65+
log_info "Starting wpss..."
66+
if ! start_remoteproc "$rproc_path"; then
67+
log_fail "Failed to start wpss"
9468
echo "$TESTNAME FAIL" > "$res_file"
9569
exit 1
70+
else
71+
log_pass "wpss started successfully"
72+
echo "$TESTNAME PASS" > "$res_file"
9673
fi
97-
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
74+
75+
log_info "------------------- Completed $TESTNAME -------------------"

0 commit comments

Comments
 (0)