diff options
author | Fabricio Voznika <fvoznika@google.com> | 2019-01-25 14:38:10 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-01-25 14:39:20 -0800 |
commit | c28f886c0bb0ff996e07fc133e0ebe1d842b496a (patch) | |
tree | f37a116ab8552fac479d8184b0272fa01ff0161b | |
parent | 876b241fac98e1e23f25ea4ccdca7768e0a7877f (diff) |
Execute statically linked binary
Mounting lib and lib64 are not necessary anymore and simplifies the test.
PiperOrigin-RevId: 230971195
Change-Id: Ib91a3ffcec4b322cd3687c337eedbde9641685ed
-rw-r--r-- | runsc/container/BUILD | 2 | ||||
-rw-r--r-- | runsc/container/container_test.go | 27 |
2 files changed, 21 insertions, 8 deletions
diff --git a/runsc/container/BUILD b/runsc/container/BUILD index d9534cbcc..5dfff5c5e 100644 --- a/runsc/container/BUILD +++ b/runsc/container/BUILD @@ -65,7 +65,9 @@ go_test( go_binary( name = "test_app", + testonly = 1, srcs = ["test_app.go"], + pure = "on", deps = [ "//runsc/test/testutil", "@com_github_google_subcommands//:go_default_library", diff --git a/runsc/container/container_test.go b/runsc/container/container_test.go index bd8655f3e..9f3d6b454 100644 --- a/runsc/container/container_test.go +++ b/runsc/container/container_test.go @@ -1526,19 +1526,30 @@ func TestGoferExits(t *testing.T) { } func TestRootNotMount(t *testing.T) { - spec := testutil.NewSpecWithArgs("/bin/true") + if testutil.RaceEnabled { + // Requires statically linked binary, since it's mapping the root to a + // random dir, libs cannot be located. + t.Skip("race makes test_app not statically linked") + } - root, err := ioutil.TempDir(testutil.TmpDir(), "root") + appSym, err := testutil.FindFile("runsc/container/test_app") + if err != nil { + t.Fatal("error finding test_app:", err) + } + app, err := filepath.EvalSymlinks(appSym) if err != nil { - t.Fatalf("failure to create tmp dir: %v", err) + t.Fatalf("error resolving %q symlink: %v", appSym, err) } + log.Infof("App path %q is a symlink to %q", appSym, app) + + root := filepath.Dir(app) + exe := "/" + filepath.Base(app) + log.Infof("Executing %q in %q", exe, root) + + spec := testutil.NewSpecWithArgs(exe, "help") spec.Root.Path = root spec.Root.Readonly = true - spec.Mounts = []specs.Mount{ - {Destination: "/bin", Source: "/bin", Type: "bind", Options: []string{"ro"}}, - {Destination: "/lib", Source: "/lib", Type: "bind", Options: []string{"ro"}}, - {Destination: "/lib64", Source: "/lib64", Type: "bind", Options: []string{"ro"}}, - } + spec.Mounts = nil conf := testutil.TestConfig() if err := run(spec, conf); err != nil { |