Merge "Add test that shared libs don't propagate ubsan rt" am: 3a69f93987
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2302617 Change-Id: I1570eb535004743a404c235defd2fb41255c4506 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
189faa28f2
1 changed files with 39 additions and 4 deletions
|
@ -572,7 +572,7 @@ func TestUbsan(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_binary {
|
cc_binary {
|
||||||
name: "bin_depends_ubsan",
|
name: "bin_depends_ubsan_static",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libshared",
|
"libshared",
|
||||||
|
@ -584,6 +584,14 @@ func TestUbsan(t *testing.T) {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_binary {
|
||||||
|
name: "bin_depends_ubsan_shared",
|
||||||
|
host_supported: true,
|
||||||
|
shared_libs: [
|
||||||
|
"libsharedubsan",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
cc_binary {
|
cc_binary {
|
||||||
name: "bin_no_ubsan",
|
name: "bin_no_ubsan",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
@ -607,6 +615,14 @@ func TestUbsan(t *testing.T) {
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_library_shared {
|
||||||
|
name: "libsharedubsan",
|
||||||
|
host_supported: true,
|
||||||
|
sanitize: {
|
||||||
|
undefined: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "libubsan",
|
name: "libubsan",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
@ -632,22 +648,33 @@ func TestUbsan(t *testing.T) {
|
||||||
|
|
||||||
check := func(t *testing.T, result *android.TestResult, variant string) {
|
check := func(t *testing.T, result *android.TestResult, variant string) {
|
||||||
staticVariant := variant + "_static"
|
staticVariant := variant + "_static"
|
||||||
|
sharedVariant := variant + "_shared"
|
||||||
|
|
||||||
minimalRuntime := result.ModuleForTests("libclang_rt.ubsan_minimal", staticVariant)
|
minimalRuntime := result.ModuleForTests("libclang_rt.ubsan_minimal", staticVariant)
|
||||||
|
|
||||||
// The binaries, one with ubsan and one without
|
// The binaries, one with ubsan and one without
|
||||||
binWithUbsan := result.ModuleForTests("bin_with_ubsan", variant)
|
binWithUbsan := result.ModuleForTests("bin_with_ubsan", variant)
|
||||||
binDependsUbsan := result.ModuleForTests("bin_depends_ubsan", variant)
|
binDependsUbsan := result.ModuleForTests("bin_depends_ubsan_static", variant)
|
||||||
|
libSharedUbsan := result.ModuleForTests("libsharedubsan", sharedVariant)
|
||||||
|
binDependsUbsanShared := result.ModuleForTests("bin_depends_ubsan_shared", variant)
|
||||||
binNoUbsan := result.ModuleForTests("bin_no_ubsan", variant)
|
binNoUbsan := result.ModuleForTests("bin_no_ubsan", variant)
|
||||||
|
|
||||||
android.AssertStringListContains(t, "missing libclang_rt.ubsan_minimal in bin_with_ubsan static libs",
|
android.AssertStringListContains(t, "missing libclang_rt.ubsan_minimal in bin_with_ubsan static libs",
|
||||||
strings.Split(binWithUbsan.Rule("ld").Args["libFlags"], " "),
|
strings.Split(binWithUbsan.Rule("ld").Args["libFlags"], " "),
|
||||||
minimalRuntime.OutputFiles(t, "")[0].String())
|
minimalRuntime.OutputFiles(t, "")[0].String())
|
||||||
|
|
||||||
android.AssertStringListContains(t, "missing libclang_rt.ubsan_minimal in bin_depends_ubsan static libs",
|
android.AssertStringListContains(t, "missing libclang_rt.ubsan_minimal in bin_depends_ubsan_static static libs",
|
||||||
strings.Split(binDependsUbsan.Rule("ld").Args["libFlags"], " "),
|
strings.Split(binDependsUbsan.Rule("ld").Args["libFlags"], " "),
|
||||||
minimalRuntime.OutputFiles(t, "")[0].String())
|
minimalRuntime.OutputFiles(t, "")[0].String())
|
||||||
|
|
||||||
|
android.AssertStringListContains(t, "missing libclang_rt.ubsan_minimal in libsharedubsan static libs",
|
||||||
|
strings.Split(libSharedUbsan.Rule("ld").Args["libFlags"], " "),
|
||||||
|
minimalRuntime.OutputFiles(t, "")[0].String())
|
||||||
|
|
||||||
|
android.AssertStringListDoesNotContain(t, "unexpected libclang_rt.ubsan_minimal in bin_depends_ubsan_shared static libs",
|
||||||
|
strings.Split(binDependsUbsanShared.Rule("ld").Args["libFlags"], " "),
|
||||||
|
minimalRuntime.OutputFiles(t, "")[0].String())
|
||||||
|
|
||||||
android.AssertStringListDoesNotContain(t, "unexpected libclang_rt.ubsan_minimal in bin_no_ubsan static libs",
|
android.AssertStringListDoesNotContain(t, "unexpected libclang_rt.ubsan_minimal in bin_no_ubsan static libs",
|
||||||
strings.Split(binNoUbsan.Rule("ld").Args["libFlags"], " "),
|
strings.Split(binNoUbsan.Rule("ld").Args["libFlags"], " "),
|
||||||
minimalRuntime.OutputFiles(t, "")[0].String())
|
minimalRuntime.OutputFiles(t, "")[0].String())
|
||||||
|
@ -656,10 +683,18 @@ func TestUbsan(t *testing.T) {
|
||||||
strings.Split(binWithUbsan.Rule("ld").Args["ldFlags"], " "),
|
strings.Split(binWithUbsan.Rule("ld").Args["ldFlags"], " "),
|
||||||
"-Wl,--exclude-libs="+minimalRuntime.OutputFiles(t, "")[0].Base())
|
"-Wl,--exclude-libs="+minimalRuntime.OutputFiles(t, "")[0].Base())
|
||||||
|
|
||||||
android.AssertStringListContains(t, "missing -Wl,--exclude-libs for minimal runtime in bin_depends_ubsan static libs",
|
android.AssertStringListContains(t, "missing -Wl,--exclude-libs for minimal runtime in bin_depends_ubsan_static static libs",
|
||||||
strings.Split(binDependsUbsan.Rule("ld").Args["ldFlags"], " "),
|
strings.Split(binDependsUbsan.Rule("ld").Args["ldFlags"], " "),
|
||||||
"-Wl,--exclude-libs="+minimalRuntime.OutputFiles(t, "")[0].Base())
|
"-Wl,--exclude-libs="+minimalRuntime.OutputFiles(t, "")[0].Base())
|
||||||
|
|
||||||
|
android.AssertStringListContains(t, "missing -Wl,--exclude-libs for minimal runtime in libsharedubsan static libs",
|
||||||
|
strings.Split(libSharedUbsan.Rule("ld").Args["ldFlags"], " "),
|
||||||
|
"-Wl,--exclude-libs="+minimalRuntime.OutputFiles(t, "")[0].Base())
|
||||||
|
|
||||||
|
android.AssertStringListDoesNotContain(t, "unexpected -Wl,--exclude-libs for minimal runtime in bin_depends_ubsan_shared static libs",
|
||||||
|
strings.Split(binDependsUbsanShared.Rule("ld").Args["ldFlags"], " "),
|
||||||
|
"-Wl,--exclude-libs="+minimalRuntime.OutputFiles(t, "")[0].Base())
|
||||||
|
|
||||||
android.AssertStringListDoesNotContain(t, "unexpected -Wl,--exclude-libs for minimal runtime in bin_no_ubsan static libs",
|
android.AssertStringListDoesNotContain(t, "unexpected -Wl,--exclude-libs for minimal runtime in bin_no_ubsan static libs",
|
||||||
strings.Split(binNoUbsan.Rule("ld").Args["ldFlags"], " "),
|
strings.Split(binNoUbsan.Rule("ld").Args["ldFlags"], " "),
|
||||||
"-Wl,--exclude-libs="+minimalRuntime.OutputFiles(t, "")[0].Base())
|
"-Wl,--exclude-libs="+minimalRuntime.OutputFiles(t, "")[0].Base())
|
||||||
|
|
Loading…
Reference in a new issue