|
@@ -3908,3 +3908,113 @@ cc_library {
|
|
|
},
|
|
|
)
|
|
|
}
|
|
|
+
|
|
|
+func TestCcLibraryWithIntegerOverflowProperty(t *testing.T) {
|
|
|
+ runCcLibraryTestCase(t, Bp2buildTestCase{
|
|
|
+ Description: "cc_library has correct features when integer_overflow property is provided",
|
|
|
+ ModuleTypeUnderTest: "cc_library",
|
|
|
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
|
|
+ Blueprint: `
|
|
|
+cc_library {
|
|
|
+ name: "foo",
|
|
|
+ sanitize: {
|
|
|
+ integer_overflow: true,
|
|
|
+ },
|
|
|
+}
|
|
|
+`,
|
|
|
+ ExpectedBazelTargets: []string{
|
|
|
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
|
|
+ "features": `["ubsan_integer_overflow"]`,
|
|
|
+ "local_includes": `["."]`,
|
|
|
+ }),
|
|
|
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
|
|
+ "features": `["ubsan_integer_overflow"]`,
|
|
|
+ "local_includes": `["."]`,
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func TestCcLibraryWithMiscUndefinedProperty(t *testing.T) {
|
|
|
+ runCcLibraryTestCase(t, Bp2buildTestCase{
|
|
|
+ Description: "cc_library has correct features when misc_undefined property is provided",
|
|
|
+ ModuleTypeUnderTest: "cc_library",
|
|
|
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
|
|
+ Blueprint: `
|
|
|
+cc_library {
|
|
|
+ name: "foo",
|
|
|
+ sanitize: {
|
|
|
+ misc_undefined: ["undefined", "nullability"],
|
|
|
+ },
|
|
|
+}
|
|
|
+`,
|
|
|
+ ExpectedBazelTargets: []string{
|
|
|
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
|
|
+ "features": `[
|
|
|
+ "ubsan_undefined",
|
|
|
+ "ubsan_nullability",
|
|
|
+ ]`,
|
|
|
+ "local_includes": `["."]`,
|
|
|
+ }),
|
|
|
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
|
|
+ "features": `[
|
|
|
+ "ubsan_undefined",
|
|
|
+ "ubsan_nullability",
|
|
|
+ ]`,
|
|
|
+ "local_includes": `["."]`,
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func TestCcLibraryWithUBSanPropertiesArchSpecific(t *testing.T) {
|
|
|
+ runCcLibraryTestCase(t, Bp2buildTestCase{
|
|
|
+ Description: "cc_library has correct feature select when UBSan props are specified in arch specific blocks",
|
|
|
+ ModuleTypeUnderTest: "cc_library",
|
|
|
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
|
|
+ Blueprint: `
|
|
|
+cc_library {
|
|
|
+ name: "foo",
|
|
|
+ sanitize: {
|
|
|
+ misc_undefined: ["undefined", "nullability"],
|
|
|
+ },
|
|
|
+ target: {
|
|
|
+ android: {
|
|
|
+ sanitize: {
|
|
|
+ misc_undefined: ["alignment"],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ linux_glibc: {
|
|
|
+ sanitize: {
|
|
|
+ integer_overflow: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+}
|
|
|
+`,
|
|
|
+ ExpectedBazelTargets: []string{
|
|
|
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
|
|
+ "features": `[
|
|
|
+ "ubsan_undefined",
|
|
|
+ "ubsan_nullability",
|
|
|
+ ] + select({
|
|
|
+ "//build/bazel/platforms/os:android": ["ubsan_alignment"],
|
|
|
+ "//build/bazel/platforms/os:linux_glibc": ["ubsan_integer_overflow"],
|
|
|
+ "//conditions:default": [],
|
|
|
+ })`,
|
|
|
+ "local_includes": `["."]`,
|
|
|
+ }),
|
|
|
+ MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
|
|
+ "features": `[
|
|
|
+ "ubsan_undefined",
|
|
|
+ "ubsan_nullability",
|
|
|
+ ] + select({
|
|
|
+ "//build/bazel/platforms/os:android": ["ubsan_alignment"],
|
|
|
+ "//build/bazel/platforms/os:linux_glibc": ["ubsan_integer_overflow"],
|
|
|
+ "//conditions:default": [],
|
|
|
+ })`,
|
|
|
+ "local_includes": `["."]`,
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ })
|
|
|
+}
|