Merge pull request #599 from avagin/test
integration: don't ignore exit codes of test processes
This commit is contained in:
commit
8c6ed5ebe0
|
@ -182,14 +182,6 @@ func newTestRoot() (string, error) {
|
||||||
return dir, nil
|
return dir, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitProcess(p *libcontainer.Process, t *testing.T) {
|
|
||||||
status, err := p.Wait()
|
|
||||||
ok(t, err)
|
|
||||||
if !status.Success() {
|
|
||||||
t.Fatal(status)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEnter(t *testing.T) {
|
func TestEnter(t *testing.T) {
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
return
|
return
|
||||||
|
@ -430,22 +422,16 @@ func testFreeze(t *testing.T, systemd bool) {
|
||||||
stdinR, stdinW, err := os.Pipe()
|
stdinR, stdinW, err := os.Pipe()
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
|
|
||||||
pconfig := libcontainer.Process{
|
pconfig := &libcontainer.Process{
|
||||||
Args: []string{"cat"},
|
Args: []string{"cat"},
|
||||||
Env: standardEnvironment,
|
Env: standardEnvironment,
|
||||||
Stdin: stdinR,
|
Stdin: stdinR,
|
||||||
}
|
}
|
||||||
err = container.Start(&pconfig)
|
err = container.Start(pconfig)
|
||||||
stdinR.Close()
|
stdinR.Close()
|
||||||
defer stdinW.Close()
|
defer stdinW.Close()
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
|
|
||||||
pid, err := pconfig.Pid()
|
|
||||||
ok(t, err)
|
|
||||||
|
|
||||||
process, err := os.FindProcess(pid)
|
|
||||||
ok(t, err)
|
|
||||||
|
|
||||||
err = container.Pause()
|
err = container.Pause()
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
state, err := container.Status()
|
state, err := container.Status()
|
||||||
|
@ -457,12 +443,7 @@ func testFreeze(t *testing.T, systemd bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
stdinW.Close()
|
stdinW.Close()
|
||||||
s, err := process.Wait()
|
waitProcess(pconfig, t)
|
||||||
ok(t, err)
|
|
||||||
|
|
||||||
if !s.Success() {
|
|
||||||
t.Fatal(s.String())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCpuShares(t *testing.T) {
|
func TestCpuShares(t *testing.T) {
|
||||||
|
@ -547,7 +528,7 @@ func TestContainerState(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
stdinR.Close()
|
stdinR.Close()
|
||||||
defer p.Signal(os.Kill)
|
defer stdinW.Close()
|
||||||
|
|
||||||
st, err := container.State()
|
st, err := container.State()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -562,7 +543,7 @@ func TestContainerState(t *testing.T) {
|
||||||
t.Fatal("Container using non-host ipc namespace")
|
t.Fatal("Container using non-host ipc namespace")
|
||||||
}
|
}
|
||||||
stdinW.Close()
|
stdinW.Close()
|
||||||
p.Wait()
|
waitProcess(p, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPassExtraFiles(t *testing.T) {
|
func TestPassExtraFiles(t *testing.T) {
|
||||||
|
|
|
@ -44,14 +44,13 @@ func TestExecIn(t *testing.T) {
|
||||||
Stdout: buffers.Stdout,
|
Stdout: buffers.Stdout,
|
||||||
Stderr: buffers.Stderr,
|
Stderr: buffers.Stderr,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = container.Start(ps)
|
err = container.Start(ps)
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
_, err = ps.Wait()
|
waitProcess(ps, t)
|
||||||
ok(t, err)
|
|
||||||
stdinW.Close()
|
stdinW.Close()
|
||||||
if _, err := process.Wait(); err != nil {
|
waitProcess(process, t)
|
||||||
t.Log(err)
|
|
||||||
}
|
|
||||||
out := buffers.Stdout.String()
|
out := buffers.Stdout.String()
|
||||||
if !strings.Contains(out, "cat") || !strings.Contains(out, "ps") {
|
if !strings.Contains(out, "cat") || !strings.Contains(out, "ps") {
|
||||||
t.Fatalf("unexpected running process, output %q", out)
|
t.Fatalf("unexpected running process, output %q", out)
|
||||||
|
@ -92,12 +91,11 @@ func TestExecInRlimit(t *testing.T) {
|
||||||
}
|
}
|
||||||
err = container.Start(ps)
|
err = container.Start(ps)
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
_, err = ps.Wait()
|
waitProcess(ps, t)
|
||||||
ok(t, err)
|
|
||||||
stdinW.Close()
|
stdinW.Close()
|
||||||
if _, err := process.Wait(); err != nil {
|
waitProcess(process, t)
|
||||||
t.Log(err)
|
|
||||||
}
|
|
||||||
out := buffers.Stdout.String()
|
out := buffers.Stdout.String()
|
||||||
if limit := strings.TrimSpace(out); limit != "1025" {
|
if limit := strings.TrimSpace(out); limit != "1025" {
|
||||||
t.Fatalf("expected rlimit to be 1025, got %s", limit)
|
t.Fatalf("expected rlimit to be 1025, got %s", limit)
|
||||||
|
@ -191,12 +189,11 @@ func TestExecInTTY(t *testing.T) {
|
||||||
t.Fatal("Waiting for copy timed out")
|
t.Fatal("Waiting for copy timed out")
|
||||||
case <-copy:
|
case <-copy:
|
||||||
}
|
}
|
||||||
_, err = ps.Wait()
|
waitProcess(ps, t)
|
||||||
ok(t, err)
|
|
||||||
stdinW.Close()
|
stdinW.Close()
|
||||||
if _, err := process.Wait(); err != nil {
|
waitProcess(process, t)
|
||||||
t.Log(err)
|
|
||||||
}
|
|
||||||
out := stdout.String()
|
out := stdout.String()
|
||||||
if !strings.Contains(out, "cat") || !strings.Contains(string(out), "ps") {
|
if !strings.Contains(out, "cat") || !strings.Contains(string(out), "ps") {
|
||||||
t.Fatalf("unexpected running process, output %q", out)
|
t.Fatalf("unexpected running process, output %q", out)
|
||||||
|
@ -243,14 +240,11 @@ func TestExecInEnvironment(t *testing.T) {
|
||||||
}
|
}
|
||||||
err = container.Start(process2)
|
err = container.Start(process2)
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
if _, err := process2.Wait(); err != nil {
|
waitProcess(process2, t)
|
||||||
out := buffers.Stdout.String()
|
|
||||||
t.Fatal(err, out)
|
|
||||||
}
|
|
||||||
stdinW.Close()
|
stdinW.Close()
|
||||||
if _, err := process.Wait(); err != nil {
|
waitProcess(process, t)
|
||||||
t.Log(err)
|
|
||||||
}
|
|
||||||
out := buffers.Stdout.String()
|
out := buffers.Stdout.String()
|
||||||
// check execin's process environment
|
// check execin's process environment
|
||||||
if !strings.Contains(out, "DEBUG=false") ||
|
if !strings.Contains(out, "DEBUG=false") ||
|
||||||
|
|
|
@ -49,6 +49,19 @@ func ok(t testing.TB, err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func waitProcess(p *libcontainer.Process, t *testing.T) {
|
||||||
|
_, file, line, _ := runtime.Caller(1)
|
||||||
|
status, err := p.Wait()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("%s:%d: unexpected error: %s\n\n", filepath.Base(file), line, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if !status.Success() {
|
||||||
|
t.Fatalf("%s:%d: unexpected status: %s\n\n", filepath.Base(file), line, status.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// newRootfs creates a new tmp directory and copies the busybox root filesystem
|
// newRootfs creates a new tmp directory and copies the busybox root filesystem
|
||||||
func newRootfs() (string, error) {
|
func newRootfs() (string, error) {
|
||||||
dir, err := ioutil.TempDir("", "")
|
dir, err := ioutil.TempDir("", "")
|
||||||
|
|
Loading…
Reference in New Issue