Skip to content

Commit

Permalink
Update kernel_build_config templated scenarios to work in container env
Browse files Browse the repository at this point in the history
  • Loading branch information
matusmarhefka committed Aug 17, 2023
1 parent 07d772c commit 7862a5f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions shared/templates/kernel_build_config/tests/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

if [ ! -e /boot/config-$(uname -r) ]; then
mkdir -p /boot
touch /boot/config-$(uname -r)
fi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
# remediation = none

source common.sh

# The sets up a config file with extra double quotes

{{%- if VARIABLE %}}
Expand Down
2 changes: 2 additions & 0 deletions shared/templates/kernel_build_config/tests/fail1.fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

2 changes: 2 additions & 0 deletions shared/templates/kernel_build_config/tests/fail2.fail.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
# remediation = none

source common.sh

# fail2 is the second fail scenario

{{%- if VALUE == "n" %}}
Expand Down
2 changes: 2 additions & 0 deletions shared/templates/kernel_build_config/tests/pass1.pass.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source common.sh

# pass1 is the plain expected pass scenario

{{%- if VALUE == "n" %}}
Expand Down
2 changes: 2 additions & 0 deletions shared/templates/kernel_build_config/tests/pass2.pass.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source common.sh

# pass 2 is the second pass scenario

{{%- if VALUE == "n" %}}
Expand Down
2 changes: 2 additions & 0 deletions shared/templates/kernel_build_config/tests/substrings.fail.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7862a5f

Please sign in to comment.