Get rid of "grep: warning: stray \ before /"
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2242185
grep (3.8) warnings when running the unit tests or running
"kdumpctl reset-crashkernel" on >= F39,
# unit tests
Examples:
1) kdumpctl _find_kernel_path_by_release() returns the kernel path for the given release
When call _find_kernel_path_by_release vmlinuz-6.2.11-200.fc37.x86_64
1.1) WARNING: There was output to stderr but not found expectation
stderr: grep: warning: stray \ before /
# spec/kdumpctl_general_spec.sh:169-172
# kdumpctl reset-crashkernel
grep: warning: stray \ before /
kdump: Updated crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M for kernel=/boot/vmlinuz-6.6.8-200.fc39.x86_64. Please reboot the system for the change to take effect.
This warning can be reproduced by
echo 'kernel="/boot/vmlinuz-6.4.6-200.fc38.x86_64"' | grep -E "^kernel=.*$_release(\/\w+)?\"$"
This patch removes unneeded backslash. It also adds a test for
systemd-boot path. And for simplification, Parameters:dynamic is now
used to generate test data dynamically.
Fixes: 8af05dc4
("kdumpctl: Add support for systemd-boot paths")
Signed-off-by: Coiby Xu <coxu@redhat.com>
Reviewed-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
parent
95f086ca9f
commit
97b3b962a9
2
kdumpctl
2
kdumpctl
@ -1412,7 +1412,7 @@ _find_kernel_path_by_release()
|
|||||||
|
|
||||||
# Insert '/' before '+' to cope with grep's EREs
|
# Insert '/' before '+' to cope with grep's EREs
|
||||||
_release=${_release//+/\\+}
|
_release=${_release//+/\\+}
|
||||||
_grubby_kernel_str=$(grubby --info ALL | grep -E "^kernel=.*$_release(\/\w+)?\"$")
|
_grubby_kernel_str=$(grubby --info ALL | grep -E "^kernel=.*$_release(/\w+)?\"$")
|
||||||
_kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str")
|
_kernel_path=$(_filter_grubby_kernel_str "$_grubby_kernel_str")
|
||||||
if [[ -z $_kernel_path ]]; then
|
if [[ -z $_kernel_path ]]; then
|
||||||
ddebug "kernel $_release doesn't exist"
|
ddebug "kernel $_release doesn't exist"
|
||||||
|
@ -156,16 +156,32 @@ Describe 'kdumpctl'
|
|||||||
End
|
End
|
||||||
|
|
||||||
Describe '_find_kernel_path_by_release()'
|
Describe '_find_kernel_path_by_release()'
|
||||||
|
# When the array length changes, the Parameters:dynamic should change as well
|
||||||
|
kernel_paths=(/boot/vmlinuz-6.2.11-200.fc37.x86_64
|
||||||
|
/boot/vmlinuz-5.14.0-316.el9.aarch64+64k
|
||||||
|
/boot/vmlinuz-5.14.0-322.el9.aarch64
|
||||||
|
/boot/efi/36b54597c46383/6.4.0-0.rc0.20230427git6e98b09da931.5.fc39.aarch64/linux)
|
||||||
|
|
||||||
|
kernels=(vmlinuz-6.2.11-200.fc37.x86_64
|
||||||
|
vmlinuz-5.14.0-316.el9.aarch64+64k
|
||||||
|
vmlinuz-5.14.0-322.el9.aarch64
|
||||||
|
6.4.0-0.rc0.20230427git6e98b09da931.5.fc39.aarch64)
|
||||||
|
|
||||||
grubby() {
|
grubby() {
|
||||||
echo -e 'kernel="/boot/vmlinuz-6.2.11-200.fc37.x86_64"\nkernel="/boot/vmlinuz-5.14.0-322.el9.aarch64"\nkernel="/boot/vmlinuz-5.14.0-316.el9.aarch64+64k"'
|
for key in "${!kernel_paths[@]}"; do
|
||||||
|
echo "kernel=\"${kernel_paths[$key]}\""
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
Parameters
|
Parameters:dynamic
|
||||||
# parameter answer
|
# Due to a bug [1] in shellspec, hardcode the loop number instead of using the
|
||||||
vmlinuz-6.2.11-200.fc37.x86_64 /boot/vmlinuz-6.2.11-200.fc37.x86_64
|
# array length
|
||||||
vmlinuz-5.14.0-322.el9.aarch64 /boot/vmlinuz-5.14.0-322.el9.aarch64
|
# [1] https://github.com/shellspec/shellspec/issues/259
|
||||||
vmlinuz-5.14.0-316.el9.aarch64+64k /boot/vmlinuz-5.14.0-316.el9.aarch64+64k
|
for key in {0..3}; do
|
||||||
|
%data "${kernels[$key]}" "${kernel_paths[$key]}"
|
||||||
|
done
|
||||||
End
|
End
|
||||||
|
|
||||||
It 'returns the kernel path for the given release'
|
It 'returns the kernel path for the given release'
|
||||||
When call _find_kernel_path_by_release "$1"
|
When call _find_kernel_path_by_release "$1"
|
||||||
The output should equal "$2"
|
The output should equal "$2"
|
||||||
|
Loading…
Reference in New Issue
Block a user