Files
podman/pkg/specgen/generate/config_common_test.go
Doug Rabson d50054f1e4 pkg/specgen: Add device support for FreeBSD
On FreeBSD, each container has its own devfs instance with a ruleset
that controls what the container can see. To expose devices to a
container we add rules to its devfs to make the requested devices
visible. For privileged containers, we use 'ruleset=0' which makes
everything visible.

This shares the ParseDevice function with Linux so it moves to
config_common.go from config_linux.go.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-08-04 10:11:14 +01:00

30 lines
680 B
Go

package generate
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseDevice(t *testing.T) {
tests := []struct {
device string
src string
dst string
perm string
}{
{"/dev/foo", "/dev/foo", "/dev/foo", "rwm"},
{"/dev/foo:/dev/bar", "/dev/foo", "/dev/bar", "rwm"},
{"/dev/foo:/dev/bar:rw", "/dev/foo", "/dev/bar", "rw"},
{"/dev/foo:rw", "/dev/foo", "/dev/foo", "rw"},
{"/dev/foo::rw", "/dev/foo", "/dev/foo", "rw"},
}
for _, test := range tests {
src, dst, perm, err := ParseDevice(test.device)
assert.NoError(t, err)
assert.Equal(t, src, test.src)
assert.Equal(t, dst, test.dst)
assert.Equal(t, perm, test.perm)
}
}