C++: cc_shared_library tests for attribute added in unknown commit
RELNOTES:none
PiperOrigin-RevId: 291150536
Change-Id: Ic11732ffb76cc2e2c775f5952d0f9aeb5324ae36
diff --git a/examples/test_cc_shared_library/BUILD b/examples/test_cc_shared_library/BUILD
index 8d9b06f..b45ca15 100644
--- a/examples/test_cc_shared_library/BUILD
+++ b/examples/test_cc_shared_library/BUILD
@@ -1,6 +1,13 @@
-load("//cc:defs.bzl", "cc_binary", "cc_library")
+load("//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("//examples:experimental_cc_shared_library.bzl", "cc_shared_library")
+cc_test(
+ name = "cc_test",
+ srcs = ["main.cc"],
+ dynamic_deps = ["foo_so"],
+ deps = ["foo"],
+)
+
cc_binary(
name = "binary",
srcs = ["main.cc"],
@@ -12,6 +19,7 @@
name = "foo_so",
dynamic_deps = ["bar_so"],
preloaded_deps = ["preloaded_dep"],
+ user_link_flags = ["-Wl,-rpath,kittens"],
visibility_file = "foo.lds",
exports = [
"foo",
@@ -31,7 +39,6 @@
# changed, the symbols from bar4 won't be exported.
"bar4",
],
- user_link_flags = ["-Wl,-rpath,kittens"],
)
cc_library(
@@ -122,6 +129,7 @@
data = [
":bar_so",
":binary",
+ ":cc_test",
":foo_so",
],
)
diff --git a/examples/test_cc_shared_library/cc_shared_library_integration_test.sh b/examples/test_cc_shared_library/cc_shared_library_integration_test.sh
index 9930ffc..7e9b947 100755
--- a/examples/test_cc_shared_library/cc_shared_library_integration_test.sh
+++ b/examples/test_cc_shared_library/cc_shared_library_integration_test.sh
@@ -50,14 +50,26 @@
&& exit 1)
}
+function do_test_binary() {
+ symbols=$(nm -D $1)
+ check_symbol_present "$symbols" "U _Z3foov"
+ $1 | (grep -q "hello 42" || (echo "Expected 'hello 42'" && exit 1))
+}
+
function test_binary() {
binary=$(find . -name binary)
- symbols=$(nm -D $binary)
+ do_test_binary $binary
check_symbol_present "$symbols" "T _Z13preloaded_depv"
- check_symbol_present "$symbols" "U _Z3foov"
- $binary | (grep -q "hello 42" || (echo "Expected 'hello 42'" && exit 1))
+}
+
+function test_cc_test() {
+ cc_test=$(find . -name cc_test)
+ do_test_binary $cc_test
+ check_symbol_absent "$symbols" "_Z13preloaded_depv"
+ ldd $cc_test | (grep -q "preloaded_Udep.so" || (echo "Expected '"preloaded_Udep.so"'" && exit 1))
}
test_shared_library_user_link_flags
test_shared_library_symbols
test_binary
+test_cc_test