From 3d4cb38d96e45cf5da1460daf3345dd318fdee2f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 7 Jan 2022 16:00:08 +0800 Subject: [PATCH] unit tests: add check_config with with the default kdump.conf This test prevents the mistake of adding an option to kdump.conf without changing check_config as is the case with commit 73ced7f ("introduce the auto_reset_crashkernel option to kdump.conf"). Reviewed-by: Philipp Rudo Signed-off-by: Coiby Xu --- spec/kdumpctl_general_spec.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index e72bf1d..5a3ce1c 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -174,4 +174,29 @@ Describe 'kdumpctl' End End + Describe 'parse_config()' + bad_kdump_conf=$(mktemp -t bad_kdump_conf.XXXXXXXXXX) + cleanup() { + rm -f "$bad_kdump_conf" + } + AfterAll 'cleanup' + + It 'should not be happy with unkown option in kdump.conf' + KDUMP_CONFIG_FILE="$bad_kdump_conf" + echo blabla > "$bad_kdump_conf" + When call parse_config + The status should be failure + The stderr should include 'Invalid kdump config option blabla' + End + + It 'should be happy with the default kdump.conf' + # shellcheck disable=SC2034 + # override the KDUMP_CONFIG_FILE variable + KDUMP_CONFIG_FILE=./kdump.conf + When call parse_config + The status should be success + End + + End + End