Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 067b8897 authored by Liz Kammer's avatar Liz Kammer Committed by Chris Wailes
Browse files

Correct isThirdParty check

Previously, isThirdParty check was over-selecting for third-party-ness,
the only non-third-party paths were those explicitly excluded from
typically third party directories, results in ~all code being considered
third party.

Updated test to ensure bionic is not considered third party, which fails
without this change.

Test: go soong tests
Change-Id: Id371aaad2ceef2b3163384fa84712397877cbe90
parent 93f51a3c
Loading
Loading
Loading
Loading
+31 −28
Original line number Diff line number Diff line
@@ -3955,10 +3955,13 @@ func TestIncludeDirectoryOrdering(t *testing.T) {
		`, lib, lib)
	}

	ctx := PrepareForIntegrationTestWithCc.RunTestWithBp(t, bp)
	ctx := android.GroupFixturePreparers(
		PrepareForIntegrationTestWithCc,
		android.FixtureAddTextFile("external/foo/Android.bp", bp),
	).RunTest(t)
	// Use the arm variant instead of the arm64 variant so that it gets headers from
	// ndk_libandroid_support to test LateStaticLibs.
	cflags := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_sdk_static").Output("obj/foo.o").Args["cFlags"]
	cflags := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_sdk_static").Output("obj/external/foo/foo.o").Args["cFlags"]

	var includes []string
	flags := strings.Split(cflags, " ")
@@ -3981,32 +3984,32 @@ func TestIncludeDirectoryOrdering(t *testing.T) {
		"${config.ArmToolchainCflags}",
		"${config.ArmArmv7ANeonCflags}",
		"${config.ArmGenericCflags}",
		"android_arm_export_include_dirs",
		"lib32_export_include_dirs",
		"arm_export_include_dirs",
		"android_export_include_dirs",
		"linux_export_include_dirs",
		"export_include_dirs",
		"android_arm_local_include_dirs",
		"lib32_local_include_dirs",
		"arm_local_include_dirs",
		"android_local_include_dirs",
		"linux_local_include_dirs",
		"local_include_dirs",
		".",
		"libheader1",
		"libheader2",
		"libwhole1",
		"libwhole2",
		"libstatic1",
		"libstatic2",
		"libshared1",
		"libshared2",
		"liblinux",
		"libandroid",
		"libarm",
		"lib32",
		"libandroid_arm",
		"external/foo/android_arm_export_include_dirs",
		"external/foo/lib32_export_include_dirs",
		"external/foo/arm_export_include_dirs",
		"external/foo/android_export_include_dirs",
		"external/foo/linux_export_include_dirs",
		"external/foo/export_include_dirs",
		"external/foo/android_arm_local_include_dirs",
		"external/foo/lib32_local_include_dirs",
		"external/foo/arm_local_include_dirs",
		"external/foo/android_local_include_dirs",
		"external/foo/linux_local_include_dirs",
		"external/foo/local_include_dirs",
		"external/foo",
		"external/foo/libheader1",
		"external/foo/libheader2",
		"external/foo/libwhole1",
		"external/foo/libwhole2",
		"external/foo/libstatic1",
		"external/foo/libstatic2",
		"external/foo/libshared1",
		"external/foo/libshared2",
		"external/foo/liblinux",
		"external/foo/libandroid",
		"external/foo/libarm",
		"external/foo/lib32",
		"external/foo/libandroid_arm",
		"defaults/cc/common/ndk_libc++_shared",
		"defaults/cc/common/ndk_libandroid_support",
		"out/soong/ndk/sysroot/usr/include",
+2 −1
Original line number Diff line number Diff line
@@ -692,9 +692,10 @@ func isThirdParty(path string) bool {
				return false
			}
		}
	}
		return true
	}
	return false
}

// Properties for rust_bindgen related to generating rust bindings.
// This exists here so these properties can be included in a cc_default
+5 −4
Original line number Diff line number Diff line
@@ -19,23 +19,24 @@ import (
)

func TestIsThirdParty(t *testing.T) {
	shouldFail := []string{
	thirdPartyPaths := []string{
		"external/foo/",
		"vendor/bar/",
		"hardware/underwater_jaguar/",
	}
	shouldPass := []string{
	nonThirdPartyPaths := []string{
		"vendor/google/cts/",
		"hardware/google/pixel",
		"hardware/interfaces/camera",
		"hardware/ril/supa_ril",
		"bionic/libc",
	}
	for _, path := range shouldFail {
	for _, path := range thirdPartyPaths {
		if !isThirdParty(path) {
			t.Errorf("Expected %s to be considered third party", path)
		}
	}
	for _, path := range shouldPass {
	for _, path := range nonThirdPartyPaths {
		if isThirdParty(path) {
			t.Errorf("Expected %s to *not* be considered third party", path)
		}