Skip to content

Commit 3768bfe

Browse files
committed
test-case: simultaneous-p-c/volume/multiple-pipeline: Support multiple topologies
Three execution-class test cases updated to handle multi-topology TPLG input and avoid testing same physical PCM device more than once. simultaneous-playback-capture.sh: - Accepts colon/comma-separated TPLG by func_tplg_parse_and_validate() - Rewrite 'both' pipeline detection: * Parse sof-tplgreader.py output for 'id=X;...type=(playback|capture)' * Track seen 'id:type' pairs to skip exact duplicates from multiple topology files (same id+type in two files) * Accumulate id_has_playback[] and id_has_capture[] separately * Collect only IDs present in both maps. true 'both' pipelines, even when playback and capture come from different topology files - Updated description and OPT_DESC to document multi-file usage volume-basic-test.sh: - Call func_tplg_parse_and_validate(); iterate TPLG_FILES split on ',' - Append topo_vol_kcontrols.py output per topology to temp array (errors suppressed with '2>/dev/null || true' for optional files) - Deduplicate with 'sort -u' before assigning to pgalist; controls that appear in multiple topology files are tested only once multiple-pipeline.sh: - Declare global associative array USED_PCMS before main loop - In func_run_pipeline_with_type(): check USED_PCMS[$dev]; skip with log message if already tested; otherwise mark and proceed - Reset USED_PCMS=() at start of each loop iteration so every full pass starts with clean slate Signed-off-by: Mateusz Junkier <mateusz.junkier@intel.com>
1 parent bd396c8 commit 3768bfe

3 files changed

Lines changed: 78 additions & 18 deletions

File tree

test-case/multiple-pipeline.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ DEV_LST['playback']='/dev/zero'
8686
APP_LST['capture']='arecord_opts'
8787
DEV_LST['capture']='/dev/null'
8888

89+
# Global associative array to track used PCM devices across playback/capture
90+
declare -A USED_PCMS
91+
8992
# define for load pipeline
9093
# args: $1: playback or capture
9194
# $2: optional filter
@@ -114,6 +117,13 @@ func_run_pipeline_with_type()
114117
dev=$(func_pipeline_parse_value "$idx" dev)
115118
pcm=$(func_pipeline_parse_value "$idx" pcm)
116119

120+
# Skip if this PCM device was already tested
121+
if [[ -n "${USED_PCMS[$dev]}" ]]; then
122+
dlogi "Skipping duplicate PCM: $pcm [$dev] (already tested)"
123+
continue
124+
fi
125+
USED_PCMS["$dev"]=1
126+
117127
dlogi "Testing: $pcm [$dev]"
118128

119129
"${APP_LST[$direction]}" -D "$dev" -c "$channel" -r "$rate" -f "$fmt" "${DEV_LST[$direction]}" -q &
@@ -180,6 +190,9 @@ do
180190
setup_kernel_check_point
181191
dlogi "===== Testing: (Loop: $i/$loop_cnt) ====="
182192

193+
# Reset used PCMs tracker for this iteration
194+
USED_PCMS=()
195+
183196
# start playback or capture:
184197
case "$f_arg" in
185198
'p' | 'a')

test-case/simultaneous-playback-capture.sh

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
## N/A
77
## Description:
88
## simultaneous running of aplay and arecord on "both" pipelines
9+
## Supports multiple topology files separated by colon (:) or comma (,)
910
## Case step:
10-
## 1. Parse TPLG file to get pipeline with type "both"
11+
## 1. Parse TPLG file(s) to get pipeline with type "both"
1112
## 2. Run aplay and arecord
1213
## 3. Check for aplay and arecord process existence
1314
## 4. Sleep for given time period
@@ -21,7 +22,7 @@
2122
# shellcheck source=case-lib/lib.sh
2223
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
2324

24-
OPT_NAME['t']='tplg' OPT_DESC['t']="tplg file, default value is env TPLG: $TPLG"
25+
OPT_NAME['t']='tplg' OPT_DESC['t']="tplg file(s), separated by : or , default value is env TPLG: $TPLG"
2526
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"
2627

2728
OPT_NAME['w']='wait' OPT_DESC['w']='sleep for wait duration'
@@ -41,23 +42,53 @@ loop_cnt=${OPT_VAL['l']}
4142

4243
start_test
4344

