Skip to content

Commit 994f626

Browse files
committed
Modularized adsp, cdsp, and wpss remoteproc tests using common helper functions.
Refactored adsp, cdsp, and wpss remoteproc tests. Introduced modular helper usage and standardized logging. Signed-off-by: Sai-teja573 <[email protected]>
1 parent 8e078f4 commit 994f626

File tree

4 files changed

+805
-157
lines changed

4 files changed

+805
-157
lines changed

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

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

33
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
44
# SPDX-License-Identifier: BSD-3-Clause-Clear
5-
65
# Robustly find and source init_env
76
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
87
INIT_ENV=""
@@ -14,12 +13,12 @@ while [ "$SEARCH" != "/" ]; do
1413
fi
1514
SEARCH=$(dirname "$SEARCH")
1615
done
17-
16+
1817
if [ -z "$INIT_ENV" ]; then
1918
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
2019
exit 1
2120
fi
22-
21+
2322
# Only source if not already loaded (idempotent)
2423
if [ -z "$__INIT_ENV_LOADED" ]; then
2524
# shellcheck disable=SC1090
@@ -28,65 +27,46 @@ fi
2827
# Always source functestlib.sh, using $TOOLS exported by init_env
2928
# shellcheck disable=SC1090,SC1091
3029
. "$TOOLS/functestlib.sh"
31-
30+
3231
TESTNAME="adsp_remoteproc"
32+
firmware_name="adsp"
33+
res_file="./$TESTNAME.res"
34+
LOG_FILE="./$TESTNAME.log"
35+
36+
exec > >(tee -a "$LOG_FILE") 2>&1
37+
3338
test_path=$(find_test_case_by_name "$TESTNAME")
3439
cd "$test_path" || exit 1
35-
# shellcheck disable=SC2034
36-
res_file="./$TESTNAME.res"
37-
40+
3841
log_info "-----------------------------------------------------------------------------------------"
3942
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
40-
log_info "=== Test Initialization ==="
41-
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)
55-
56-
if [ "$state1" != "running" ]; then
57-
log_fail "$TESTNAME : Test Failed"
58-
echo "$TESTNAME FAIL" > "$test_path/$TESTNAME.res"
43+
44+
if ! validate_remoteproc_running "$firmware_name" "$LOG_FILE" 15 2; then
45+
log_fail "$firmware_name remoteproc is not in running state after bootup"
46+
echo "$TESTNAME FAIL" > "$res_file"
5947
exit 1
6048
fi
61-
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"
49+
50+
log_pass "$firmware_name remoteproc validated as running"
51+
52+
rproc_path=$(get_remoteproc_path_by_firmware "$firmware_name")
53+
54+
stop_remoteproc "$rproc_path" || {
55+
log_fail "$TESTNAME stop failed"
56+
echo "$TESTNAME FAIL" > "$res_file"
7157
exit 1
72-
else
73-
log_pass "adsp stop successful"
74-
fi
58+
}
59+
log_pass "$firmware_name stop successful"
60+
7561
log_info "Restarting remoteproc"
76-
# Execute command 4 (no output expected)
77-
echo start > ${remoteproc_path}/state
78-
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"
62+
start_remoteproc "$rproc_path" || {
63+
log_fail "$TESTNAME start failed"
64+
echo "$TESTNAME FAIL" > "$res_file"
8465
exit 1
85-
fi
86-
87-
# If all checks pass, print "PASS"
88-
echo "adsp PASS"
89-
log_pass "adsp PASS"
66+
}
67+
68+
log_pass "$firmware_name PASS"
9069
echo "$TESTNAME PASS" > "$res_file"
9170
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
9271
exit 0
72+

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

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

