mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-28 10:01:28 +08:00
new-api: implement Wait, WaitProcess
Signed-off-by: Andrew Vagin <avagin@openvz.org>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/libcontainer"
|
||||
@@ -252,11 +253,6 @@ func TestEnter(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
process, err := os.FindProcess(pid)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Execute a first process in the container
|
||||
stdinR2, stdinW2, err := os.Pipe()
|
||||
if err != nil {
|
||||
@@ -273,11 +269,6 @@ func TestEnter(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
process2, err := os.FindProcess(pid2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
processes, err := container.Processes()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -293,22 +284,27 @@ func TestEnter(t *testing.T) {
|
||||
t.Fatal("unexpected number of processes", processes, pid, pid2)
|
||||
}
|
||||
|
||||
// Wait processes
|
||||
var status syscall.WaitStatus
|
||||
|
||||
stdinW2.Close()
|
||||
s, err := process2.Wait()
|
||||
exitCode, err := container.WaitProcess(pid2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !s.Success() {
|
||||
t.Fatal(s.String())
|
||||
status = syscall.WaitStatus(exitCode)
|
||||
if status.ExitStatus() != 0 {
|
||||
t.Fatal(exitCode)
|
||||
}
|
||||
|
||||
stdinW.Close()
|
||||
s, err = process.Wait()
|
||||
exitCode, err = container.WaitProcess(pid)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !s.Success() {
|
||||
t.Fatal(s.String())
|
||||
status = syscall.WaitStatus(exitCode)
|
||||
if status.ExitStatus() != 0 {
|
||||
t.Fatal(exitCode)
|
||||
}
|
||||
|
||||
// Check that both processes live in the same pidns
|
||||
|
||||
Reference in New Issue
Block a user