1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/oci/devices_linux_test.go
Sebastiaan van Stijn d414c0c1e8
replace uses of deprecated libcontainer/configs.Device
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-02 17:55:51 +02:00

31 lines
685 B
Go

package oci
import (
"os"
"testing"
"github.com/opencontainers/runc/libcontainer/devices"
"golang.org/x/sys/unix"
"gotest.tools/v3/assert"
)
func TestDeviceMode(t *testing.T) {
tests := []struct {
name string
in os.FileMode
out os.FileMode
}{
{name: "regular permissions", in: 0777, out: 0777},
{name: "block device", in: 0777 | unix.S_IFBLK, out: 0777},
{name: "character device", in: 0777 | unix.S_IFCHR, out: 0777},
{name: "fifo device", in: 0777 | unix.S_IFIFO, out: 0777},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
d := Device(&devices.Device{FileMode: tc.in})
assert.Equal(t, *d.FileMode, tc.out)
})
}
}