prepare_cmdline is totally broken. For example if the remove list ($2)
is empty it removes all white spaces or if a parameter has a quoted
value containing a white space it only removes the first part of the
parameter up to the first space. Thus add a test case that shows what the
function should do in order to fix it in subsequent patches.
Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
---
spec/kdump-lib_spec.sh | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh
index 8c91480..3d10006 100644
--- a/spec/kdump-lib_spec.sh
+++ b/spec/kdump-lib_spec.sh
@@ -48,4 +48,36 @@ Describe 'kdump-lib'
End
End
+ Describe 'prepare_cmdline()'
+ get_bootcpu_apicid() {
+ echo 1
+ }
+
+ get_watchdog_drvs() {
+ echo foo
+ }
+
+ add="disable_cpu_apicid=1 foo.pretimeout=0"
+
+ Parameters
+ #test cmdline remove add result
+ "#1" "a b c" "" ""
"a b c"
+ "#2" "a b c" "b" ""
"a c"
+ "#3" "a b=x c" "b" ""
"a c"
+ "#4" "a b='x y' c" "b" ""
"a c"
+ "#5" "a b='x y' c" "b=x" ""
"a c"
+ "#6" "a b='x y' c" "b='x y'"
"" "a c"
+ "#7" "a b c" "" "x"
"a b c x"
+ "#8" "a b c" "" "x=1"
"a b c x=1"
+ "#9" "a b c" "" "x='1
2'" "a b c x='1 2'"
+ "#10" "a b c" "a" "x='1
2'" "b c x='1 2'"
+ "#11" "a b c" "x" "x='1
2'" "a b c x='1 2'"
+ End
+
+ It "Test $1: should generate the correct kernel command line"
+ When call prepare_cmdline "$2" "$3" "$4"
+ The output should equal "$5 $add"
+ End
+ End
+
End
--
2.39.0