From 8d1321c59ddb8db48c890acaecc250fa6705f4ae Mon Sep 17 00:00:00 2001 From: Mathieu Tortuyaux Date: Wed, 6 Jul 2022 15:01:19 +0200 Subject: [PATCH] test/selinux: update boolean name Signed-off-by: Mathieu Tortuyaux --- kola/tests/misc/selinux.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/kola/tests/misc/selinux.go b/kola/tests/misc/selinux.go index 6f5f5e66d..1dd55afd4 100644 --- a/kola/tests/misc/selinux.go +++ b/kola/tests/misc/selinux.go @@ -19,11 +19,14 @@ import ( "regexp" "strings" + "github.com/coreos/go-semver/semver" "github.com/flatcar/mantle/kola/cluster" "github.com/flatcar/mantle/kola/register" "github.com/flatcar/mantle/platform" ) +var seBoolean = "container_use_nfs" + func init() { register.Register(®ister.Test{ Run: SelinuxEnforce, @@ -40,6 +43,15 @@ func init() { Distros: []string{"cl", "fcos", "rhcos"}, // This test is normally not related to the cloud environment Platforms: []string{"qemu", "qemu-unpriv"}, + SkipFunc: func(version semver.Version, channel, arch, platform string) bool { + // Workaround to set the SELinux boolean name based of the Flatcar version. + // Note: it works only if we test '*' + if version.LessThan(semver.Version{Major: 3637}) { + seBoolean = "virt_use_nfs" + } + + return false + }, }) register.Register(®ister.Test{ Run: SelinuxBooleanPersist, @@ -48,6 +60,15 @@ func init() { Distros: []string{"fcos", "rhcos"}, // This test is normally not related to the cloud environment Platforms: []string{"qemu", "qemu-unpriv"}, + SkipFunc: func(version semver.Version, channel, arch, platform string) bool { + // Workaround to set the SELinux boolean name based of the Flatcar version. + // Note: it works only if we test '*' + if version.LessThan(semver.Version{Major: 3637}) { + seBoolean = "virt_use_nfs" + } + + return false + }, }) register.Register(®ister.Test{ Run: SelinuxManage, @@ -155,8 +176,6 @@ func SelinuxEnforce(c cluster.TestCluster) { // SelinuxBoolean checks that you can tweak a boolean in the current session func SelinuxBoolean(c cluster.TestCluster) { - seBoolean := "virt_use_nfs" - m := c.Machines()[0] tempBoolState, err := getSelinuxBooleanState(c, m, seBoolean) @@ -186,8 +205,6 @@ func SelinuxBoolean(c cluster.TestCluster) { // SelinuxBooleanPersist checks that you can tweak a boolean and have it // persist across reboots func SelinuxBooleanPersist(c cluster.TestCluster) { - seBoolean := "virt_use_nfs" - m := c.Machines()[0] persistBoolState, err := getSelinuxBooleanState(c, m, seBoolean)