| ... | ... |
@@ -2883,6 +2883,7 @@ func (s *DockerSuite) TestRunAllowPortRangeThroughPublish(c *check.C) {
|
| 2883 | 2883 |
} |
| 2884 | 2884 |
|
| 2885 | 2885 |
func (s *DockerSuite) TestRunOOMExitCode(c *check.C) {
|
| 2886 |
+ testRequires(c, OomControl) |
|
| 2886 | 2887 |
errChan := make(chan error) |
| 2887 | 2888 |
go func() {
|
| 2888 | 2889 |
defer close(errChan) |
| ... | ... |
@@ -7,8 +7,10 @@ import ( |
| 7 | 7 |
"log" |
| 8 | 8 |
"net/http" |
| 9 | 9 |
"os/exec" |
| 10 |
+ "path" |
|
| 10 | 11 |
"strings" |
| 11 | 12 |
|
| 13 |
+ "github.com/docker/libcontainer/cgroups" |
|
| 12 | 14 |
"github.com/go-check/check" |
| 13 | 15 |
) |
| 14 | 16 |
|
| ... | ... |
@@ -107,6 +109,24 @@ var ( |
| 107 | 107 |
}, |
| 108 | 108 |
"Test requires support for IPv6", |
| 109 | 109 |
} |
| 110 |
+ OomControl = TestRequirement{
|
|
| 111 |
+ func() bool {
|
|
| 112 |
+ cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory")
|
|
| 113 |
+ if err != nil {
|
|
| 114 |
+ return false |
|
| 115 |
+ } |
|
| 116 |
+ if _, err := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")); err != nil {
|
|
| 117 |
+ return false |
|
| 118 |
+ } |
|
| 119 |
+ |
|
| 120 |
+ if _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.oom_control")); err != nil {
|
|
| 121 |
+ return false |
|
| 122 |
+ } |
|
| 123 |
+ return true |
|
| 124 |
+ |
|
| 125 |
+ }, |
|
| 126 |
+ "Test requires Oom control enabled.", |
|
| 127 |
+ } |
|
| 110 | 128 |
) |
| 111 | 129 |
|
| 112 | 130 |
// testRequires checks if the environment satisfies the requirements |