Skip to content

Commit 3d6d976

Browse files
licliucoiby
authored andcommitted
unit tests: add test cases for 1 kernel with multiple grub entries
Add test cases for kdumpctl reset-crashkernel when there are multiple grub entries for one kernel. Add a new grub entry which has the same kernel with existing one but with different title. Signed-off-by: Lichen Liu <[email protected]>
1 parent 7e85781 commit 3d6d976

File tree

2 files changed

+105
-4
lines changed

2 files changed

+105
-4
lines changed

spec/kdumpctl_reset_crashkernel_spec.sh

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]'
33
Include ./kdumpctl
44
kernel1=/boot/vmlinuz-5.15.6-100.fc34.x86_64
55
kernel2=/boot/vmlinuz-5.14.14-200.fc34.x86_64
6+
kernel2_index1=1
7+
kernel2_index2=2
68
ck=222M
79
KDUMP_SPEC_TEST_RUN_DIR=$(mktemp -d /tmp/spec_test.XXXXXXXXXX)
810
current_kernel=5.15.6-100.fc34.x86_64
@@ -103,9 +105,34 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]'
103105
When call grubby --info "$kernel2"
104106
The line 3 of output should include crashkernel="$ck"
105107
End
108+
End
106109

110+
Context "one kernel have 2 grub entries, and the first one is modified"
111+
grubby --args crashkernel="$kdump_crashkernel" --update-kernel ALL
112+
grubby --args crashkernel="$ck" --update-kernel "$kernel2_index1"
113+
Specify 'kdumpctl should warn the user that crashkernel has been updated'
114+
When call reset_crashkernel --kernel="$kernel2"
115+
The error should include "Updated crashkernel=$kdump_crashkernel for kernel=$kernel2, grub entry index=$kernel2_index1"
116+
End
117+
Specify 'kernel2 should not have old crashkernel ck'
118+
When call grubby --info "$kernel2"
119+
The line 3 of output should not include crashkernel="$ck"
120+
End
107121
End
108122

123+
Context "one kernel have 2 grub entries, and the second one is modified"
124+
grubby --args crashkernel="$kdump_crashkernel" --update-kernel ALL
125+
grubby --args crashkernel="$ck" --update-kernel "$kernel2_index2"
126+
Specify 'kdumpctl should warn the user that crashkernel has been updated'
127+
When call reset_crashkernel --kernel="$kernel2"
128+
The error should include "Updated crashkernel=$kdump_crashkernel for kernel=$kernel2, grub entry index=$kernel2_index2"
129+
End
130+
131+
Specify 'kernel2 should not have old crashkernel ck'
132+
When call grubby --info "$kernel2"
133+
The line 3 of output should not include crashkernel="$ck"
134+
End
135+
End
109136
End
110137

111138
Describe "FADump" fadump
@@ -142,8 +169,8 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]'
142169
grubby --args crashkernel="$ck" --update-kernel ALL
143170
Specify 'kdumpctl should warn the user that crashkernel has been udpated'
144171
When call reset_crashkernel --kernel=ALL --fadump=on
145-
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1"
146-
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2"
172+
The error should include "Updated fadump=on and updated crashkernel=$fadump_crashkernel for kernel=$kernel1"
173+
The error should include "Updated fadump=on and updated crashkernel=$fadump_crashkernel for kernel=$kernel2"
147174
End
148175

149176
Specify 'kernel1 should have crashkernel updated'
@@ -176,6 +203,72 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]'
176203
End
177204
End
178205

