Skip to content

Commit 5f488f2

Browse files
authored
Merge pull request #110 from Sai-teja573/modularized
Modularized adsp, cdsp, and wpss remoteproc tests using common helper functions
2 parents 5baf561 + ecb15a5 commit 5f488f2

File tree

4 files changed

+188
-163
lines changed

4 files changed

+188
-163
lines changed

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

Lines changed: 36 additions & 54 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,48 @@ 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 "-----------------------------------------------------------------------------------------"
39-
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
42+
log_info "------------------- Starting $TESTNAME Testcase ----------------------------"
4043
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"
44+
45+
if ! validate_remoteproc_running "$firmware_name" "$LOG_FILE" 15 2; then
46+
log_fail "$firmware_name remoteproc is not in running state after bootup"
47+
echo "$TESTNAME FAIL" > "$res_file"
5948
exit 1
6049
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"
50+
51+
log_pass "$firmware_name remoteproc validated as running"
52+
53+
rproc_path=$(get_remoteproc_path_by_firmware "$firmware_name")
54+
55+
stop_remoteproc "$rproc_path" || {
56+
log_fail "$TESTNAME stop failed"
57+
echo "$TESTNAME FAIL" > "$res_file"
7158
exit 1
72-
else
73-
log_pass "adsp stop successful"
74-
fi
75-
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"
59+
}
60+
log_pass "$firmware_name stop successful"
61+
62+
log_info "Restarting $firmware_name"
63+
start_remoteproc "$rproc_path" || {
64+
log_fail "$TESTNAME start failed"
65+
echo "$TESTNAME FAIL" > "$res_file"
8466
exit 1
85-
fi
86-
87-
# If all checks pass, print "PASS"
88-
echo "adsp PASS"
89-
log_pass "adsp PASS"
67+
}
68+
69+
log_pass "$firmware_name PASS"
9070
echo "$TESTNAME PASS" > "$res_file"
91-
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
71+
72+
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"
9273
exit 0
74+

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

Lines changed: 34 additions & 50 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,48 @@ 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 "-----------------------------------------------------------------------------------------"
39-
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
42+
log_info "------------------- Starting $TESTNAME Testcase ----------------------------"
4043
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
44+
45+
if ! validate_remoteproc_running "$firmware_name" "$LOG_FILE" 15 2; then
46+
log_fail "$firmware_name remoteproc is not in running state after bootup"
47+
echo "$TESTNAME FAIL" > "$res_file"
5848
exit 1
5949
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
50+
51+
log_pass "$firmware_name remoteproc validated as running"
52+
53+
rproc_path=$(get_remoteproc_path_by_firmware "$firmware_name")
54+
55+
stop_remoteproc "$rproc_path" || {
56+
log_fail "$TESTNAME stop failed"
57+
echo "$TESTNAME FAIL" > "$res_file"
6958
exit 1
70-
else
71-
log_pass "cdsp stop successful"
72-
fi
73-
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"
59+
}
60+
log_pass "$firmware_name stop successful"
61+
62+
log_info "Restarting $firmware_name"
63+
start_remoteproc "$rproc_path" || {
64+
log_fail "$TESTNAME start failed"
8165
echo "$TESTNAME FAIL" > "$res_file"
8266
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"
89-
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
67+
}
68+
69+
log_pass "$firmware_name PASS"
70+
echo "$TESTNAME PASS" > "$res_file"
71+
72+
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"
9073
exit 0
74+

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

Lines changed: 34 additions & 58 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,48 @@ 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 "-----------------------------------------------------------------------------------------"
39-
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
42+
log_info "------------------- Starting $TESTNAME Testcase ----------------------------"
4043
log_info "=== Test Initialization ==="
41-
42-
log_info "=== Detecting and validating WPSS remoteproc instance ==="
4344

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
45+
if ! validate_remoteproc_running "$firmware_name" "$LOG_FILE" 15 2; then
46+
log_fail "$firmware_name remoteproc is not in running state after bootup"
47+
echo "$TESTNAME FAIL" > "$res_file"
48+
exit 1
5949
fi
6050

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

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

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

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"
62+
log_info "Restarting $firmware_name"
63+
start_remoteproc "$rproc_path" || {
64+
log_fail "$TESTNAME start failed"
9565
echo "$TESTNAME FAIL" > "$res_file"
9666
exit 1
97-
fi
98-
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
67+
}
68+
69+
log_pass "$firmware_name PASS"
70+
echo "$TESTNAME PASS" > "$res_file"
71+
72+
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"
73+
exit 0
74+

0 commit comments

Comments
 (0)