Skip to content

Commit bd396c8

Browse files
committed
test-case: verify-tplg-binary/pcm-list: Support multiple topology files
Both tests now accept colon or comma-separated list of topology paths by -t / TPLG, consistent with new func_tplg_parse_and_validate() convention introduced in case-lib/pipeline.sh. verify-tplg-binary.sh: - Normalise separator to colon, split into array, iterate per file - Call func_lib_get_tplg_path() per entry; dlogw + skip on missing file instead of die() (optional topologies on headless systems) - Print md5sum and sof-tplgreader.py output per topology - Run tplgtool2.py per file; include filename in die() message - Remove now-redundant main() wrapper - Print a summary line after all files pass verify-pcm-list.sh: - Use func_tplg_parse_and_validate() to resolve all topologies; carry NO_HDMI_MODE / NO_BT_MODE / NO_DMIC_MODE automatically - Build sof-tplgreader.py -f filter string from active NO_* variables, mirroring func_pipeline_export() filter logic, so pipeline list compared against /proc/asound/pcm is consistent - Pass comma joined TPLG_FILES to sof-tplgreader.py - Deduplication: with TPLG_COUNT > 1 use awk 'NF && !seen[$0]++' remove exact duplicate lines while preserving original order; dont deduplicate by id alone PCM legitimately has both playback and capture entry sharing same id Signed-off-by: Mateusz Junkier <mateusz.junkier@intel.com>
1 parent 497dc8f commit bd396c8

2 files changed

Lines changed: 86 additions & 26 deletions

File tree

test-case/verify-pcm-list.sh

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
## driver already inserted with modprobe
77
## Description:
88
## using /proc/asound/pcm to compare with tplg content
9+
## Supports multiple topology files separated by colon (:) or comma (,)
910
## Case step:
10-
## 1. load tplg file to get pipeline list string
11+
## 1. load tplg file(s) to get pipeline list string
1112
## 2. load /proc/asound/pcm to get pcm list string
1213
## 3. compare string list
1314
## Expect result:
@@ -20,22 +21,66 @@ set -e
2021
# shellcheck source=case-lib/lib.sh
2122
source "$(dirname "${BASH_SOURCE[0]}")/../case-lib/lib.sh"
2223

23-
OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $''TPLG'
24+
# Normalize pipeline list formatting and ordering so comparison is order-insensitive
25+
# but still count-sensitive (no deduplication).
26+
normalize_pipeline_list() {
27+
awk 'NF { print }' | sort -V
28+
}
29+
30+
OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file(s), separated by : or , default value is env TPLG: $''TPLG'
2431
OPT_HAS_ARG['t']=1 OPT_VAL['t']="${TPLG:-}"
2532

2633
func_opt_parse_option "$@"
2734
tplg=${OPT_VAL['t']}
2835

2936
start_test
3037

31-
tplg_path=$(func_lib_get_tplg_path "$tplg") ||
32-
die "No available topology for this test case"
38+
# Support multiple topologies separated by colon (:) or comma (,)
39+
# sof-tplgreader.py natively supports multiple files with comma separator
40+
tplg="${tplg//,/:}" # Normalize to colon first
41+
# Parse and validate topology files
42+
func_tplg_parse_and_validate "$tplg"
43+
tplg_files="$TPLG_FILES"
44+
45+
dlogi "Processing $TPLG_COUNT topology file(s)"
46+
47+
setup_kernel_check_point
48+
49+
# Build filter options (same as pipeline.sh func_pipeline_export)
50+
opt=""
51+
# In no HDMI mode, exclude HDMI pipelines
52+
[ -z "$NO_HDMI_MODE" ] || opt="$opt & ~pcm:HDMI"
53+
# In no Bluetooth mode, exclude BT pipelines
54+
[ -z "$NO_BT_MODE" ] || opt="$opt & ~pcm:Bluetooth"
55+
# In no DMIC mode, exclude DMIC pipelines
56+
[ -z "$NO_DMIC_MODE" ] || opt="$opt & ~pcm:DMIC"
57+
58+
# Remove leading " & " if present
59+
opt="${opt# & }"
60+
61+
# Build sof-tplgreader.py command with filter
62+
if [ -n "$opt" ]; then
63+
dlogi "Applying pipeline filter: $opt"
64+
tplg_str=$(sof-tplgreader.py "$tplg_files" -f "$opt" -d id pcm type -o)
65+
else
66+
tplg_str=$(sof-tplgreader.py "$tplg_files" -d id pcm type -o)
67+
fi
68+
69+
# Deduplicate exact duplicate lines only, preserve original order.
70+
# Do NOT deduplicate by id because one PCM can have both playback and capture
71+
# entries with the same id.
72+
if [ "$TPLG_COUNT" -gt 1 ]; then
73+
tplg_str=$(echo "$tplg_str" | awk 'NF && !seen[$0]++')
74+
dlogi "Deduplicated identical pipelines from $TPLG_COUNT topology files"
75+
fi
76+
77+
# Normalize topology output ordering before comparison
78+
tplg_str=$(echo "$tplg_str" | normalize_pipeline_list)
3379

