From 615d66111214f5ae9b41fb2a89bb3549c03fc7af Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Thu, 6 Feb 2020 14:01:45 -0800 Subject: runsc/container_test: hide host /etc in test containers The host /etc can contain config files which affect tests. For example, bash reads /etc/passwd and if it is too big a test can fail by timeout. PiperOrigin-RevId: 293670637 --- runsc/testutil/testutil.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'runsc/testutil') diff --git a/runsc/testutil/testutil.go b/runsc/testutil/testutil.go index 80c2c9680..92d677e71 100644 --- a/runsc/testutil/testutil.go +++ b/runsc/testutil/testutil.go @@ -119,6 +119,13 @@ func NewSpecWithArgs(args ...string) *specs.Spec { Capabilities: specutils.AllCapabilities(), }, Mounts: []specs.Mount{ + // Hide the host /etc to avoid any side-effects. + // For example, bash reads /etc/passwd and if it is + // very big, tests can fail by timeout. + { + Type: "tmpfs", + Destination: "/etc", + }, // Root is readonly, but many tests want to write to tmpdir. // This creates a writable mount inside the root. Also, when tmpdir points // to "/tmp", it makes the the actual /tmp to be mounted and not a tmpfs -- cgit v1.2.3