github.com/noxiouz/docker@v0.7.3-0.20160629055221-3d231c78e8c5/integration-cli/docker_cli_oom_killed_test.go (about)

     1  // +build !windows
     2  
     3  package main
     4  
     5  import (
     6  	"github.com/docker/docker/pkg/integration/checker"
     7  	"github.com/go-check/check"
     8  )
     9  
    10  func (s *DockerSuite) TestInspectOomKilledTrue(c *check.C) {
    11  	testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
    12  
    13  	name := "testoomkilled"
    14  	_, exitCode, _ := dockerCmdWithError("run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "x=a; while true; do x=$x$x$x$x; done")
    15  
    16  	c.Assert(exitCode, checker.Equals, 137, check.Commentf("OOM exit should be 137"))
    17  
    18  	oomKilled := inspectField(c, name, "State.OOMKilled")
    19  	c.Assert(oomKilled, checker.Equals, "true")
    20  }
    21  
    22  func (s *DockerSuite) TestInspectOomKilledFalse(c *check.C) {
    23  	testRequires(c, DaemonIsLinux, memoryLimitSupport, swapMemorySupport)
    24  
    25  	name := "testoomkilled"
    26  	dockerCmd(c, "run", "--name", name, "--memory", "32MB", "busybox", "sh", "-c", "echo hello world")
    27  
    28  	oomKilled := inspectField(c, name, "State.OOMKilled")
    29  	c.Assert(oomKilled, checker.Equals, "false")
    30  }