integration: check container.Processes()

Signed-off-by: Andrey Vagin <avagin@openvz.org>
This commit is contained in:
Andrey Vagin 2015-01-21 12:29:53 +03:00 committed by Andrew Vagin
parent 10f0ac2921
commit 5162e5a81c
1 changed files with 25 additions and 2 deletions

View File

@ -257,11 +257,18 @@ func TestEnter(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
pconfig.Args = []string{"readlink", "/proc/self/ns/pid"} // Execute a first process in the container
pconfig.Stdin = nil stdinR2, stdinW2, err := os.Pipe()
if err != nil {
t.Fatal(err)
}
pconfig.Args = []string{"sh", "-c", "cat && readlink /proc/self/ns/pid"}
pconfig.Stdin = stdinR2
pconfig.Stdout = &stdout2 pconfig.Stdout = &stdout2
pid2, err := container.StartProcess(&pconfig) pid2, err := container.StartProcess(&pconfig)
stdinR2.Close()
defer stdinW2.Close()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -271,6 +278,22 @@ func TestEnter(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
processes, err := container.Processes()
if err != nil {
t.Fatal(err)
}
n := 0
for i := range processes {
if processes[i] == pid || processes[i] == pid2 {
n++
}
}
if n != 2 {
t.Fatal("unexpected number of processes", processes, pid, pid2)
}
stdinW2.Close()
s, err := process2.Wait() s, err := process2.Wait()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)