On Mon, Feb 21, 2022 at 08:57:43PM +0800, Coiby Xu wrote:
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
spec/kdumpctl_general_spec.sh | 65 +++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh
index 86894d8..a18aac0 100644
--- a/spec/kdumpctl_general_spec.sh
+++ b/spec/kdumpctl_general_spec.sh
@@ -99,4 +99,69 @@ Describe 'kdumpctl'
End
End
+ Describe '_add_kernel_arg_in_grub_etc_default()'
+ GRUB_ETC_DEFAULT=/tmp/default_grub
+
+ Context 'when the given parameter is in different positions'
+ Parameters
+ "crashkernel=222M fadump=on rhgb quiet" crashkernel 333M 222M
^^^^
+ " fadump=on crashkernel=222M rhgb quiet" crashkernel
333M 222M
^^^^
+ "fadump=on rhgb quiet crashkernel=222M" crashkernel
333M 222M
^^^^
+ "fadump=on rhgb quiet" crashkernel 333M
+ "fadump=on foo=bar1 rhgb quiet" foo bar2 bar1
^^^^
+ End
Shouldn't these parameters be removed? I see from
the following test
case, only "$2=$3\" is used, so the "$4" parameters should be removed
for avoid misleading.
> +
> + It 'should update the kernel parameter correctly'
> + echo 'GRUB_CMDLINE_LINUX="'"$1"'"'
>$GRUB_ETC_DEFAULT
> + When call _add_kernel_arg_in_grub_etc_default "$2" "$3"
> + # the updated kernel parameter should appear in the end
> + The contents of file $GRUB_ETC_DEFAULT should include "$2=$3\""
+ End
> + End
> +
> + It 'should only update the given parameter and not update the parameter that
has the given parameter as suffix'
> + echo 'GRUB_CMDLINE_LINUX="fadump=on rhgb quiet
ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT
> + _ck_val=1G-4G:192M,4G-64G:256M,64G-102400T:512M
> + When call _add_kernel_arg_in_grub_etc_default crashkernel "$_ck_val"
> + The contents of file $GRUB_ETC_DEFAULT should include
"crashkernel=$_ck_val\""
> + The contents of file $GRUB_ETC_DEFAULT should include
"ckcrashkernel=222M"
> + End
> +
> +
> + It 'should be able to handle the cases of there are multiple crashkernel
entries'
> + echo 'GRUB_CMDLINE_LINUX="fadump=on rhgb quiet crashkernel=101M
crashkernel=222M"' >$GRUB_ETC_DEFAULT
> + _ck_val=1G-4G:192M,4G-64G:256M,64G-102400T:512M
> + When call _add_kernel_arg_in_grub_etc_default crashkernel "$_ck_val"
> + The contents of file $GRUB_ETC_DEFAULT should include
"crashkernel=$_ck_val\""
> + The contents of file $GRUB_ETC_DEFAULT should not include
"crashkernel=222M"
> + End
> +
> + End
> +
> +
> + Describe '_remove_kernel_arg_in_grub_etc_default()'
> + GRUB_ETC_DEFAULT=/tmp/default_grub
> + It 'should remove all values for given arg'
> + echo 'GRUB_CMDLINE_LINUX="crashkernel=33M crashkernel=11M fadump=on
crashkernel=222M"' >$GRUB_ETC_DEFAULT
> + When call _remove_kernel_arg_in_grub_etc_default crashkernel
> + The contents of file $GRUB_ETC_DEFAULT should equal
'GRUB_CMDLINE_LINUX="fadump=on"'
> + End
> +
> + It 'should not remove args that have the given arg as suffix'
> + echo 'GRUB_CMDLINE_LINUX="ckcrashkernel=33M crashkernel=11M
ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT
> + When call _remove_kernel_arg_in_grub_etc_default crashkernel
> + The contents of file $GRUB_ETC_DEFAULT should equal
'GRUB_CMDLINE_LINUX="ckcrashkernel=33M ckcrashkernel=222M"'
> + End
> + End
> +
> +
> + Describe '_read_kernel_arg_in_grub_etc_default()'
> + GRUB_ETC_DEFAULT=/tmp/default_grub
> + It 'should read the value for given arg'
> + echo 'GRUB_CMDLINE_LINUX="crashkernel=33M crashkernel=11M
ckcrashkernel=222M"' >$GRUB_ETC_DEFAULT
> + When call _read_kernel_arg_in_grub_etc_default crashkernel
> + The output should equal '11M'
> + End
> + End
For the above $GRUB_ETC_DEFAULT should be cleaned after test.
+
End
--
2.34.1
_______________________________________________
kexec mailing list -- kexec(a)lists.fedoraproject.org
To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure