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

Commit 53fe467c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topic "soong_tests_ndk"

* changes:
  Make apex use cc.GatherRequiredDepsForTests
  Move NDK test modules into cc/testing.go
parents 11204523 f9aabd71
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ func TestArchConfigFuchsia(buildDir string, env map[string]string, bp string, fs

	config.Targets = map[OsType][]Target{
		Fuchsia: []Target{
			{Fuchsia, Arch{ArchType: Arm64, ArchVariant: ""}, NativeBridgeDisabled, "", ""},
			{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", ""},
		},
		BuildOs: []Target{
			{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
+4 −169
Original line number Diff line number Diff line
@@ -99,112 +99,6 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
	android.ClearApexDependency()

	bp = bp + `
		toolchain_library {
			name: "libcompiler_rt-extras",
			src: "",
			vendor_available: true,
			recovery_available: true,
		}

		toolchain_library {
			name: "libatomic",
			src: "",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
		}

		toolchain_library {
			name: "libgcc",
			src: "",
			vendor_available: true,
			recovery_available: true,
		}

		toolchain_library {
			name: "libgcc_stripped",
			src: "",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
		}

		toolchain_library {
			name: "libclang_rt.builtins-aarch64-android",
			src: "",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
		}

		toolchain_library {
			name: "libclang_rt.builtins-arm-android",
			src: "",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
		}

		toolchain_library {
			name: "libclang_rt.builtins-x86_64-android",
			src: "",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
		}

		toolchain_library {
			name: "libclang_rt.builtins-i686-android",
			src: "",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
		}

		cc_object {
			name: "crtbegin_so",
			stl: "none",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
		}

		cc_object {
			name: "crtend_so",
			stl: "none",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
		}

		cc_object {
			name: "crtbegin_static",
			stl: "none",
		}

		cc_object {
			name: "crtend_android",
			stl: "none",
		}

		llndk_library {
			name: "libc",
			symbol_file: "",
			native_bridge_supported: true,
		}

		llndk_library {
			name: "libm",
			symbol_file: "",
			native_bridge_supported: true,
		}

		llndk_library {
			name: "libdl",
			symbol_file: "",
			native_bridge_supported: true,
		}

		filegroup {
			name: "myapex-file_contexts",
			srcs: [
@@ -213,6 +107,8 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
		}
	`

	bp = bp + cc.GatherRequiredDepsForTest(android.Android)

	bp = bp + java.GatherRequiredDepsForTest()

	fs := map[string][]byte{
@@ -259,6 +155,8 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
		"dummy.txt":                                  nil,
	}

	cc.GatherRequiredFilesForTest(fs)

	for _, handler := range handlers {
		// The fs now needs to be populated before creating the config, call handlers twice
		// for now, once to get any fs changes, and later after the config was created to
@@ -1013,47 +911,6 @@ func TestApexWithSystemLibsStubs(t *testing.T) {
			apex_available: [ "myapex" ],
		}

		cc_library {
			name: "libc",
			no_libcrt: true,
			nocrt: true,
			system_shared_libs: [],
			stl: "none",
			stubs: {
				versions: ["27", "28", "29"],
			},
		}

		cc_library {
			name: "libm",
			no_libcrt: true,
			nocrt: true,
			system_shared_libs: [],
			stl: "none",
			stubs: {
				versions: ["27", "28", "29"],
			},
			apex_available: [
				"//apex_available:platform",
				"myapex"
			],
		}

		cc_library {
			name: "libdl",
			no_libcrt: true,
			nocrt: true,
			system_shared_libs: [],
			stl: "none",
			stubs: {
				versions: ["27", "28", "29"],
			},
			apex_available: [
				"//apex_available:platform",
				"myapex"
			],
		}

		cc_library {
			name: "libBootstrap",
			srcs: ["mylib.cpp"],
@@ -3455,28 +3312,6 @@ func TestLegacyAndroid10Support(t *testing.T) {
			system_shared_libs: [],
			apex_available: [ "myapex" ],
		}

		cc_library {
			name: "libc++",
			srcs: ["mylib.cpp"],
			stl: "none",
			system_shared_libs: [],
			apex_available: [ "myapex" ],
		}

		cc_library_static {
			name: "libc++demangle",
			srcs: ["mylib.cpp"],
			stl: "none",
			system_shared_libs: [],
		}

		cc_library_static {
			name: "libunwind_llvm",
			srcs: ["mylib.cpp"],
			stl: "none",
			system_shared_libs: [],
		}
	`, withUnbundledBuild)

	module := ctx.ModuleForTests("myapex", "android_common_myapex_image")
+18 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ func TestVndkApexUsesVendorVariant(t *testing.T) {
			cc_library {
				name: "libprofile-extras",
				vendor_available: true,
				recovery_available: true,
				native_coverage: false,
				system_shared_libs: [],
				stl: "none",
@@ -76,6 +77,23 @@ func TestVndkApexUsesVendorVariant(t *testing.T) {
			cc_library {
				name: "libprofile-clang-extras",
				vendor_available: true,
				recovery_available: true,
				native_coverage: false,
				system_shared_libs: [],
				stl: "none",
				notice: "custom_notice",
			}
			cc_library {
				name: "libprofile-extras_ndk",
				vendor_available: true,
				native_coverage: false,
				system_shared_libs: [],
				stl: "none",
				notice: "custom_notice",
			}
			cc_library {
				name: "libprofile-clang-extras_ndk",
				vendor_available: true,
				native_coverage: false,
				system_shared_libs: [],
				stl: "none",
+5 −5
Original line number Diff line number Diff line
@@ -2674,20 +2674,20 @@ func TestStaticDepsOrderWithStubs(t *testing.T) {
		cc_binary {
			name: "mybin",
			srcs: ["foo.c"],
			static_libs: ["libB"],
			static_libs: ["libfooB"],
			static_executable: true,
			stl: "none",
		}

		cc_library {
			name: "libB",
			name: "libfooB",
			srcs: ["foo.c"],
			shared_libs: ["libC"],
			shared_libs: ["libfooC"],
			stl: "none",
		}

		cc_library {
			name: "libC",
			name: "libfooC",
			srcs: ["foo.c"],
			stl: "none",
			stubs: {
@@ -2697,7 +2697,7 @@ func TestStaticDepsOrderWithStubs(t *testing.T) {

	mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a").Module().(*Module)
	actual := mybin.depsInLinkOrder
	expected := getOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libB", "libC"})
	expected := getOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libfooB", "libfooC"})

	if !reflect.DeepEqual(actual, expected) {
		t.Errorf("staticDeps orderings were not propagated correctly"+
+95 −1
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
	ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
	ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
	ctx.RegisterModuleType("cc_object", ObjectFactory)
	ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
	ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
}

func GatherRequiredDepsForTest(os android.OsType) string {
@@ -37,6 +39,7 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "libatomic",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
			src: "",
		}

@@ -51,6 +54,7 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "libclang_rt.builtins-arm-android",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
			src: "",
		}

@@ -58,6 +62,7 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "libclang_rt.builtins-aarch64-android",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
			src: "",
		}

@@ -65,6 +70,7 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "libclang_rt.builtins-i686-android",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
			src: "",
		}

@@ -72,6 +78,7 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "libclang_rt.builtins-x86_64-android",
			vendor_available: true,
			recovery_available: true,
			native_bridge_supported: true,
			src: "",
		}

@@ -115,6 +122,7 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "libclang_rt.ubsan_standalone-aarch64-android",
			vendor_available: true,
			recovery_available: true,
			system_shared_libs: [],
			srcs: [""],
		}

@@ -139,6 +147,9 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			stl: "none",
			system_shared_libs: [],
			recovery_available: true,
			stubs: {
				versions: ["27", "28", "29"],
			},
		}
		llndk_library {
			name: "libc",
@@ -151,6 +162,13 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			stl: "none",
			system_shared_libs: [],
			recovery_available: true,
			stubs: {
				versions: ["27", "28", "29"],
			},
			apex_available: [
				"//apex_available:platform",
				"myapex"
			],
		}
		llndk_library {
			name: "libm",
@@ -163,6 +181,13 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			stl: "none",
			system_shared_libs: [],
			recovery_available: true,
			stubs: {
				versions: ["27", "28", "29"],
			},
			apex_available: [
				"//apex_available:platform",
				"myapex"
			],
		}
		llndk_library {
			name: "libdl",
@@ -201,6 +226,10 @@ func GatherRequiredDepsForTest(os android.OsType) string {
				enabled: true,
				support_system_process: true,
			},
			apex_available: [
				"//apex_available:platform",
				"myapex"
			],
		}
		cc_library {
			name: "libc++demangle",
@@ -226,6 +255,7 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "crtbegin_so",
			recovery_available: true,
			vendor_available: true,
			native_bridge_supported: true,
			stl: "none",
		}

@@ -233,18 +263,23 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "crtbegin_dynamic",
			recovery_available: true,
			vendor_available: true,
			native_bridge_supported: true,
			stl: "none",
		}

		cc_object {
			name: "crtbegin_static",
			recovery_available: true,
			vendor_available: true,
			native_bridge_supported: true,
			stl: "none",
		}

		cc_object {
			name: "crtend_so",
			recovery_available: true,
			vendor_available: true,
			native_bridge_supported: true,
			stl: "none",
		}

@@ -252,12 +287,57 @@ func GatherRequiredDepsForTest(os android.OsType) string {
			name: "crtend_android",
			recovery_available: true,
			vendor_available: true,
			native_bridge_supported: true,
			stl: "none",
		}

		cc_library {
			name: "libprotobuf-cpp-lite",
		}

		cc_library {
			name: "ndk_libunwind",
			sdk_version: "current",
			stl: "none",
			system_shared_libs: [],
		}

		cc_library {
			name: "libc.ndk.current",
			sdk_version: "current",
			stl: "none",
			system_shared_libs: [],
		}

		cc_library {
			name: "libm.ndk.current",
			sdk_version: "current",
			stl: "none",
			system_shared_libs: [],
		}

		cc_library {
			name: "libdl.ndk.current",
			sdk_version: "current",
			stl: "none",
			system_shared_libs: [],
		}

		ndk_prebuilt_object {
			name: "ndk_crtbegin_so.27",
			sdk_version: "27",
		}

		ndk_prebuilt_object {
			name: "ndk_crtend_so.27",
			sdk_version: "27",
		}

		ndk_prebuilt_shared_stl {
			name: "ndk_libc++_shared",
		}
	`

	if os == android.Fuchsia {
		ret += `
		cc_library {
@@ -273,6 +353,18 @@ func GatherRequiredDepsForTest(os android.OsType) string {
	return ret
}

func GatherRequiredFilesForTest(fs map[string][]byte) {
	fs["prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so"] = nil
	fs["prebuilts/ndk/current/platforms/android-27/arch-arm/usr/lib/crtbegin_so.o"] = nil
	fs["prebuilts/ndk/current/platforms/android-27/arch-arm/usr/lib/crtend_so.o"] = nil
	fs["prebuilts/ndk/current/platforms/android-27/arch-arm64/usr/lib/crtbegin_so.o"] = nil
	fs["prebuilts/ndk/current/platforms/android-27/arch-arm64/usr/lib/crtend_so.o"] = nil
	fs["prebuilts/ndk/current/platforms/android-27/arch-x86/usr/lib/crtbegin_so.o"] = nil
	fs["prebuilts/ndk/current/platforms/android-27/arch-x86/usr/lib/crtend_so.o"] = nil
	fs["prebuilts/ndk/current/platforms/android-27/arch-x86_64/usr/lib64/crtbegin_so.o"] = nil
	fs["prebuilts/ndk/current/platforms/android-27/arch-x86_64/usr/lib64/crtend_so.o"] = nil
}

func TestConfig(buildDir string, os android.OsType, env map[string]string,
	bp string, fs map[string][]byte) android.Config {

@@ -293,6 +385,8 @@ func TestConfig(buildDir string, os android.OsType, env map[string]string,
		"liba.so":     nil,
	}

	GatherRequiredFilesForTest(mockFS)

	for k, v := range fs {
		mockFS[k] = v
	}
Loading