Skip to content

Commit eecee05

Browse files
committed
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 d4ea109 commit eecee05

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
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/intel/"
1438+
modprobe_file="/etc/modprobe.d/tplg_filename.conf"
1439+
remove_script="$SCRIPT_HOME/tools/kmod/sof_remove.sh"
1440+
insert_script="$SCRIPT_HOME/sof-test/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: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
4848
OPT_NAME['S']='filter_string' OPT_DESC['S']="run this case on specified pipelines"
4949
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"
5050

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
56+
5157
func_opt_parse_option "$@"
5258

5359
tplg=${OPT_VAL['t']}
@@ -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)