Skip to content

Cannot run tests because of wrong library path #2007

@yunchih

Description

@yunchih

Title: Cannot run tests because of wrong library path

Description
I'm not able to run any test because libgtest.a and libgmock.a cannot be found by bazel. The two static libraries were installed into thirdparty_build/lib64, instead of the thirdparty_build/lib specified in ci/prebuilt/BUILD. This happens on both x86-64 Fedora 26 and ArchLinux. The patch attached solves the issue. If PR welcomed, I'd be happy to give it a try.

Repro steps:

git clone --depth 1 https://github.com/envoyproxy/envoy
bazel fetch //source/...
bazel build //source/exe:envoy-static
bazel test //test/common/http:async_client_impl_test

Logs:

$ bazel test //test/common/http:async_client_impl_test   
DEBUG: /home/yunchih/Downloads/envoy/bazel/repositories.bzl:20:5: Fetching external dependencies...
DEBUG: /home/yunchih/Downloads/envoy/bazel/repositories.bzl:26:5: 
DEBUG: /home/yunchih/Downloads/envoy/bazel/repositories.bzl:27:5: External dependency cache directory /home/yunchih/.cache/bazel/_bazel_yunchih/3e48947f02ad51b3ccfd7439d38c5b2c/external/envoy_deps_cache_71db16db382225e98b90ee84c338724d
make: Entering directory '/home/yunchih/.cache/bazel/_bazel_yunchih/3e48947f02ad51b3ccfd7439d38c5b2c/external/envoy_deps'
....
DEBUG: /home/yunchih/Downloads/envoy/bazel/repositories.bzl:28:5: External dep build exited with return code: 0.
WARNING: /home/yunchih/.cache/bazel/_bazel_yunchih/3e48947f02ad51b3ccfd7439d38c5b2c/external/com_google_protobuf_cc/WORKSPACE:1: Workspace name in /home/yunchih/.cache/bazel/_bazel_yunchih/3e48947f02ad51b3ccfd7439d38c5b2c/external/com_google_protobuf_cc/WORKSPACE (@com_google_protobuf) does not match the name given in the repository's definition (@com_google_protobuf_cc); this will cause a build error in future versions.
INFO: Found 1 test target...
ERROR: missing input file '@envoy_deps//:thirdparty_build/lib/libgtest.a'.
ERROR: Process terminated by signal 15.
ERROR: /home/yunchih/Downloads/envoy/test/common/http/BUILD:12:1: //test/common/http:async_client_impl_test: missing input file '@envoy_deps//:thirdparty_build/lib/libgtest.a'.
Target //test/common/http:async_client_impl_test failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/yunchih/Downloads/envoy/test/common/http/BUILD:12:1 1 input file(s) do not exist.
INFO: Elapsed time: 0.132s, Critical Path: 0.01s

Executed 0 out of 1 test: 1 fails to build.

$ ls ./bazel-envoy/external/envoy_deps/thirdparty_build/lib64
total 24616
-rw-r--r--. 1 yunchih yunchih 6187552 Nov  7 23:43 libgtest.a
-rw-r--r--. 1 yunchih yunchih 9582828 Nov  7 23:43 libgmock_main.a
-rw-r--r--. 1 yunchih yunchih  369998 Nov  7 23:43 libgtest_main.a
-rw-r--r--. 1 yunchih yunchih 9050344 Nov  7 23:43 libgmock.a
drwxrwxr-x. 2 yunchih yunchih    4096 Nov  7 23:43 pkgconfig

Patch:

diff --git a/ci/prebuilt/BUILD b/ci/prebuilt/BUILD
index dc0a46a..934fb8e 100644
--- a/ci/prebuilt/BUILD
+++ b/ci/prebuilt/BUILD
@@ -37,10 +37,10 @@ cc_library(
 
 cc_library(
     name = "googletest",
-    srcs = [
-        "thirdparty_build/lib/libgmock.a",
-        "thirdparty_build/lib/libgtest.a",
-    ],
+    srcs = glob([
+        "thirdparty_build/lib*/libgmock.a",
+        "thirdparty_build/lib*/libgtest.a",
+    ]),

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions