55# # Preconditions:
66# # N/A
77# # Description:
8- # # run arecord on each pepeline
8+ # # run arecord on each pipeline
99# # default duration is 10s
1010# # default loop count is 3
1111# # Case step:
@@ -48,6 +48,12 @@ OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
4848OPT_NAME[' S' ]=' filter_string' OPT_DESC[' S' ]=" run this case on specified pipelines"
4949OPT_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+
5157func_opt_parse_option " $@ "
5258
5359tplg=${OPT_VAL['t']}
@@ -56,11 +62,75 @@ duration=${OPT_VAL['d']}
5662loop_cnt=${OPT_VAL['l']}
5763out_dir=${OPT_VAL['o']}
5864file_prefix=${OPT_VAL['f']}
59-
65+ samplerate=${OPT_VAL['R']} # Use the sample rate specified by the -R option
66+ new_tplg_filename=${OPT_VAL['T']} # New topology filename
67+ modprobe_file=" /etc/modprobe.d/tplg_filename.conf"
68+
69+ script_name=$( basename " ${BASH_SOURCE[0]} " )
70+
71+ reboot_file=" /var/tmp/$script_name /rebooted"
72+
73+ # Function to check and update topology filename, reload drivers, and confirm update
74+ update_topology_filename () {
75+ if [[ -f " $modprobe_file " ]]; then
76+ old_topology=$( sudo cat " $modprobe_file " )
77+ echo " Old topology: $old_topology "
78+ fi
79+
80+ # Confirm current topology
81+ tplg_file=$( sudo journalctl -q -k | grep -i ' loading topology' | awk -F: ' { topo=$NF; } END { print topo }' )
82+ echo " Current topology loaded: $tplg_file "
83+
84+ if [[ -n " $new_tplg_filename " ]]; then
85+ echo " options snd-sof-pci tplg_filename=$new_tplg_filename " | sudo tee " $modprobe_file " > /dev/null
86+ echo " Updated topology filename to: $new_tplg_filename "
87+
88+ # Reload drivers
89+ sudo sof-test/tools/kmod/sof_remove.sh
90+ sleep 5
91+ sudo sof-test/tools/kmod/sof_insert.sh
92+ sleep 5
93+
94+ # Confirm updated topology
95+ tplg_file=$( sudo journalctl -q -k | grep -i ' loading topology' | awk -F: ' { topo=$NF; } END { print topo }' )
96+ echo " Updated topology loaded: $tplg_file "
97+ fi
98+ }
99+
100+ # Restore the original topology after the test
101+ restore_topology () {
102+ if [[ -n " $old_topology " ]]; then
103+ # sleep 10
104+ echo " $old_topology " | sudo tee " $modprobe_file " > /dev/null
105+ echo " Restored original topology: $old_topology "
106+ # reboot_wrapper
107+ # Reload drivers to apply the original topology
108+ # sleep 5
109+ # sudo sof-test/tools/kmod/sof_remove.sh
110+ # sleep 5
111+ # sudo sof-test/tools/kmod/sof_insert.sh
112+ # sleep 5
113+
114+ # Confirm restored topology
115+ # tplg_file=$(sudo journalctl -q -k | grep -i 'loading topology' | awk -F: '{ topo=$NF; } END { print topo }')
116+ # echo "Restored topology loaded: $tplg_file"
117+ fi
118+ }
119+
120+ # Update topology filename if -T option is used
121+ update_topology_filename
60122start_test
61- logger_disabled || func_lib_start_log_collect
123+ # logger_disabled || func_lib_start_log_collect
62124
63125setup_kernel_check_point
126+
127+ if [ -f $reboot_file ]; then
128+ dlogi " System rebooted"
129+ rm " $reboot_file "
130+ sof-kernel-log-check.sh " $KERNEL_CHECKPOINT "
131+ exit $?
132+ fi
133+
64134func_lib_check_sudo
65135func_pipeline_export " $tplg " " type:capture & ${OPT_VAL['S']} "
66136
90160 dlogi " using $file as capture output"
91161 fi
92162
93- if ! arecord_opts -D" $dev " -r " $rate " -c " $channel " -f " $fmt_elem " -d " $duration " " $file " -v -q;
163+ # Ensure the sample rate is set correctly
164+ if ! arecord_opts -D" $dev " -r " $samplerate " -c " $channel " -f " $fmt_elem " -d " $duration " " $file " -v -q;
94165 then
95166 func_lib_lsof_error_dump " $snd "
167+ echo " arecord on PCM $dev failed at $i /$loop_cnt ."
96168 die " arecord on PCM $dev failed at $i /$loop_cnt ."
97169 fi
98170 done
99171 done
100172 done
101173done
102174
103- sof-kernel-log-check.sh " $KERNEL_CHECKPOINT "
104- exit $?
175+ echo " Wait for remove"
176+ # sleep 1000
177+ restore_topology
178+ mkdir -p " /var/tmp/$script_name "
179+ touch " $reboot_file "
180+ reboot_wrapper
0 commit comments