diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-08-16 10:54:21 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-16 10:55:45 -0700 |
commit | da087e66cc0eb1616437e5b729576801671d3696 (patch) | |
tree | c4075198b446502abd4f81c7c1f3b7a0b3677bdf /runsc/container/container_test.go | |
parent | eacbe6a678ec08751543868ef19f9197c167fe60 (diff) |
Combine functions to search for file under one common function
Bazel adds the build type in front of directories making it hard to
refer to binaries in code.
PiperOrigin-RevId: 209010854
Change-Id: I6c9da1ac3bbe79766868a3b14222dd42d03b4ec5
Diffstat (limited to 'runsc/container/container_test.go')
-rw-r--r-- | runsc/container/container_test.go | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/runsc/container/container_test.go b/runsc/container/container_test.go index 33c53e189..10b10d100 100644 --- a/runsc/container/container_test.go +++ b/runsc/container/container_test.go @@ -206,27 +206,6 @@ func run(spec *specs.Spec, conf *boot.Config) error { return nil } -// findUDSApp finds the uds_test_app binary to be used in the UnixDomainSocket test. -func findUDSApp() (string, error) { - // TODO: Use bazel FindBinary function. - - // uds_test_app is in a directory like: - // './linux_amd64_pure_stripped/uds_test_app.go'. - // - // Since I don't want to construct 'linux_amd64_pure_stripped' based on the - // build type, do a quick search for: './*/uds_test_app' - // Note: This glob will only succeed when file is one directory deep. - matches, err := filepath.Glob("./*/uds_test_app") - if err != nil { - return "", fmt.Errorf("error globbing: %v", err) - } - if i := len(matches); i != 1 { - return "", fmt.Errorf("error identifying uds_test_app from matches: got %d matches", i) - } - - return matches[0], nil -} - type configOption int const ( @@ -760,16 +739,9 @@ func TestUnixDomainSockets(t *testing.T) { // Get file path for corresponding output file in sandbox. outputFileSandbox := filepath.Join(goferRoot, output) - // Need to get working directory, even though not intuitive. - wd, _ := os.Getwd() - localPath, err := findUDSApp() + app, err := testutil.FindFile("runsc/container/uds_test_app") if err != nil { - t.Fatalf("error finding localPath: %v", err) - } - app := filepath.Join(wd, localPath) - - if _, err = os.Stat(app); err != nil { - t.Fatalf("error finding the uds_test_app: %v", err) + t.Fatal("error finding uds_test_app:", err) } socketPath := filepath.Join(dir, socket) |