34-
tplg_str=$(sof-tplgreader.py "$tplg_path" -d id pcm type -o)
35-
pcm_str=$(sof-dump-status.py -i "${SOFCARD:-0}")
80+
pcm_str=$(sof-dump-status.py -i "${SOFCARD:-0}" | normalize_pipeline_list)
3681

37-
dlogc "sof-tplgreader.py $tplg_path -d id pcm type -o"
38-
dlogi "Pipeline(s) from topology file:"
82+
dlogc "Processed $TPLG_COUNT topology file(s)"
83+
dlogi "Pipeline(s) from topology file(s):"
3984
echo "$tplg_str"
4085
dlogc "sof-dump-status.py -i ${SOFCARD:-0}"
4186
dlogi "Pipeline(s) from system:"

test-case/verify-tplg-binary.sh

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
## SOF topology files install at "/lib/firmware/intel/sof-tplg"
77
## Description:
88
## check target topology files md5sum
9+
## Supports multiple topology files separated by colon (:) or comma (,)
910
## Case step:
1011
## 1. check if topology files exist
1112
## 2. dump tplg files md5sum
@@ -19,37 +20,51 @@ set -e
1920
# shellcheck source=case-lib/lib.sh
2021
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
2122

22-
OPT_NAME['t']='tplg' OPT_DESC['t']="tplg file, default value is env TPLG: $TPLG"
23+
OPT_NAME['t']='tplg' OPT_DESC['t']="tplg file(s), separated by : or , default value is env TPLG: $TPLG"
2324
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"
2425

2526
func_opt_parse_option "$@"
2627
tplg=${OPT_VAL['t']}
2728

2829
start_test
2930

30-
tplg_path=$(func_lib_get_tplg_path "$tplg") ||
31-
die "No available topology ($tplg) for this test case"
31+
# Support multiple topologies separated by colon (:) or comma (,)
32+
# Convert comma separators to colons for uniform handling
33+
tplg="${tplg//,/:}"
34+
IFS=':' read -ra tplg_array <<< "$tplg"
3235

33-
dlogi "Checking topology file: $tplg_path with sof-tplgreader.py"
34-
dlogi "Found file: $(md5sum "$tplg_path" | awk '{print $2, $1;}')"
35-
tplgData=$(sof-tplgreader.py "$tplg_path") ||
36-
die "No valid pipeline(s) found in $tplg_path"
37-
38-
dlogi "Valid pipeline(s) in this topology:"
39-
echo "===========================>>"
40-
echo "$tplgData"
41-
echo "<<==========================="
42-
43-
main()
44-
{
36+
# Process each topology
37+
for single_tplg in "${tplg_array[@]}"; do
38+
single_tplg="${single_tplg## }"; single_tplg="${single_tplg%% }" # Trim whitespace
39+
[[ -z "$single_tplg" ]] && continue
40+
41+
tplg_path=$(func_lib_get_tplg_path "$single_tplg") || {
42+
dlogw "Topology not found: $single_tplg (skipping)"
43+
continue
44+
}
45+
46+
dlogi "========================================"
47+
dlogi "Checking topology file: $tplg_path with sof-tplgreader.py"
48+
dlogi "Found file: $(md5sum "$tplg_path" | awk '{print $2, $1;}')"
49+
tplgData=$(sof-tplgreader.py "$tplg_path") || {
50+
dloge "No valid pipeline(s) found in $tplg_path"
51+
continue
52+
}
53+
54+
dlogi "Valid pipeline(s) in this topology:"
55+
echo "============================>>"
56+
echo "$tplgData"
57+
echo "<<============================="
58+
4559
# This one can find more problems, see sof-test#1054
4660
dlogi "Checking topology file with tplgtool2.py: $tplg_path"
4761
( set -x
4862
tplgtool2.py -D "${LOG_ROOT}" "$tplg_path" ) || {
4963
ret=$?
50-
die "tplgtool2.py returned $ret"
64+
die "tplgtool2.py returned $ret for $tplg_path"
5165
}
52-
}
66+
done
5367

54-
main
68+
dlogi "========================================"
69+
dlogi "All topology files verified successfully"
5570

0 commit comments

Comments
 (0)