Add test for --pid=host
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
23feaaa240
commit
15e8f3fdd3
1 changed files with 32 additions and 0 deletions
|
@ -2750,6 +2750,38 @@ func TestContainerNetworkMode(t *testing.T) {
|
|||
logDone("run - container shared network namespace")
|
||||
}
|
||||
|
||||
func TestRunModePidHost(t *testing.T) {
|
||||
hostPid, err := os.Readlink("/proc/1/ns/pid")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cmd := exec.Command(dockerBinary, "run", "--pid=host", "busybox", "readlink", "/proc/self/ns/pid")
|
||||
out2, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatal(err, out2)
|
||||
}
|
||||
|
||||
out2 = strings.Trim(out2, "\n")
|
||||
if hostPid != out2 {
|
||||
t.Fatalf("PID different with --pid=host %s != %s\n", hostPid, out2)
|
||||
}
|
||||
|
||||
cmd = exec.Command(dockerBinary, "run", "busybox", "readlink", "/proc/self/ns/pid")
|
||||
out2, _, err = runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatal(err, out2)
|
||||
}
|
||||
|
||||
out2 = strings.Trim(out2, "\n")
|
||||
if hostPid == out2 {
|
||||
t.Fatalf("PID should be different without --pid=host %s == %s\n", hostPid, out2)
|
||||
}
|
||||
deleteAllContainers()
|
||||
|
||||
logDone("run - pid host mode")
|
||||
}
|
||||
|
||||
func TestRunTLSverify(t *testing.T) {
|
||||
cmd := exec.Command(dockerBinary, "ps")
|
||||
out, ec, err := runCommandWithOutput(cmd)
|
||||
|
|
Loading…
Add table
Reference in a new issue