mirror of
https://github.com/containers/podman.git
synced 2025-09-17 06:47:10 +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>
29 lines
677 B
Go
29 lines
677 B
Go
package generate
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestShouldMask(t *testing.T) {
|
|
tests := []struct {
|
|
mask string
|
|
unmask []string
|
|
shouldMask bool
|
|
}{
|
|
{"/proc/foo", []string{"all"}, false},
|
|
{"/proc/foo", []string{"ALL"}, false},
|
|
{"/proc/foo", []string{"/proc/foo"}, false},
|
|
{"/proc/foo", []string{"/proc/*"}, false},
|
|
{"/proc/foo", []string{"/proc/bar", "all"}, false},
|
|
{"/proc/foo", []string{"/proc/f*"}, false},
|
|
{"/proc/foo", []string{"/proc/b*"}, true},
|
|
{"/proc/foo", []string{}, true},
|
|
}
|
|
for _, test := range tests {
|
|
val := shouldMask(test.mask, test.unmask)
|
|
assert.Equal(t, val, test.shouldMask)
|
|
}
|
|
}
|