github.com/rumpl/bof@v23.0.0-rc.2+incompatible/integration/container/pidmode_linux_test.go (about) 1 package container // import "github.com/docker/docker/integration/container" 2 3 import ( 4 "context" 5 "os" 6 "testing" 7 "time" 8 9 "github.com/docker/docker/integration/internal/container" 10 "gotest.tools/v3/assert" 11 "gotest.tools/v3/poll" 12 "gotest.tools/v3/skip" 13 ) 14 15 func TestPidHost(t *testing.T) { 16 skip.If(t, testEnv.DaemonInfo.OSType != "linux") 17 skip.If(t, testEnv.IsRemoteDaemon()) 18 19 hostPid, err := os.Readlink("/proc/1/ns/pid") 20 assert.NilError(t, err) 21 22 defer setupTest(t)() 23 client := testEnv.APIClient() 24 ctx := context.Background() 25 26 cID := container.Run(ctx, t, client, func(c *container.TestContainerConfig) { 27 c.HostConfig.PidMode = "host" 28 }) 29 poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond)) 30 cPid := container.GetContainerNS(ctx, t, client, cID, "pid") 31 assert.Assert(t, hostPid == cPid) 32 33 cID = container.Run(ctx, t, client) 34 poll.WaitOn(t, container.IsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond)) 35 cPid = container.GetContainerNS(ctx, t, client, cID, "pid") 36 assert.Assert(t, hostPid != cPid) 37 }