44-
# get 'both' pcm, it means pcm have same id with different type
45-
declare -A tmp_id_lst
45+
# Support multiple topologies separated by colon (:) or comma (,)
46+
# sof-tplgreader.py natively supports multiple files with comma separator
47+
tplg="${tplg//,/:}" # Normalize to colon first
48+
# Parse and validate topology files
49+
func_tplg_parse_and_validate "$tplg"
50+
tplg_files="$TPLG_FILES"
51+
52+
dlogi "Processing $TPLG_COUNT topology file(s) for 'both' pipelines"
53+
54+
# get 'both' pcm: pipelines with same id but different types (playback + capture)
55+
declare -A tmp_id_types # Store "id:type" combinations seen
56+
declare -A id_has_playback
57+
declare -A id_has_capture
4658
id_lst_str=""
47-
tplg_path=$(func_lib_get_tplg_path "$tplg") ||
48-
die "No available topology for this test case"
49-
for i in $(sof-tplgreader.py "$tplg_path" -d id -v)
50-
do
51-
if [ ! "${tmp_id_lst["$i"]}" ]; then # this id is never used
52-
tmp_id_lst["$i"]=0
53-
else # this id already used
54-
tmp_id_lst["$i"]=1
55-
id_lst_str="$id_lst_str,$i"
59+
60+
# sof-tplgreader.py handles multiple files natively
61+
# Parse output to find IDs with both playback and capture
62+
while IFS= read -r line; do
63+
# Expected format: id=X;pcm=NAME;type=TYPE;...
64+
if [[ "$line" =~ id=([0-9]+)\;.*type=(playback|capture) ]]; then
65+
pid="${BASH_REMATCH[1]}"
66+
ptype="${BASH_REMATCH[2]}"
67+
key="${pid}:${ptype}"
68+
69+
# Skip if we've seen this exact id:type combination (duplicate from multiple topologies)
70+
[[ -n "${tmp_id_types[$key]}" ]] && continue
71+
tmp_id_types["$key"]=1
72+
73+
# Track which IDs have which types
74+
if [[ "$ptype" == "playback" ]]; then
75+
id_has_playback["$pid"]=1
76+
elif [[ "$ptype" == "capture" ]]; then
77+
id_has_capture["$pid"]=1
78+
fi
79+
fi
80+
done < <(sof-tplgreader.py "$tplg_files" -d id pcm type -o)
81+
82+
# Find IDs that have both playback and capture
83+
for pid in "${!id_has_playback[@]}"; do
84+
if [[ -n "${id_has_capture[$pid]}" ]]; then
85+
id_lst_str="${id_lst_str},${pid}"
5686
fi
5787
done
58-
# now all duplicate ids have already been caught
59-
unset tmp_id_lst tplg_path
60-
id_lst_str=${id_lst_str/,/} # remove 1st, which is not used
88+
89+
# Clean up
90+
unset tmp_id_types id_has_playback id_has_capture
91+
id_lst_str=${id_lst_str/,/} # remove leading comma
6192
[[ ${#id_lst_str} -eq 0 ]] && dlogw "no pipeline with both playback and capture capabilities found in $tplg" && exit 2
6293
func_pipeline_export "$tplg" "id:$id_lst_str"
6394

test-case/volume-basic-test.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,24 @@ sleep 1
5151
check_alsa_tool_process
5252
sofcard=${SOFCARD:-0}
5353

54-
# https://mywiki.wooledge.org/BashFAQ/024 why cant I pipe data to read?
55-
readarray -t pgalist < <("$TOPDIR"/tools/topo_vol_kcontrols.py "$tplg")
54+
# Extract PGA controls from all topology files
55+
# Parse multiple topologies (comma or colon separated) and collect unique PGA controls
56+
func_tplg_parse_and_validate "$tplg"
57+
tplg_files="$TPLG_FILES"
58+
59+
# Collect PGA controls from all topology files
60+
pgalist_tmp=()
61+
IFS=',' read -ra tplg_array <<< "$tplg_files"
62+
for single_tplg in "${tplg_array[@]}"; do
63+
dlogi "Extracting PGA controls from: $single_tplg"
64+
# Collect output from this topology
65+
while IFS= read -r line; do
66+
[[ -n "$line" ]] && pgalist_tmp+=("$line")
67+
done < <("$TOPDIR"/tools/topo_vol_kcontrols.py "$single_tplg" 2>/dev/null || true)
68+
done
69+
70+
# Deduplicate PGA controls (same control can appear in multiple topologies)
71+
readarray -t pgalist < <(printf '%s\n' "${pgalist_tmp[@]}" | sort -u)
5672

5773
# This (1) provides some logging (2) avoids skip_test if amixer fails
5874
get_sof_controls "$sofcard"

0 commit comments

Comments
 (0)