From 2f52973feb59e9aee3a7d9dbac45b1fa1e513889 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Wed, 6 Sep 2023 10:49:49 +0200 Subject: [PATCH] unit tests: Fix parse_config test case The test case for parse_config creates a default kdump.conf in the pwd. This fails when the pwd is read only. Thus move the default kdump.conf to /tmp just like it is done for the "bad" kdump.conf. This also allows to reuse the temporary file used for the "bad" case. Signed-off-by: Philipp Rudo --- spec/kdumpctl_general_spec.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/spec/kdumpctl_general_spec.sh b/spec/kdumpctl_general_spec.sh index dcac2f8..243aeca 100644 --- a/spec/kdumpctl_general_spec.sh +++ b/spec/kdumpctl_general_spec.sh @@ -173,16 +173,14 @@ Describe 'kdumpctl' End Describe 'parse_config()' - bad_kdump_conf=$(mktemp -t bad_kdump_conf.XXXXXXXXXX) + KDUMP_CONFIG_FILE=$(mktemp -t kdump_conf.XXXXXXXXXX) cleanup() { - rm -f "$bad_kdump_conf" - rm -f kdump.conf + rm -f "$KDUMP_CONFIG_FILE" } AfterAll 'cleanup' It 'should not be happy with unkown option in kdump.conf' - KDUMP_CONFIG_FILE="$bad_kdump_conf" - echo blabla > "$bad_kdump_conf" + echo blabla > "$KDUMP_CONFIG_FILE" When call parse_config The status should be failure The stderr should include 'Invalid kdump config option blabla' @@ -191,10 +189,7 @@ Describe 'kdumpctl' Parameters:value aarch64 ppc64le s390x x86_64 It 'should be happy with the default kdump.conf' - ./gen-kdump-conf.sh "$1" > kdump.conf - # shellcheck disable=SC2034 - # override the KDUMP_CONFIG_FILE variable - KDUMP_CONFIG_FILE=./kdump.conf + ./gen-kdump-conf.sh "$1" > "$KDUMP_CONFIG_FILE" When call parse_config The status should be success End