Skip to content

Commit f400925

Browse files
committed
test: fix skipping: test-mic-privacy
Fix skip if no module named: usbrelay. Add skip if no relays hardware are detected. Add the new parameter to test: dsp-settle-sleep by default = 2s Signed-off-by: Artur Wilczak <arturx.wilczak@intel.com>
1 parent 1e34865 commit f400925

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

test-case/test-mic-privacy.sh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ source "${TESTLIB}/relay.sh"
4141
ALSABAT_WAV_FILES="/tmp/mc.wav.*"
4242
rm -f "$ALSABAT_WAV_FILES"
4343

44-
DSP_SETTLE_TIME=2
45-
4644
OPT_NAME['p']='pcm_p' OPT_DESC['p']='pcm for playback. Example: hw:0,0'
4745
OPT_HAS_ARG['p']=1 OPT_VAL['p']='hw:0,0'
4846

@@ -58,6 +56,9 @@ OPT_HAS_ARG['C']=1 OPT_VAL['C']='2'
5856
OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT"
5957
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1
6058

59+
OPT_NAME['d']='dsp-settle-sleep' OPT_DESC['d']="Waiting time to change control state"
60+
OPT_HAS_ARG['d']=1 OPT_VAL['d']=2
61+
6162
OPT_NAME['r']='rate' OPT_DESC['r']='sample rate'
6263
OPT_HAS_ARG['r']=1 OPT_VAL['r']=48000
6364

@@ -72,6 +73,7 @@ channel_c=${OPT_VAL['C']}
7273
channel_p=${OPT_VAL['N']}
7374
rate=${OPT_VAL['r']}
7475
relay=${OPT_VAL['u']}
76+
dsp_settle_time=${OPT_VAL['d']}
7577

7678
dlogi "Params: pcm_p=$pcm_p, pcm_c=$pcm_c, channel_c=$channel_c, channel_p=$channel_p, rate=$rate, LOG_ROOT=$LOG_ROOT"
7779

@@ -150,25 +152,26 @@ main()
150152

151153
start_test
152154

153-
logger_disabled || func_lib_start_log_collect
155+
dlogi "Checking usbrelay availability..."
156+
command -v usbrelay || {
157+
# If usbrelay package is not installed
158+
skip_test "usbrelay command not found."
159+
}
160+
161+
# display current status of relays
162+
usbrelay_switch --debug || {
163+
skip_test "Failed to get usbrelay status."
164+
}
154165

155166
if [ -z "$pcm_p" ] || [ -z "$pcm_c" ]; then
156167
skip_test "No playback or capture PCM is specified. Skip the $0 test."
157168
fi
158-
159-
# check if usbrelay tool is installed
160-
command -v usbrelay || {
161-
skip_test "usbrelay command not found. Please install usbrelay to control the mic privacy switch."
162-
}
163-
169+
164170
dlogi "Current DSP status is $(sof-dump-status.py --dsp_status 0)" || {
165171
skip_test "platform doesn't support runtime pm, skip test case"
166172
}
167173

168-
dlogi "Starting preconditions check"
169-
170-
# display current status of relays
171-
usbrelay "--debug"
174+
logger_disabled || func_lib_start_log_collect
172175

173176
check_locale_for_alsabat
174177

@@ -180,7 +183,7 @@ main()
180183
show_control_state
181184

182185
# wait for the switch to settle
183-
sleep "$DSP_SETTLE_TIME"
186+
sleep "$dsp_settle_time"
184187

185188
# check the PCMs before mic privacy test
186189
dlogi "Check playback/capture before mic privacy test"
@@ -196,14 +199,14 @@ main()
196199

197200
dlogi "Preconditions are met, starting mic privacy test"
198201

199-
sleep "$DSP_SETTLE_TIME"
202+
sleep "$dsp_settle_time"
200203

201204
dlogi "===== Testing: MIC privacy ====="
202205
dlogi "Turn on the mic privacy switch"
203206
usbrelay_switch "$relay" 1
204207

205208
# wait for the switch to settle
206-
sleep "$DSP_SETTLE_TIME"
209+
sleep "$dsp_settle_time"
207210

208211
alsabat_output=$(mktemp)
209212
dlogc "alsabat -P$pcm_p -C$pcm_c -c 2 -r $rate"

0 commit comments

Comments
 (0)