From 7862a5faf6465c890f05032fa1425b6a3e3b9640 Mon Sep 17 00:00:00 2001 From: Matus Marhefka Date: Thu, 17 Aug 2023 11:16:36 +0200 Subject: [PATCH] Update kernel_build_config templated scenarios to work in container env --- shared/templates/kernel_build_config/tests/common.sh | 6 ++++++ .../kernel_build_config/tests/extra_quotes.fail.sh | 2 ++ shared/templates/kernel_build_config/tests/fail1.fail.sh | 2 ++ .../kernel_build_config/tests/fail1_multiple_files.fail.sh | 5 +++-- shared/templates/kernel_build_config/tests/fail2.fail.sh | 2 ++ shared/templates/kernel_build_config/tests/pass1.pass.sh | 2 ++ shared/templates/kernel_build_config/tests/pass2.pass.sh | 2 ++ .../templates/kernel_build_config/tests/substrings.fail.sh | 2 ++ 8 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 shared/templates/kernel_build_config/tests/common.sh diff --git a/shared/templates/kernel_build_config/tests/common.sh b/shared/templates/kernel_build_config/tests/common.sh new file mode 100644 index 00000000000..4fd8fedb41c --- /dev/null +++ b/shared/templates/kernel_build_config/tests/common.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +if [ ! -e /boot/config-$(uname -r) ]; then + mkdir -p /boot + touch /boot/config-$(uname -r) +fi diff --git a/shared/templates/kernel_build_config/tests/extra_quotes.fail.sh b/shared/templates/kernel_build_config/tests/extra_quotes.fail.sh index eac1a6f60c0..48d7c70372d 100644 --- a/shared/templates/kernel_build_config/tests/extra_quotes.fail.sh +++ b/shared/templates/kernel_build_config/tests/extra_quotes.fail.sh @@ -1,6 +1,8 @@ #!/bin/bash # remediation = none +source common.sh + # The sets up a config file with extra double quotes {{%- if VARIABLE %}} diff --git a/shared/templates/kernel_build_config/tests/fail1.fail.sh b/shared/templates/kernel_build_config/tests/fail1.fail.sh index fdfd99e43a6..6a5b528fcb1 100644 --- a/shared/templates/kernel_build_config/tests/fail1.fail.sh +++ b/shared/templates/kernel_build_config/tests/fail1.fail.sh @@ -5,6 +5,8 @@ {{%- set VALUE="correct_value" %}} {{%- endif %}} +source common.sh + # fail1 is the plain expected fail scenario, the config with a wrong value for file in /boot/config-* ; do diff --git a/shared/templates/kernel_build_config/tests/fail1_multiple_files.fail.sh b/shared/templates/kernel_build_config/tests/fail1_multiple_files.fail.sh index f38f8c3d73d..9b76c8f59fc 100644 --- a/shared/templates/kernel_build_config/tests/fail1_multiple_files.fail.sh +++ b/shared/templates/kernel_build_config/tests/fail1_multiple_files.fail.sh @@ -5,6 +5,8 @@ {{%- set VALUE="correct_value" %}} {{%- endif %}} +source common.sh + # fail1 is the plain expected fail scenario, the config with a wrong value for file in /boot/config-* ; do if grep -q ^{{{ CONFIG }}} "$file" ; then @@ -15,6 +17,5 @@ for file in /boot/config-* ; do done # Ensure one config file is compliant -cp /boot/config-$(uname -r ) /boot/config-test +touch /boot/config-test sed -i "s/{{{ CONFIG }}}.*/{{{ CONFIG }}}={{{ VALUE }}}/" /boot/config-test - diff --git a/shared/templates/kernel_build_config/tests/fail2.fail.sh b/shared/templates/kernel_build_config/tests/fail2.fail.sh index 6d6caf5073b..99654f911f2 100644 --- a/shared/templates/kernel_build_config/tests/fail2.fail.sh +++ b/shared/templates/kernel_build_config/tests/fail2.fail.sh @@ -1,6 +1,8 @@ #!/bin/bash # remediation = none +source common.sh + # fail2 is the second fail scenario {{%- if VALUE == "n" %}} diff --git a/shared/templates/kernel_build_config/tests/pass1.pass.sh b/shared/templates/kernel_build_config/tests/pass1.pass.sh index 37689b014e7..1b1188af7f8 100644 --- a/shared/templates/kernel_build_config/tests/pass1.pass.sh +++ b/shared/templates/kernel_build_config/tests/pass1.pass.sh @@ -1,5 +1,7 @@ #!/bin/bash +source common.sh + # pass1 is the plain expected pass scenario {{%- if VALUE == "n" %}} diff --git a/shared/templates/kernel_build_config/tests/pass2.pass.sh b/shared/templates/kernel_build_config/tests/pass2.pass.sh index 21bde5143e4..72d464e2894 100644 --- a/shared/templates/kernel_build_config/tests/pass2.pass.sh +++ b/shared/templates/kernel_build_config/tests/pass2.pass.sh @@ -1,5 +1,7 @@ #!/bin/bash +source common.sh + # pass 2 is the second pass scenario {{%- if VALUE == "n" %}} diff --git a/shared/templates/kernel_build_config/tests/substrings.fail.sh b/shared/templates/kernel_build_config/tests/substrings.fail.sh index 4c265a61533..de394903fa2 100644 --- a/shared/templates/kernel_build_config/tests/substrings.fail.sh +++ b/shared/templates/kernel_build_config/tests/substrings.fail.sh @@ -10,6 +10,8 @@ {{%- set SUPER_VALUE='XYZ' ~ VALUE %}} {{%- endif %}} +source common.sh + for file in /boot/config-* ; do if grep -q ^{{{ CONFIG }}} "$file" ; then sed -i "s/{{{ CONFIG }}}.*/{{{ CONFIG }}}={{{ SUPER_VALUE }}}/" "$file"