Skip to content

Commit 6007edd

Browse files
pkunieckredzynix
authored andcommitted
check-capture: add sample rate changing, topology changing
- Added functionality to change topology filename. - Implemented sample rate modification. - Enable ultrasound testing capabilities. Signed-off-by: Patryk Kuniecki <patryk.kuniecki@intel.com>
1 parent fa7f3ed commit 6007edd

File tree

3 files changed

+85
-19
lines changed

3 files changed

+85
-19
lines changed

case-lib/hijack.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ function func_exit_handler()
199199
fi
200200
}
201201

202+
# Only run when changing topology was initiated during the test
203+
if [[ -n "$new_tplg_filename" ]]; then
204+
restore_topology
205+
fi
202206
print_test_result_exit "$exit_status"
203207
}
204208

case-lib/lib.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,3 +1425,55 @@ reboot_wrapper()
14251425
echo "Reboot command" && sleep 5
14261426
sudo reboot now
14271427
}
1428+
1429+
check_topology() {
1430+
# Confirm topology on the dut
1431+
tplg_file=$(sudo journalctl -q -k | grep -i 'loading topology' | awk -F: '{ topo=$NF; } END { print topo }')
1432+
echo "Updated topology loaded: $tplg_file"
1433+
}
1434+
1435+
# Function to check and update topology filename, reload drivers, and confirm update
1436+
update_topology_filename() {
1437+
firmware_dir="/lib/firmware/"
1438+
modprobe_file="/etc/modprobe.d/tplg_filename.conf"
1439+
remove_script="$SCRIPT_HOME/tools/kmod/sof_remove.sh"
1440+
insert_script="$SCRIPT_HOME/tools/kmod/sof_insert.sh"
1441+
if ! find "$firmware_dir" -type f -name "$new_tplg_filename" -print -quit | grep -q .; then
1442+
echo "File $new_tplg_filename does not exist in $firmware_dir or its subdirectories, exiting."
1443+
exit 1
1444+
fi
1445+
if [[ -f "$modprobe_file" ]]; then
1446+
old_topology=$(sudo cat "$modprobe_file")
1447+
echo "Old topology: $old_topology"
1448+
fi
1449+
# Check if the remove and insert scripts exist
1450+
if [[ ! -f "$remove_script" ]]; then
1451+
echo "Error: File $remove_script does not exist. Exiting."
1452+
exit 1
1453+
fi
1454+
1455+
if [[ ! -f "$insert_script" ]]; then
1456+
echo "Error: File $insert_script does not exist. Exiting."
1457+
exit 1
1458+
fi
1459+
1460+
if [[ -n "$new_tplg_filename" ]]; then
1461+
echo "options snd-sof-pci tplg_filename=$new_tplg_filename" | sudo tee "$modprobe_file" > /dev/null
1462+
echo "Updated topology filename to: $new_tplg_filename"
1463+
1464+
# Reload drivers
1465+
echo "Reloading drivers"
1466+
sudo "$remove_script"
1467+
sudo "$insert_script"
1468+
check_topology
1469+
fi
1470+
}
1471+
1472+
# Restore the original topology after the test
1473+
restore_topology() {
1474+
echo "$old_topology" | sudo tee "$modprobe_file" > /dev/null
1475+
echo "Restored original topology: $old_topology"
1476+
sudo "$remove_script"
1477+
sudo "$insert_script"
1478+
check_topology
1479+
}

test-case/check-capture.sh

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,38 @@ set -e
2121
# shellcheck source=case-lib/lib.sh
2222
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
2323

24-
OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $''TPLG'
25-
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"
24+
OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $''TPLG'
25+
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"
2626

27-
OPT_NAME['r']='round' OPT_DESC['r']='round count'
28-
OPT_HAS_ARG['r']=1 OPT_VAL['r']=1
27+
OPT_NAME['r']='round' OPT_DESC['r']='round count'
28+
OPT_HAS_ARG['r']=1 OPT_VAL['r']=1
2929

30-
OPT_NAME['d']='duration' OPT_DESC['d']='arecord duration in second'
31-
OPT_HAS_ARG['d']=1 OPT_VAL['d']=10
30+
OPT_NAME['d']='duration' OPT_DESC['d']='arecord duration in second'
31+
OPT_HAS_ARG['d']=1 OPT_VAL['d']=10
3232

33-
OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
34-
OPT_HAS_ARG['l']=1 OPT_VAL['l']=3
33+
OPT_NAME['l']='loop' OPT_DESC['l']='loop count'
34+
OPT_HAS_ARG['l']=1 OPT_VAL['l']=3
3535

36-
OPT_NAME['o']='output' OPT_DESC['o']='output dir'
37-
OPT_HAS_ARG['o']=1 OPT_VAL['o']="$LOG_ROOT/wavs"
36+
OPT_NAME['o']='output' OPT_DESC['o']='output dir'
37+
OPT_HAS_ARG['o']=1 OPT_VAL['o']="$LOG_ROOT/wavs"
3838

39-
OPT_NAME['f']='file' OPT_DESC['f']='file name prefix'
40-
OPT_HAS_ARG['f']=1 OPT_VAL['f']=''
39+
OPT_NAME['f']='file' OPT_DESC['f']='file name prefix'
40+
OPT_HAS_ARG['f']=1 OPT_VAL['f']=''
4141

42-
OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT"
43-
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1
42+
OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT"
43+
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1
4444

45-
OPT_NAME['F']='fmts' OPT_DESC['F']='Iterate all supported formats'
46-
OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
45+
OPT_NAME['F']='fmts' OPT_DESC['F']='Iterate all supported formats'
46+
OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
4747

4848
OPT_NAME['S']='filter_string' OPT_DESC['S']="run this case on specified pipelines"
49-
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"
49+
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"
50+
51+
OPT_NAME['R']='samplerate' OPT_DESC['R']='sample rate'
52+
OPT_HAS_ARG['R']=1 OPT_VAL['R']=48000 # Default sample rate
53+
54+
OPT_NAME['T']='tplg_filename' OPT_DESC['T']='new topology filename'
55+
OPT_HAS_ARG['T']=1 OPT_VAL['T']='' # Default empty
5056

5157
func_opt_parse_option "$@"
5258

@@ -56,7 +62,12 @@ duration=${OPT_VAL['d']}
5662
loop_cnt=${OPT_VAL['l']}
5763
out_dir=${OPT_VAL['o']}
5864
file_prefix=${OPT_VAL['f']}
65+
samplerate=${OPT_VAL['R']} # Use the sample rate specified by the -R option
66+
new_tplg_filename=${OPT_VAL['T']} # New topology filename
5967

68+
if [[ -n "$new_tplg_filename" ]]; then
69+
update_topology_filename
70+
fi
6071
start_test
6172
logger_disabled || func_lib_start_log_collect
6273

@@ -90,7 +101,7 @@ do
90101
dlogi "using $file as capture output"
91102
fi
92103

93-
if ! arecord_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" -d "$duration" "$file" -v -q;
104+
if ! arecord_opts -D"$dev" -r "$samplerate" -c "$channel" -f "$fmt_elem" -d "$duration" "$file" -v -q;
94105
then
95106
func_lib_lsof_error_dump "$snd"
96107
die "arecord on PCM $dev failed at $i/$loop_cnt."
@@ -99,6 +110,5 @@ do
99110
done
100111
done
101112
done
102-
103113
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT"
104114
exit $?

0 commit comments

Comments
 (0)