C++: cc_shared_library tests for attribute added in unknown commit

RELNOTES:none
PiperOrigin-RevId: 291150536
Change-Id: Ic11732ffb76cc2e2c775f5952d0f9aeb5324ae36
This commit is contained in:
Googler 2020-01-23 05:49:55 -08:00 committed by Copybara-Service
parent 0489ba308b
commit 8774a4decd
2 changed files with 25 additions and 5 deletions

View File

@ -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 @@ cc_shared_library(
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 @@ cc_shared_library(
# changed, the symbols from bar4 won't be exported.
"bar4",
],
user_link_flags = ["-Wl,-rpath,kittens"],
)
cc_library(
@ -122,6 +129,7 @@ sh_test(
data = [
":bar_so",
":binary",
":cc_test",
":foo_so",
],
)

View File

@ -50,14 +50,26 @@ function test_shared_library_user_link_flags() {
&& 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