diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index 6ee6a401fa..2592da9ce5 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "slices" "strconv" "strings" @@ -1049,7 +1050,7 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint container with --pre-checkpoint", func() { - if podmanTest.Host.Arch == "arm64" { + if runtime.GOARCH == "arm64" { Skip("skip on arm64/aarch64, https://github.com/checkpoint-restore/criu/issues/2676") } SkipIfContainerized("FIXME: #24230 - no longer works in container testing") @@ -1085,7 +1086,7 @@ var _ = Describe("Podman checkpoint", func() { }) It("podman checkpoint container with --pre-checkpoint and export (migration)", func() { - if podmanTest.Host.Arch == "arm64" { + if runtime.GOARCH == "arm64" { Skip("skip on arm64/aarch64, https://github.com/checkpoint-restore/criu/issues/2676") } SkipIfContainerized("FIXME: #24230 - no longer works in container testing") diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 398c7220c0..dddb31b1cb 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -21,6 +21,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "slices" "sort" "strconv" @@ -68,7 +69,6 @@ type PodmanTestIntegration struct { StorageOptions string SignaturePolicyPath string CgroupManager string - Host HostOS CliTmpDir string // value of podman --tmpdir } @@ -296,7 +296,6 @@ const ( // PodmanTestCreateUtil creates a PodmanTestIntegration instance for the tests func PodmanTestCreateUtil(tempDir string, target PodmanTestCreateUtilTarget) *PodmanTestIntegration { - host := GetHostDistributionInfo() cwd, _ := os.Getwd() root := filepath.Join(tempDir, "root") @@ -387,7 +386,6 @@ func PodmanTestCreateUtil(tempDir string, target PodmanTestCreateUtilTarget) *Po StorageOptions: storageOptions, SignaturePolicyPath: filepath.Join(INTEGRATION_ROOT, "test/policy.json"), CgroupManager: cgroupManager, - Host: host, } var pathPrefix string @@ -1828,7 +1826,7 @@ func skipWithoutDevNullb0() { } func SkipIfNotAMD64() { - if podmanTest.Host.Arch != "amd64" { + if runtime.GOARCH != "amd64" { Skip("test only valid on amd64") } } diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go index 36eb39801d..3a2673d0c7 100644 --- a/test/e2e/create_test.go +++ b/test/e2e/create_test.go @@ -168,7 +168,7 @@ var _ = Describe("Podman create", func() { }) It("podman create with --mount flag", func() { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("skip failing test on ppc64le") } diff --git a/test/e2e/history_test.go b/test/e2e/history_test.go index cd53b7ece9..8c632663ca 100644 --- a/test/e2e/history_test.go +++ b/test/e2e/history_test.go @@ -3,6 +3,8 @@ package integration import ( + "runtime" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "go.podman.io/podman/v6/test/utils" @@ -66,7 +68,7 @@ var _ = Describe("Podman history", func() { Expect(len(lines[1])).To(BeNumerically(">", 45)) // Size is different on other architectures - if podmanTest.Host.Arch == "amd64" { + if runtime.GOARCH == "amd64" { session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.Size}}", ALPINE}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) diff --git a/test/e2e/load_test.go b/test/e2e/load_test.go index efbbe5847d..9acac1ffcf 100644 --- a/test/e2e/load_test.go +++ b/test/e2e/load_test.go @@ -5,6 +5,7 @@ package integration import ( "fmt" "path/filepath" + "runtime" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -145,7 +146,7 @@ var _ = Describe("Podman load", func() { }) It("podman load multiple tags", func() { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("skip on ppc64le") } outfile := filepath.Join(podmanTest.TempDir, "alpine.tar") diff --git a/test/e2e/manifest_test.go b/test/e2e/manifest_test.go index 36b9c564b0..fb36a5b6b7 100644 --- a/test/e2e/manifest_test.go +++ b/test/e2e/manifest_test.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "strings" . "github.com/onsi/ginkgo/v2" @@ -196,7 +197,7 @@ var _ = Describe("Podman manifest", func() { }) It("push with --add-compression and --force-compression", func() { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } if isRootless() { diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index 98b8879655..b7d969e190 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -666,7 +666,7 @@ var _ = Describe("Podman pull", func() { It("From local registry", func() { SkipIfRemote("Remote pull does not support decryption") - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } diff --git a/test/e2e/push_test.go b/test/e2e/push_test.go index 9832efcde1..d78881521d 100644 --- a/test/e2e/push_test.go +++ b/test/e2e/push_test.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "strings" . "github.com/onsi/ginkgo/v2" @@ -95,7 +96,7 @@ var _ = Describe("Podman push", func() { }) It("push test --force-compression", func() { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } if isRootless() { @@ -152,7 +153,7 @@ var _ = Describe("Podman push", func() { }) It("push test --force-compression --format=v2s2", func() { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } if isRootless() { @@ -193,7 +194,7 @@ var _ = Describe("Podman push", func() { }) It("podman push to local registry", func() { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } if isRootless() { @@ -358,7 +359,7 @@ var _ = Describe("Podman push", func() { It("podman push to local registry with authorization", func() { SkipIfRootless("/etc/containers/certs.d not writable") - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } authPath := filepath.Join(podmanTest.TempDir, "auth") diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go index b1ea864e9a..02ebd6829f 100644 --- a/test/e2e/run_signal_test.go +++ b/test/e2e/run_signal_test.go @@ -7,6 +7,7 @@ import ( "io" "os" "path/filepath" + "runtime" "strings" "syscall" "time" @@ -24,7 +25,7 @@ const ( var _ = Describe("Podman run with --sig-proxy", func() { Specify("signals are forwarded to container using sig-proxy", func() { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("Doesn't work on ppc64le") } signal := syscall.SIGFPE diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index 2266a71e73..5429dbfebb 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -10,6 +10,7 @@ import ( "os" "path/filepath" "regexp" + "runtime" "strconv" "strings" "syscall" @@ -459,7 +460,7 @@ var _ = Describe("Podman run", func() { session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(Not(BeEmpty())) Expect(session).Should(ExitCleanly()) - if podmanTest.Host.Arch == "amd64" { + if runtime.GOARCH == "amd64" { session = podmanTest.Podman([]string{"exec", "maskCtr2", "ls", "/proc/acpi"}) session.WaitWithDefaultTimeout() Expect(session.OutputToString()).To(Not(BeEmpty())) @@ -495,7 +496,7 @@ var _ = Describe("Podman run", func() { Expect(session).Should(ExitCleanly()) Expect(session.OutputToStringArray()).Should(HaveLen(1)) - if podmanTest.Host.Arch == "amd64" { + if runtime.GOARCH == "amd64" { session = podmanTest.Podman([]string{"run", "--security-opt", "unmask=/proc/a*", ALPINE, "ls", "/proc/acpi"}) session.WaitWithDefaultTimeout() Expect(session).Should(ExitCleanly()) @@ -2286,7 +2287,7 @@ WORKDIR /madethis`, BB) It("podman run and decrypt from local registry", func() { SkipIfRemote("Remote run does not support decryption") - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go index eab77368ae..a302365f24 100644 --- a/test/e2e/run_volume_test.go +++ b/test/e2e/run_volume_test.go @@ -9,6 +9,7 @@ import ( "os/exec" "os/user" "path/filepath" + "runtime" "strconv" "strings" @@ -68,7 +69,7 @@ var _ = Describe("Podman run with volumes", func() { }) It("podman run with --mount flag", func() { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("skip failing test on ppc64le") } mountPath := filepath.Join(podmanTest.TempDir, "secrets") diff --git a/test/e2e/save_test.go b/test/e2e/save_test.go index e56fa382dc..2a072c2ed7 100644 --- a/test/e2e/save_test.go +++ b/test/e2e/save_test.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strconv" "strings" @@ -121,7 +122,7 @@ var _ = Describe("Podman save", func() { It("podman save remove signature", func() { podmanTest.AddImageToRWStore(ALPINE) SkipIfRootless("FIXME: Need get in rootless push sign") - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } tempGNUPGHOME := filepath.Join(podmanTest.TempDir, "tmpGPG") diff --git a/test/e2e/search_test.go b/test/e2e/search_test.go index 998e69f8f0..efb21a8f6b 100644 --- a/test/e2e/search_test.go +++ b/test/e2e/search_test.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "os" + "runtime" "strconv" "text/template" @@ -44,7 +45,7 @@ insecure = false registryFileBadTmpl := template.Must(template.New("registryFileBad").Parse(badRegFileContents)) mockFakeRegistryServerAsContainer := func(name string) endpoint { - if podmanTest.Host.Arch == "ppc64le" { + if runtime.GOARCH == "ppc64le" { Skip("No registry image for ppc64le") } port := GetPort() diff --git a/test/utils/common_function_test.go b/test/utils/common_function_test.go index 464b3496f6..b22297f152 100644 --- a/test/utils/common_function_test.go +++ b/test/utils/common_function_test.go @@ -33,27 +33,20 @@ var _ = Describe("Common functions test", func() { }) DescribeTable("Test GetHostDistributionInfo", - func(path, id, ver string, empty bool) { + func(path, id, ver string) { txt := fmt.Sprintf("ID=%s\nVERSION_ID=%s", id, ver) - if !empty { - f, _ := os.Create(path) - _, err := f.WriteString(txt) - Expect(err).ToNot(HaveOccurred(), "Failed to write data.") - f.Close() - } + f, _ := os.Create(path) + _, err := f.WriteString(txt) + Expect(err).ToNot(HaveOccurred(), "Failed to write data.") + f.Close() OSReleasePath = path host := GetHostDistributionInfo() - if empty { - Expect(host).To(Equal(HostOS{}), "HostOs should be empty.") - } else { - Expect(host.Distribution).To(Equal(strings.Trim(id, "\""))) - Expect(host.Version).To(Equal(strings.Trim(ver, "\""))) - } + Expect(host.Distribution).To(Equal(strings.Trim(id, "\""))) + Expect(host.Version).To(Equal(strings.Trim(ver, "\""))) }, - Entry("Configure file is not exist.", "/tmp/nonexistent", "", "", true), - Entry("Item value with and without \"", "/tmp/os-release.test", "fedora", "\"28\"", false), - Entry("Item empty with and without \"", "/tmp/os-release.test", "", "\"\"", false), + Entry("Item value with and without \"", "/tmp/os-release.test", "fedora", "\"28\""), + Entry("Item empty with and without \"", "/tmp/os-release.test", "", "\"\""), ) DescribeTable("Test TestIsCommandAvailable", diff --git a/test/utils/utils.go b/test/utils/utils.go index 0f4a319112..b5e75fb15d 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -12,7 +12,6 @@ import ( "math/rand" "os" "os/exec" - "runtime" "strings" "syscall" "time" @@ -78,7 +77,6 @@ type PodmanSession struct { type HostOS struct { Distribution string Version string - Arch string } // MakeOptions assembles all podman options @@ -397,14 +395,11 @@ func tagOutputToMap(imagesOutput []string) map[string]map[string]bool { // GetHostDistributionInfo returns a struct with its distribution Name and version func GetHostDistributionInfo() HostOS { f, err := os.Open(OSReleasePath) - if err != nil { - return HostOS{} - } + Expect(err).ToNot(HaveOccurred(), "open %s", OSReleasePath) defer f.Close() l := bufio.NewScanner(f) host := HostOS{} - host.Arch = runtime.GOARCH for l.Scan() { if strings.HasPrefix(l.Text(), "ID=") { host.Distribution = strings.ReplaceAll(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "") @@ -413,6 +408,8 @@ func GetHostDistributionInfo() HostOS { host.Version = strings.ReplaceAll(strings.TrimSpace(strings.Join(strings.Split(l.Text(), "=")[1:], "")), "\"", "") } } + err = l.Err() + Expect(err).ToNot(HaveOccurred(), "read %s", OSReleasePath) return host }