mirror of
https://github.com/containers/podman.git
synced 2025-09-18 07:51:22 +08:00

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>
30 lines
680 B
Go
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)
|
|
}
|
|
}
|