diff options
author | Andrei Vagin <avagin@google.com> | 2020-02-06 14:01:45 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-02-06 14:02:52 -0800 |
commit | 615d66111214f5ae9b41fb2a89bb3549c03fc7af (patch) | |
tree | f1b578cfe9510b18985f65fd340537a3b46a8770 | |
parent | 6bd59b4e08893281468e8af5aebb5fab0f7a8c0d (diff) |
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
-rw-r--r-- | runsc/testutil/testutil.go | 7 |
1 files changed, 7 insertions, 0 deletions
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 |