github.com/adityamillind98/moby@v23.0.0-rc.4+incompatible/oci/devices_linux_test.go (about)

     1  package oci
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/opencontainers/runc/libcontainer/devices"
     8  	"golang.org/x/sys/unix"
     9  	"gotest.tools/v3/assert"
    10  )
    11  
    12  func TestDeviceMode(t *testing.T) {
    13  	tests := []struct {
    14  		name string
    15  		in   os.FileMode
    16  		out  os.FileMode
    17  	}{
    18  		{name: "regular permissions", in: 0777, out: 0777},
    19  		{name: "block device", in: 0777 | unix.S_IFBLK, out: 0777},
    20  		{name: "character device", in: 0777 | unix.S_IFCHR, out: 0777},
    21  		{name: "fifo device", in: 0777 | unix.S_IFIFO, out: 0777},
    22  	}
    23  
    24  	for _, tc := range tests {
    25  		tc := tc
    26  		t.Run(tc.name, func(t *testing.T) {
    27  			d := Device(&devices.Device{FileMode: tc.in})
    28  			assert.Equal(t, *d.FileMode, tc.out)
    29  		})
    30  	}
    31  }