Skip to content

Commit 4670555

Browse files
committed
test: add option to test with pipewire
Signed-off-by: Emilia Kurdybelska <emiliax.kurdybelska@intel.com>
1 parent bf76a15 commit 4670555

File tree

3 files changed

+120
-26
lines changed

3 files changed

+120
-26
lines changed

case-lib/hijack.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ function func_exit_handler()
1212

1313
dlogi "Starting func_exit_handler($exit_status)"
1414

15+
if [ "$TEST_WITH_PIPEWIRE" == true ]; then
16+
func_lib_disable_pipewire
17+
fi
18+
1519
# call trace
1620
if [ "$exit_status" -ne 0 ] ; then
1721
dloge "Starting ${FUNCNAME[0]}(), exit status=$exit_status, FUNCNAME stack:"

case-lib/lib.sh

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ minvalue() { printf '%d' $(( "$1" < "$2" ? "$1" : "$2" )); }
8383
#
8484
start_test()
8585
{
86+
if [ "$TEST_WITH_PIPEWIRE" == true ]; then
87+
func_lib_enable_pipewire
88+
fi
89+
8690
if is_subtest; then
8791
return 0
8892
fi
@@ -571,6 +575,44 @@ func_lib_check_sudo()
571575
}
572576
}
573577

578+
func_lib_enable_pipewire()
579+
{
580+
dlogi "Starting Pipewire..."
581+
systemctl --user daemon-reexec
582+
systemctl --user daemon-reload
583+
systemctl --user unmask pipewire{,-pulse}.{socket,service}
584+
systemctl --user start pipewire{,-pulse}.{socket,service}
585+
systemctl --user unmask wireplumber.service
586+
systemctl --user start wireplumber.service
587+
588+
# Wait for pipewire to start
589+
sleep 5s
590+
591+
if [ "$(ps -C pipewire --no-header)" ]; then
592+
dlogi "Pipewire started"
593+
else
594+
die "Failed to start pipewire"
595+
fi
596+
}
597+
598+
func_lib_disable_pipewire()
599+
{
600+
dlogi "Stopping Pipewire..."
601+
602+
# Kill any left pipewire processes
603+
# pkill -9 arecord
604+
# pkill -9 aplay
605+
sleep 2s
606+
607+
systemctl --user stop pipewire{,-pulse}.{socket,service}
608+
systemctl --user mask pipewire{,-pulse}.{socket,service}
609+
systemctl --user stop wireplumber.service
610+
systemctl --user mask wireplumber.service
611+
612+
# Wait for pipewire to stop
613+
sleep 2s
614+
}
615+
574616
systemctl_show_pulseaudio()
575617
{
576618
printf '\n'
@@ -908,9 +950,15 @@ aplay_opts()
908950
# shellcheck disable=SC2086
909951
tinyplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS -D "$card_nr" -d "$dev_nr" -i wav noise.wav
910952
elif [[ "$SOF_ALSA_TOOL" = "alsa" ]]; then
911-
dlogc "aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $*"
912-
# shellcheck disable=SC2086
913-
aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS "$@"
953+
if [[ "$TEST_WITH_PIPEWIRE" == true ]]; then
954+
dlogc "timeout -k 60 30 aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $*" # option -d doesn't work with pipewire so we need timeout
955+
# shellcheck disable=SC2086
956+
timeout -k 60 30 aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS "$@"
957+
else
958+
dlogc "aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $*"
959+
# shellcheck disable=SC2086
960+
aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS "$@"
961+
fi
914962
else
915963
die "Unknown ALSA tool: ${SOF_ALSA_TOOL}"
916964
fi
@@ -927,9 +975,15 @@ arecord_opts()
927975
# shellcheck disable=SC2086
928976
tinycap $SOF_ALSA_OPTS $SOF_ARECORD_OPTS "$file" -D "$card_nr" -d "$dev_nr" -c "$channel" -t "$duration" -r "$rate" -b "$format"
929977
elif [[ "$SOF_ALSA_TOOL" = "alsa" ]]; then
930-
dlogc "arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $*"
931-
# shellcheck disable=SC2086
932-
arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS "$@"
978+
if [[ "$TEST_WITH_PIPEWIRE" == true ]]; then
979+
dlogc "timeout -k 60 30 arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $*" # option -d doesn't work with pipewire so we need timeout
980+
# shellcheck disable=SC2086
981+
timeout -k 60 30 arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS "$@"
982+
else
983+
dlogc "arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $*"
984+
# shellcheck disable=SC2086
985+
arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS "$@"
986+
fi
933987
else
934988
die "Unknown ALSA tool: ${SOF_ALSA_TOOL}"
935989
fi

test-case/check-performance.sh

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,63 @@ func_pipeline_export "$tplg" "type:any"
5151
aplay_num=0
5252
arecord_num=0
5353

54-
for idx in $(seq 0 $((PIPELINE_COUNT - 1)))
55-
do
56-
channel=$(func_pipeline_parse_value "$idx" channel)
57-
rate=$(func_pipeline_parse_value "$idx" rate)
58-
dev=$(func_pipeline_parse_value "$idx" dev)
59-
pcm=$(func_pipeline_parse_value "$idx" pcm)
60-
type=$(func_pipeline_parse_value "$idx" type)
61-
62-
# Currently, copier will convert bit depth to S32_LE despite what bit depth
63-
# is used in aplay, so make S32_LE as base bit depth for performance analysis.
64-
fmt=S32_LE
65-
66-
dlogi "Running (PCM: $pcm [$dev]<$type>) in background"
67-
if [ "$type" == "playback" ]; then
68-
aplay_opts -D "$dev" -c "$channel" -r "$rate" -f "$fmt" -d "$duration" /dev/zero -q &
69-
aplay_num=$((aplay_num+1))
70-
else
71-
arecord_opts -D "$dev" -c "$channel" -r "$rate" -f "$fmt" -d "$duration" /dev/null -q &
72-
arecord_num=$((arecord_num+1))
54+
if [ "$TEST_WITH_PIPEWIRE" == true ]; then
55+
56+
# aplay's for sinks
57+
pw_outputs_list=("Speaker" "Headphones" "HDMI")
58+
59+
for sink_type in "${pw_outputs_list[@]}"
60+
do
61+
sink_id=$(wpctl status | grep -A6 "Sinks" | grep -A3 -i "$sink_type" | tr -d '*' | awk '{print $2}' | tr -d '.' | head -n 1)
62+
if [ -z "$sink_id" ]; then
63+
echo "No $sink_type found, skipping to the next one"
64+
continue # skip if that device type isn't available
7365
fi
74-
done
66+
echo "Setting default sink to $sink_id: $sink_type"
67+
wpctl set-default "$sink_id"
68+
aplay_opts -Ddefault /dev/zero -q &
69+
aplay_num=$((aplay_num+1))
70+
done
71+
72+
# arecord's for sources
73+
pw_inputs_list=("Digital Microphone" "Headset Microphone" "SoundWire microphones")
74+
75+
for source_type in "${pw_inputs_list[@]}"
76+
do
77+
source_id=$(wpctl status | grep -A6 "Sources" | grep -A3 -i "$source_type" | tr -d '*' | awk '{print $2}' | tr -d '.' | head -n 1)
78+
if [ -z "$source_id" ]; then
79+
continue # skip if that device type isn't available
80+
fi
81+
echo "Setting default source to $source_id: $source_type"
82+
wpctl set-default "$source_id"
83+
arecord_opts -Ddefault /dev/zero -q &
84+
arecord_num=$((arecord_num+1))
85+
done
86+
87+
else
88+
89+
for idx in $(seq 0 $((PIPELINE_COUNT - 1)))
90+
do
91+
channel=$(func_pipeline_parse_value "$idx" channel)
92+
rate=$(func_pipeline_parse_value "$idx" rate)
93+
dev=$(func_pipeline_parse_value "$idx" dev)
94+
pcm=$(func_pipeline_parse_value "$idx" pcm)
95+
type=$(func_pipeline_parse_value "$idx" type)
96+
97+
# Currently, copier will convert bit depth to S32_LE despite what bit depth
98+
# is used in aplay, so make S32_LE as base bit depth for performance analysis.
99+
fmt=S32_LE
100+
101+
dlogi "Running (PCM: $pcm [$dev]<$type>) in background"
102+
if [ "$type" == "playback" ]; then
103+
aplay_opts -D "$dev" -c "$channel" -r "$rate" -f "$fmt" -d "$duration" /dev/zero -q &
104+
aplay_num=$((aplay_num+1))
105+
else
106+
arecord_opts -D "$dev" -c "$channel" -r "$rate" -f "$fmt" -d "$duration" /dev/null -q &
107+
arecord_num=$((arecord_num+1))
108+
fi
109+
done
110+
fi
75111

76112
sleep 1 # waiting stable streaming of aplay/arecord
77113
dlogi "Number of aplay/arecord process started: $aplay_num, $arecord_num"

0 commit comments

Comments
 (0)