Merge pull request #10013 from icecrime/9979_oom_exit_code
Fix error code when exiting on OOM
This commit is contained in:
commit
9621e59909
1 changed files with 23 additions and 0 deletions
|
@ -2912,3 +2912,26 @@ func TestRunAllowPortRangeThroughPublish(t *testing.T) {
|
|||
}
|
||||
logDone("run - allow port range through --expose flag")
|
||||
}
|
||||
|
||||
func TestRunOOMExitCode(t *testing.T) {
|
||||
defer deleteAllContainers()
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
|
||||
runCmd := exec.Command(dockerBinary, "run", "-m", "4MB", "busybox", "sh", "-c", "x=a; while true; do x=$x$x; done")
|
||||
out, exitCode, _ := runCommandWithOutput(runCmd)
|
||||
if expected := 137; exitCode != expected {
|
||||
t.Fatalf("wrong exit code for OOM container: expected %d, got %d (output: %q)", expected, exitCode, out)
|
||||
}
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Fatal("Timeout waiting for container to die on OOM")
|
||||
}
|
||||
|
||||
logDone("run - exit code on oom")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue