Skip to content

Commit ba44dda

Browse files
committed
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 39754df commit ba44dda

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

case-lib/relay.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ 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
1819
fi
1920

2021
# Declare a constant for the relay settle time

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,20 @@ OPT_HAS_ARG['d']=1 OPT_VAL['d']=3
6262
OPT_NAME['u']='relay' OPT_DESC['u']='name of usbrelay switch, default value is HURTM_2'
6363
OPT_HAS_ARG['u']=1 OPT_VAL['u']="HURTM_2"
6464

65-
OPT_NAME['h']='headphone' OPT_DESC['h']='name of pcm control for headphone jack'
66-
OPT_HAS_ARG['h']=1 OPT_VAL['h']="headphone jack"
65+
OPT_NAME['H']='headphone' OPT_DESC['H']='name of pcm control for headphone jack'
66+
OPT_HAS_ARG['H']=1 OPT_VAL['H']="headphone jack"
6767

68-
OPT_NAME['m']='headset' OPT_DESC['m']='name of pcm control for headset mic jack'
69-
OPT_HAS_ARG['m']=1 OPT_VAL['m']="headset [a-z ]*jack"
68+
OPT_NAME['M']='headset' OPT_DESC['M']='name of pcm control for headset mic jack'
69+
OPT_HAS_ARG['M']=1 OPT_VAL['M']="headset [a-z ]*jack"
7070

7171
func_opt_parse_option "$@"
7272

7373
tplg=${OPT_VAL['t']}
7474
relay=${OPT_VAL['u']}
7575
loop_cnt=${OPT_VAL['l']}
7676
dsp_settle_time=${OPT_VAL['d']}
77-
headphone_jack_name=${OPT_VAL['h']}
78-
headset_mic_jack_name=${OPT_VAL['m']}
77+
headphone_jack_name=${OPT_VAL['H']}
78+
headset_mic_jack_name=${OPT_VAL['M']}
7979

8080
check_control_switch_state()
8181
{
@@ -87,6 +87,8 @@ 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."
91+
9092
control_state=$(amixer -c "$SOFCARD" contents | awk -v name="$control_name" '
9193
BEGIN { IGNORECASE=1; found=0 }
9294
/name='\''/ {
@@ -103,6 +105,7 @@ check_control_switch_state()
103105
if [[ "$expected_control_state" == "$control_state" ]]; then
104106
return 0
105107
else
108+
dloge "Expected control state ($expected_control_state) but got ($control_state)."
106109
return 1
107110
fi
108111
}
@@ -185,17 +188,22 @@ main()
185188
# Check if usbrelay tool is installed
186189
command -v usbrelay || {
187190
# If usbrelay package is not installed
188-
skip_test "usbrelay command not found. Please install usbrelay package."
191+
skip_test "usbrelay command not found."
189192
}
190193

191-
logger_disabled || func_lib_start_log_collect
192-
193194
# display current status of relays
194-
usbrelay --debug
195+
usbrelay_switch --debug || {
196+
skip_test "Failed to get usbrelay status."
197+
}
198+
199+
logger_disabled || func_lib_start_log_collect
195200

196201
dlogi "Reset - plug jack audio"
197202
usbrelay_switch "$relay" 0
198203

204+
dlogi "Headphone patten: $headphone_jack_name"
205+
dlogi "Headset mic pattern: $headset_mic_jack_name"
206+
199207
for idx in $(seq 0 $((PIPELINE_COUNT - 1)))
200208
do
201209
initialize_audio_params "$idx"

0 commit comments

Comments
 (0)