Skip to content

Commit 777fa66

Browse files
committed
[DNM] reboot test
Signed-off-by: Pawel Langowski <pawelx.langowski@intel.com>
1 parent 5124961 commit 777fa66

File tree

2 files changed

+86
-6
lines changed

2 files changed

+86
-6
lines changed

test-case/check-capture.sh

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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
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,11 +62,77 @@ duration=${OPT_VAL['d']}
5662
loop_cnt=${OPT_VAL['l']}
5763
out_dir=${OPT_VAL['o']}
5864
file_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
60122
start_test
61-
logger_disabled || func_lib_start_log_collect
123+
if [ ! -f "$reboot_file" ]; then
124+
logger_disabled || func_lib_start_log_collect
125+
fi
62126

63127
setup_kernel_check_point
128+
129+
if [ -f $reboot_file ]; then
130+
dlogi "System rebooted"
131+
rm "$reboot_file"
132+
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT"
133+
exit $?
134+
fi
135+
64136
func_lib_check_sudo
65137
func_pipeline_export "$tplg" "type:capture & ${OPT_VAL['S']}"
66138

@@ -90,15 +162,21 @@ do
90162
dlogi "using $file as capture output"
91163
fi
92164

93-
if ! arecord_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" -d "$duration" "$file" -v -q;
165+
# Ensure the sample rate is set correctly
166+
if ! arecord_opts -D"$dev" -r "$samplerate" -c "$channel" -f "$fmt_elem" -d "$duration" "$file" -v -q;
94167
then
95168
func_lib_lsof_error_dump "$snd"
169+
echo "arecord on PCM $dev failed at $i/$loop_cnt."
96170
die "arecord on PCM $dev failed at $i/$loop_cnt."
97171
fi
98172
done
99173
done
100174
done
101175
done
102176

103-
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT"
104-
exit $?
177+
echo "Wait for remove"
178+
#sleep 1000
179+
restore_topology
180+
mkdir -p "/var/tmp/$script_name"
181+
touch "$reboot_file"
182+
reboot_wrapper

test-case/verify-kernel-module-load-probe.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ lsmod | grep "sof" || {
2929
lsmod
3030
die "No available sof module found!"
3131
}
32+
33+
reboot_wrapper

0 commit comments

Comments
 (0)