206+
Context "multiple grub entries, and the 1st enabled fadump"
207+
grubby --args crashkernel="$kdump_crashkernel" --remove-args=fadump --update-kernel ALL
208+
grubby --args fadump=on --update-kernel "$kernel2_index1"
209+
Specify 'kdumpctl should warn the user that crashkernel has been updated'
210+
When call reset_crashkernel --kernel="$kernel2"
211+
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2, grub entry index=$kernel2_index1"
212+
End
213+
214+
Specify 'kernel2 index 2 should have old crashkernel'
215+
When call grubby --info "$kernel2_index2"
216+
The line 3 of output should include crashkernel="$kdump_crashkernel"
217+
End
218+
219+
Specify 'kdumpctl should warn the user that crashkernel has been updated'
220+
When call reset_crashkernel --kernel="$kernel2" --fadump=on
221+
The error should include "Updated fadump=on and updated crashkernel=$fadump_crashkernel for kernel=$kernel2, grub entry index=$kernel2_index2"
222+
End
223+
End
224+
225+
Context "multiple grub entries, and the 2nd is enabled fadump"
226+
grubby --args crashkernel="$kdump_crashkernel" --remove-args=fadump --update-kernel ALL
227+
grubby --args fadump=on --update-kernel "$kernel2_index2"
228+
Specify 'kdumpctl should warn the user that crashkernel has been updated'
229+
When call reset_crashkernel --kernel="$kernel2"
230+
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2, grub entry index=$kernel2_index2"
231+
End
232+
233+
Specify 'kernel2 index 1 should have old crashkernel'
234+
When call grubby --info "$kernel2_index1"
235+
The line 3 of output should include crashkernel="$kdump_crashkernel"
236+
End
237+
238+
Specify 'kdumpctl should warn the user that crashkernel has been updated'
239+
When call reset_crashkernel --kernel="$kernel2" --fadump=on
240+
The error should include "Updated fadump=on and updated crashkernel=$fadump_crashkernel for kernel=$kernel2, grub entry index=$kernel2_index1"
241+
End
242+
End
243+
244+
Context "multiple grub entries, and the 1st is enabled fadump with default crashkernel, --fadump=off"
245+
grubby --args crashkernel="$kdump_crashkernel" --remove-args=fadump --update-kernel "$kernel2_index2"
246+
grubby --args crashkernel="$fadump_crashkernel" --update-kernel "$kernel2_index1"
247+
Specify 'kdumpctl should warn the user that crashkernel has been updated'
248+
When call reset_crashkernel --kernel="$kernel2" --fadump=off
249+
The error should include "Removed fadump and updated crashkernel=$kdump_crashkernel for kernel=$kernel2, grub entry index=$kernel2_index1"
250+
End
251+
252+
Specify 'kernel2 index 1 should not have fadump'
253+
When call grubby --info "$kernel2_index1"
254+
The line 3 of output should not include fadump=on
255+
End
256+
End
257+
258+
Context "multiple grub entries, and the 2nd is enabled fadump with default crashkernel, --fadump=off"
259+
grubby --args crashkernel="$kdump_crashkernel" --remove-args=fadump --update-kernel "$kernel2_index1"
260+
grubby --args crashkernel="$fadump_crashkernel" --update-kernel "$kernel2_index2"
261+
Specify 'kdumpctl should warn the user that crashkernel has been updated'
262+
When call reset_crashkernel --kernel="$kernel2" --fadump=off
263+
The error should include "Removed fadump and updated crashkernel=$kdump_crashkernel for kernel=$kernel2, grub entry index=$kernel2_index2"
264+
End
265+
266+
Specify 'kernel2 index 2 should not have fadump crashkernel'
267+
When call grubby --info "$kernel2_index2"
268+
The line 3 of output should not include fadump=on
269+
End
270+
End
271+
179272
Context "Update all kernels but without --fadump specified"
180273
grubby --args crashkernel="$ck" --update-kernel ALL
181274
grubby --args fadump=on --update-kernel "$kernel1"
@@ -200,8 +293,8 @@ Describe 'kdumpctl reset-crashkernel [--kernel] [--fadump]'
200293
grubby --args fadump=on --update-kernel ALL
201294
Specify 'fadump=on to fadump=nocma'
202295
When call reset_crashkernel --kernel=ALL --fadump=nocma
203-
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel1"
204-
The error should include "Updated crashkernel=$fadump_crashkernel for kernel=$kernel2"
296+
The error should include "Updated fadump=nocma and updated crashkernel=$fadump_crashkernel for kernel=$kernel1"
297+
The error should include "Updated fadump=nocma and updated crashkernel=$fadump_crashkernel for kernel=$kernel2"
205298
End
206299

207300
Specify 'kernel1 should have fadump=nocma in cmdline'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title Dup Fedora (5.14.14-200.fc34.x86_64) 34 (Workstation Edition)
2+
version 5.14.14-200.fc34.x86_64
3+
linux /boot/vmlinuz-5.14.14-200.fc34.x86_64
4+
initrd /boot/initramfs-5.14.14-200.fc34.x86_64.img
5+
options root=UUID=45fdf703-3966-401b-b8f7-cf056affd2b0 ro rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 crashkernel=4G-16G:768M,16G-64G:1G,64G-128G:2G,128G-1T:4G,1T-2T:6G,2T-4T:12G,4T-8T:20G,8T-16T:36G,16T-32T:64G,32T-64T:128G,64T-102400T:180G fadump=on
6+
grub_users $grub_users
7+
grub_arg --unrestricted
8+
grub_class kernel

0 commit comments

Comments
 (0)