machine: add test to check config mount

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2026-04-23 19:15:13 +02:00
parent 5e193ce96a
commit b14e833ef6
2 changed files with 25 additions and 0 deletions

View File

@@ -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())

View File

@@ -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")
}