From b14e833ef625f95ee5ce4ac6c014f75ce6f0b85c Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 23 Apr 2026 19:15:13 +0200 Subject: [PATCH] machine: add test to check config mount Signed-off-by: Paul Holzinger --- pkg/machine/e2e/basic_test.go | 22 ++++++++++++++++++++++ pkg/machine/e2e/machine_test.go | 3 +++ 2 files changed, 25 insertions(+) diff --git a/pkg/machine/e2e/basic_test.go b/pkg/machine/e2e/basic_test.go index beb69f299b..a4f5cf55bb 100644 --- a/pkg/machine/e2e/basic_test.go +++ b/pkg/machine/e2e/basic_test.go @@ -19,6 +19,7 @@ import ( . "github.com/onsi/gomega/gexec" "go.podman.io/podman/v6/pkg/machine/define" "go.podman.io/podman/v6/version/rawversion" + "go.podman.io/storage/pkg/configfile" ) const TESTIMAGE = "quay.io/libpod/testimage:20241011" @@ -31,6 +32,27 @@ var _ = Describe("run basic podman commands", func() { Expect(err).ToNot(HaveOccurred()) Expect(session).To(Exit(0)) + // Check that we mount the host config dir to the machine /etc/containers and and can write content from the host there. + path, err := configfile.UserConfigPath() + Expect(err).ToNot(HaveOccurred()) + err = os.MkdirAll(path, 0o755) + Expect(err).ToNot(HaveOccurred()) + + content := randomString() + f, err := os.Create(filepath.Join(path, "podman-machine-tmpfile")) + Expect(err).ToNot(HaveOccurred()) + _, err = f.WriteString(content) + Expect(err).ToNot(HaveOccurred()) + err = f.Close() + Expect(err).ToNot(HaveOccurred()) + + ssh := new(sshMachine).withSSHCommand([]string{"cat /etc/containers/podman-machine-tmpfile"}) + sshRun, err := mb.setName(name).setCmd(ssh).run() + Expect(err).ToNot(HaveOccurred()) + Expect(sshRun).To(Exit(0)) + Expect(sshRun.outputToString()).To(Equal(content)) + + // check some basic podman commands bm := basicMachine{} imgs, err := mb.setCmd(bm.withPodmanCommand([]string{"images", "-q"})).run() Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/machine/e2e/machine_test.go b/pkg/machine/e2e/machine_test.go index 0ae27a5263..a955f5ee2f 100644 --- a/pkg/machine/e2e/machine_test.go +++ b/pkg/machine/e2e/machine_test.go @@ -150,6 +150,9 @@ func setup() (string, *machineTestBuilder) { Fail("unable to set home dir on windows") } } + if err := os.Setenv("XDG_CONFIG_HOME", filepath.Join(homeDir, ".config")); err != nil { + Fail("failed to set XDG_CONFIG_HOME dir") + } if err := os.Setenv("XDG_RUNTIME_DIR", homeDir); err != nil { Fail("failed to set xdg_runtime dir") }