Skip to content

Commit 1e34865

Browse files
arikgreenredzynix
authored andcommitted
test: fix skipping: test jack detection
Fix skip if no module named: usbrelay. Add skip if no relays hardware are detected. Signed-off-by: Artur Wilczak <arturx.wilczak@intel.com>
1 parent fea93fe commit 1e34865

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

case-lib/relay.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ usbrelay_switch()
1010
{
1111
if [[ "$1" == "--debug" ]]; then
1212
dlogi "Debug mode: Current status of all relays:"
13-
usbrelay || {
14-
die "Failed to get usbrelay status.
15-
The usbrelay hw module is not responding or no relays detected.
16-
Check hardware connection."
17-
}
13+
if usbrelay --debug 2>&1 | grep -q "Found 0 devices"; then
14+
dloge "No relays detected. Found 0 devices. Check hardware connection."
15+
dloge "The usbrelay hw module is not responding or no relays detected. Check hardware connection."
16+
# Skip the test if no relays are detected
17+
exit 2
18+
fi
19+
return 0
1820
fi
1921

2022
# Declare a constant for the relay settle time

test-case/test-jack-detection-playback-capture.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ check_control_switch_state()
8787
local expected_control_state="$2"
8888
local control_state
8989

90+
dlogi "Check if the state of control: $control_name is correct."
9091
control_state=$(amixer -c "$SOFCARD" contents | \
9192
gawk -v name="$control_name" -f "${TESTLIB}/control_state.awk")
9293
dlogi "$control_name switch is: $control_state"
9394

9495
if [[ "$expected_control_state" == "$control_state" ]]; then
9596
return 0
9697
else
98+
dloge "Expected control state ($expected_control_state) but got ($control_state)."
9799
return 1
98100
fi
99101
}
@@ -176,13 +178,15 @@ main()
176178
dlogi "Checking usbrelay availability..."
177179
command -v usbrelay || {
178180
# If usbrelay package is not installed
179-
skip_test "usbrelay command not found. Please install usbrelay package."
181+
skip_test "usbrelay command not found."
180182
}
181183

182-
logger_disabled || func_lib_start_log_collect
183-
184184
# display current status of relays
185-
usbrelay --debug
185+
usbrelay_switch --debug || {
186+
skip_test "Failed to get usbrelay status."
187+
}
188+
189+
logger_disabled || func_lib_start_log_collect
186190

187191
dlogi "Reset - plug jack audio"
188192
usbrelay_switch "$relay" 0

0 commit comments

Comments
 (0)