Hi Coiby,
On Tue, 1 Mar 2022 14:17:27 +0800
Coiby Xu <coxu(a)redhat.com> wrote:
kdump_get_conf_val allows to retrieves config value defined in
kdump.conf and it also support "ext[234]\|xfs\|btrfs\|minix\|raw\|nfs\|ssh".
Signed-off-by: Coiby Xu <coxu(a)redhat.com>
---
spec/kdump-lib-initramfs_spec.sh | 41 ++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 spec/kdump-lib-initramfs_spec.sh
diff --git a/spec/kdump-lib-initramfs_spec.sh b/spec/kdump-lib-initramfs_spec.sh
new file mode 100644
index 0000000..4d0a185
--- /dev/null
+++ b/spec/kdump-lib-initramfs_spec.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+ExampleGroup 'kdump-lib-initramfs'
Is there a reason why you are using ExampleGroup here instead of
Context? If not I would prefer to use Context just to be consisted with
the other test cases.
Thanks
Philipp
+ Include ./kdump-lib-initramfs.sh
+
+ ExampleGroup 'Test kdump_get_conf_val'
+ KDUMP_CONFIG_FILE=/tmp/kdump_shellspec_test.conf
+ kdump_config() {
+ %text
+ #|default shell
+ #|nfs my.server.com:/export/tmp # trailing comment
+ #| failure_action shell
+ #|dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2
ext3"
+ #|sshkey /root/.ssh/kdump_id_rsa
+ #|ssh user(a)my.server.com
+ }
+ kdump_config >$KDUMP_CONFIG_FILE
+ ExampleGroup
+ # Test the following cases:
+ # - there is trailing comment
+ # - there is space before the parameter
+ # - complicate value for dracut_args
+ # - Given two parameters, retrive one parameter that has value specified
+ # - Given two parameters (in reverse order), retrive one parameter that has value
specified
+ Parameters
+ "#1" nfs my.server.com:/export/tmp
+ "#2" ssh user(a)my.server.com
+ "#3" failure_action shell
+ "#4" dracut_args '--omit-drivers "cfg80211 snd"
--add-drivers "ext2 ext3"'
+ "#5" 'ssh\|aaa' user(a)my.server.com
+ "#6" 'aaa\|ssh' user(a)my.server.com
+ End
+
+ Example 'Get a kernel parameter in different positions'
+ When call kdump_get_conf_val "$2"
+ The output should equal "$3"
+ End
+ End
+
+ End
+
+End