Files
podman/pkg/specgenutil/specgenutil_windows_test.go
Paul Holzinger 5c1ed12d8d enable gofumpt formatter
Based on our discussion gofumpt won the vote so use that one via
golangci-lint.

https://github.com/containers/podman/discussions/27291

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-11-11 12:32:46 +01:00

56 lines
1.3 KiB
Go

//go:build windows
package specgenutil
import (
"os"
"testing"
"github.com/containers/podman/v6/pkg/domain/entities"
"github.com/containers/podman/v6/pkg/specgen"
"github.com/stretchr/testify/assert"
)
func TestSeccompProfilePath(t *testing.T) {
cwd, err := os.Getwd()
assert.NoError(t, err)
cwd_wsl, err := specgen.ConvertWinMountPath(cwd)
assert.NoError(t, err)
tests := []struct {
originalPath string
expectedPath string
}{
{`C:\Foo`, "/mnt/c/Foo"},
{`C:\Foo`, "/mnt/c/Foo"},
{`\\?\C:\Foo`, "/mnt/c/Foo"},
{`/c/bar`, "/mnt/c/bar"},
{`/c/bar`, "/mnt/c/bar"},
{`/mnt/c/bar`, "/mnt/c/bar"},
{`/test/this`, "/test/this"},
{`c:/bar/something`, "/mnt/c/bar/something"},
{`c`, cwd_wsl + "/c"},
{`\\computer\loc`, `\\computer\loc`},
{`\\.\drive\loc`, "/mnt/wsl/drive/loc"},
{"unconfined", "unconfined"},
}
f := func(secopt string) (*specgen.SpecGenerator, error) {
sg := specgen.NewSpecGenerator("nothing", false)
err := FillOutSpecGen(sg, &entities.ContainerCreateOptions{
SecurityOpt: []string{secopt},
}, []string{},
)
return sg, err
}
for _, test := range tests {
t.Run(test.originalPath, func(t *testing.T) {
msg := "Checking: " + test.originalPath
sg, err := f("seccomp=" + test.originalPath)
assert.NoError(t, err, msg)
assert.Equal(t, test.expectedPath, sg.SeccompProfilePath, msg)
})
}
}