add a test for ensuring the behavior of read-only /dev/shm

The test ensures that `docker run --read-only -v /var/empty:/dev/shm:ro`
makes /dev/shm read-only

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Upstream-commit: 46ade6acb5b6cdb80287a83afd16c20c6a8b4dff
Component: engine
This commit is contained in:
Akihiro Suda
2016-12-06 03:44:02 +00:00
parent de8cf74e0d
commit cecb5272ed
@@ -4879,3 +4879,16 @@ func (s *delayedReader) Read([]byte) (int, error) {
time.Sleep(500 * time.Millisecond)
return 0, io.EOF
}
// #28823 (originally #28639)
func (s *DockerSuite) TestRunMountReadOnlyDevShm(c *check.C) {
testRequires(c, SameHostDaemon, DaemonIsLinux)
emptyDir, err := ioutil.TempDir("", "test-read-only-dev-shm")
c.Assert(err, check.IsNil)
defer os.RemoveAll(emptyDir)
out, _, err := dockerCmdWithError("run", "--rm", "--read-only",
"-v", fmt.Sprintf("%s:/dev/shm:ro", emptyDir),
"busybox", "touch", "/dev/shm/foo")
c.Assert(err, checker.NotNil, check.Commentf(out))
c.Assert(out, checker.Contains, "Read-only file system")
}