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
This commit is contained in:
Andrei Vagin 2020-02-06 14:01:45 -08:00 committed by gVisor bot
parent 6bd59b4e08
commit 615d661112
1 changed files with 7 additions and 0 deletions

View File

@ -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