33
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
44
# SPDX-License-Identifier: BSD-3-Clause-Clear
5-
65
# Robustly find and source init_env
76
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
87
INIT_ENV=""
@@ -28,63 +27,46 @@ fi
2827
# Always source functestlib.sh, using $TOOLS exported by init_env
2928
# shellcheck disable=SC1090,SC1091
3029
. "$TOOLS/functestlib.sh"
31-
30+
3231
TESTNAME="cdsp_remoteproc"
32+
firmware_name="cdsp"
33+
res_file="./$TESTNAME.res"
34+
LOG_FILE="./$TESTNAME.log"
35+
36+
exec > >(tee -a "$LOG_FILE") 2>&1
37+
3338
test_path=$(find_test_case_by_name "$TESTNAME")
3439
cd "$test_path" || exit 1
35-
# shellcheck disable=SC2034
36-
res_file="./$TESTNAME.res"
37-
40+
3841
log_info "-----------------------------------------------------------------------------------------"
3942
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
40-
log_info "=== Test Initialization ==="
41-
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}"
52-
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
43+
44+
if ! validate_remoteproc_running "$firmware_name" "$LOG_FILE" 15 2; then
45+
log_fail "$firmware_name remoteproc is not in running state after bootup"
46+
echo "$TESTNAME FAIL" > "$res_file"
5847
exit 1
5948
fi
60-
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
49+
50+
log_pass "$firmware_name remoteproc validated as running"
51+
52+
rproc_path=$(get_remoteproc_path_by_firmware "$firmware_name")
53+
54+
stop_remoteproc "$rproc_path" || {
55+
log_fail "$TESTNAME stop failed"
56+
echo "$TESTNAME FAIL" > "$res_file"
6957
exit 1
70-
else
71-
log_pass "cdsp stop successful"
72-
fi
58+
}
59+
log_pass "$firmware_name stop successful"
60+
7361
log_info "Restarting remoteproc"
74-
# Execute command 4 (no output expected)
75-
echo start > ${remoteproc_path}/state
76-
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"
62+
start_remoteproc "$rproc_path" || {
63+
log_fail "$TESTNAME start failed"
8164
echo "$TESTNAME FAIL" > "$res_file"
8265
exit 1
83-
fi
84-
85-
# If all checks pass, print "PASS"
86-
echo "cdsp PASS"
87-
log_pass "cdsp PASS"
88-
echo "$TESTNAME PASS" > "$res_file"
66+
}
67+
68+
log_pass "$firmware_name PASS"
69+
echo "$TESTNAME PASS" > "$res_file"
8970
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
9071
exit 0
72+

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

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

33
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
44
# SPDX-License-Identifier: BSD-3-Clause-Clear
5-
65
# Robustly find and source init_env
76
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
87
INIT_ENV=""
@@ -14,12 +13,12 @@ while [ "$SEARCH" != "/" ]; do
1413
fi
1514
SEARCH=$(dirname "$SEARCH")
1615
done
17-
16+
1817
if [ -z "$INIT_ENV" ]; then
1918
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
2019
exit 1
2120
fi
22-
21+
2322
# Only source if not already loaded (idempotent)
2423
if [ -z "$__INIT_ENV_LOADED" ]; then
2524
# shellcheck disable=SC1090
@@ -28,71 +27,46 @@ fi
2827
# Always source functestlib.sh, using $TOOLS exported by init_env
2928
# shellcheck disable=SC1090,SC1091
3029
. "$TOOLS/functestlib.sh"
31-
30+
3231
TESTNAME="wpss_remoteproc"
32+
firmware_name="wpss"
33+
res_file="./$TESTNAME.res"
34+
LOG_FILE="./$TESTNAME.log"
35+
36+
exec > >(tee -a "$LOG_FILE") 2>&1
37+
3338
test_path=$(find_test_case_by_name "$TESTNAME")
3439
cd "$test_path" || exit 1
35-
# shellcheck disable=SC2034
36-
res_file="./$TESTNAME.res"
37-
40+
3841
log_info "-----------------------------------------------------------------------------------------"
3942
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
40-
log_info "=== Test Initialization ==="
41-
42-
log_info "=== Detecting and validating WPSS remoteproc instance ==="
4343

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"
57-
echo "$TESTNAME SKIP" > "$res_file"
58-
exit 0
44+
if ! validate_remoteproc_running "$firmware_name" "$LOG_FILE" 15 2; then
45+
log_fail "$firmware_name remoteproc is not in running state after bootup"
46+
echo "$TESTNAME FAIL" > "$res_file"
47+
exit 1
5948
fi
6049

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"
50+
log_pass "$firmware_name remoteproc validated as running"
6451

65-
# Capture state before any change
66-
orig_state=$(cat "$wpss_path/state" 2>/dev/null)
67-
log_info "Original state: $orig_state"
52+
rproc_path=$(get_remoteproc_path_by_firmware "$firmware_name")
6853

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"
78-
fi
54+
stop_remoteproc "$rproc_path" || {
55+
log_fail "$TESTNAME stop failed"
56+
echo "$TESTNAME FAIL" > "$res_file"
57+
exit 1
58+
}
59+
log_pass "$firmware_name stop successful"
7960

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-
exit 0
88-
else
89-
log_fail "WPSS remoteproc failed to start, state: $final_state"
90-
echo "$TESTNAME FAIL" > "$res_file"
91-
exit 1
92-
fi
93-
else
94-
log_fail "Failed to write 'start' to $wpss_path/state"
61+
log_info "Restarting remoteproc"
62+
start_remoteproc "$rproc_path" || {
63+
log_fail "$TESTNAME start failed"
9564
echo "$TESTNAME FAIL" > "$res_file"
9665
exit 1
97-
fi
66+
}
67+
68+
log_pass "$firmware_name PASS"
69+
echo "$TESTNAME PASS" > "$res_file"
9870
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
71+
exit 0
72+

0 commit comments

Comments
 (0)