diff --git a/integration/exec_test.go b/integration/exec_test.go index 9ec617d1..745da157 100644 --- a/integration/exec_test.go +++ b/integration/exec_test.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "os" "strings" - "syscall" "testing" "github.com/docker/libcontainer" @@ -192,6 +191,20 @@ func newTestRoot() (string, error) { return dir, nil } +func waitProcess(pid int, t *testing.T) { + p, err := os.FindProcess(pid) + if err != nil { + t.Fatal(err) + } + status, err := p.Wait() + if err != nil { + t.Fatal(err) + } + if !status.Success() { + t.Fatal(status) + } +} + func TestEnter(t *testing.T) { if testing.Short() { return @@ -229,12 +242,12 @@ func TestEnter(t *testing.T) { var stdout, stdout2 bytes.Buffer - pconfig := libcontainer.ProcessConfig{ + pconfig := libcontainer.Process{ Args: []string{"sh", "-c", "cat && readlink /proc/self/ns/pid"}, Stdin: stdinR, Stdout: &stdout, } - pid, err := container.StartProcess(&pconfig) + pid, err := container.Start(&pconfig) stdinR.Close() defer stdinW.Close() if err != nil { @@ -250,7 +263,7 @@ func TestEnter(t *testing.T) { pconfig.Stdin = stdinR2 pconfig.Stdout = &stdout2 - pid2, err := container.StartProcess(&pconfig) + pid2, err := container.Start(&pconfig) stdinR2.Close() defer stdinW2.Close() if err != nil { @@ -273,27 +286,11 @@ func TestEnter(t *testing.T) { } // Wait processes - var status syscall.WaitStatus - stdinW2.Close() - exitCode, err := container.WaitProcess(pid2) - if err != nil { - t.Fatal(err) - } - status = syscall.WaitStatus(exitCode) - if status.ExitStatus() != 0 { - t.Fatal(exitCode) - } + waitProcess(pid2, t) stdinW.Close() - exitCode, err = container.WaitProcess(pid) - if err != nil { - t.Fatal(err) - } - status = syscall.WaitStatus(exitCode) - if status.ExitStatus() != 0 { - t.Fatal(exitCode) - } + waitProcess(pid, t) // Check that both processes live in the same pidns pidns := string(stdout.Bytes()) @@ -345,11 +342,11 @@ func TestFreeze(t *testing.T) { t.Fatal(err) } - pconfig := libcontainer.ProcessConfig{ + pconfig := libcontainer.Process{ Args: []string{"cat"}, Stdin: stdinR, } - pid, err := container.StartProcess(&pconfig) + pid, err := container.Start(&pconfig) stdinR.Close() defer stdinW.Close() if err != nil { @@ -364,7 +361,7 @@ func TestFreeze(t *testing.T) { if err := container.Pause(); err != nil { t.Fatal(err) } - state, err := container.RunState() + state, err := container.Status() if err != nil { t.Fatal(err) } diff --git a/integration/init_test.go b/integration/init_test.go index f9c1e3cf..6b4bc32d 100644 --- a/integration/init_test.go +++ b/integration/init_test.go @@ -6,7 +6,7 @@ import ( "runtime" "github.com/docker/libcontainer" - _ "github.com/docker/libcontainer/namespaces/nsenter" + _ "github.com/docker/libcontainer/nsenter" ) // init runs the libcontainer initialization code because of the busybox style needs diff --git a/integration/template_test.go b/integration/template_test.go index 372cc695..a8a40b08 100644 --- a/integration/template_test.go +++ b/integration/template_test.go @@ -3,7 +3,6 @@ package integration import ( "syscall" - "github.com/docker/libcontainer/cgroups" "github.com/docker/libcontainer/configs" "github.com/docker/libcontainer/devices" ) @@ -15,7 +14,6 @@ import ( func newTemplateConfig(rootfs string) *configs.Config { return &configs.Config{ RootFs: rootfs, - Tty: false, Capabilities: []string{ "CHOWN", "DAC_OVERRIDE", @@ -39,17 +37,15 @@ func newTemplateConfig(rootfs string) *configs.Config { {Type: configs.NEWPID}, {Type: configs.NEWNET}, }), - Cgroups: &cgroups.Cgroup{ + Cgroups: &configs.Cgroup{ Name: "test", Parent: "integration", AllowAllDevices: false, AllowedDevices: devices.DefaultAllowedDevices, }, - MountConfig: &configs.MountConfig{ - DeviceNodes: devices.DefaultAutoCreatedDevices, - }, - Hostname: "integration", + DeviceNodes: devices.DefaultAutoCreatedDevices, + Hostname: "integration", Env: []string{ "HOME=/root", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", diff --git a/integration/utils_test.go b/integration/utils_test.go index 93fe3b4b..39c9a126 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -91,9 +91,8 @@ func runContainer(config *configs.Config, console string, args ...string) (buffe buffers = newStdBuffers() - process := &libcontainer.ProcessConfig{ + process := &libcontainer.Process{ Args: args, - Env: make([]string, 0), Stdin: buffers.Stdin, Stdout: buffers.Stdout, Stderr: buffers.Stderr, @@ -110,7 +109,7 @@ func runContainer(config *configs.Config, console string, args ...string) (buffe } defer container.Destroy() - pid, err := container.StartProcess(process) + pid, err := container.Start(process) if err != nil { return nil, -1, err }