diff --git a/apex/Android.bp b/apex/Android.bp index 27017ae02..abae9e261 100644 --- a/apex/Android.bp +++ b/apex/Android.bp @@ -40,7 +40,6 @@ bootstrap_go_package { "dexpreopt_bootjars_test.go", "platform_bootclasspath_test.go", "systemserver_classpath_fragment_test.go", - "vndk_test.go", ], pluginFor: ["soong_build"], } diff --git a/apex/apex_test.go b/apex/apex_test.go index b7362b202..907e1f7e9 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -218,7 +218,6 @@ var prepareForApexTest = android.GroupFixturePreparers( ), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.DeviceVndkVersion = proptools.StringPtr("current") variables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test") variables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"} variables.Platform_sdk_codename = proptools.StringPtr("Q") @@ -226,7 +225,6 @@ var prepareForApexTest = android.GroupFixturePreparers( // "Tiramisu" needs to be in the next line for compatibility with soong code, // not because of these tests specifically (it's not used by the tests) variables.Platform_version_active_codenames = []string{"Q", "Tiramisu"} - variables.Platform_vndk_version = proptools.StringPtr("29") variables.BuildId = proptools.StringPtr("TEST.BUILD_ID") }), ) @@ -2062,9 +2060,9 @@ func TestApexMinSdkVersion_InVendorApex(t *testing.T) { } `) - vendorVariant := "android_vendor.29_arm64_armv8-a" + vendorVariant := "android_vendor_arm64_armv8-a" - mylib := ctx.ModuleForTests("mylib", vendorVariant+"_shared_myapex") + mylib := ctx.ModuleForTests("mylib", vendorVariant+"_shared_apex29") // Ensure that mylib links with "current" LLNDK libFlags := names(mylib.Rule("ld").Args["libFlags"]) @@ -3025,158 +3023,6 @@ func TestVendorApex(t *testing.T) { ensureListNotContains(t, requireNativeLibs, ":vndk") } -func TestVendorApex_use_vndk_as_stable_TryingToIncludeVNDKLib(t *testing.T) { - testApexError(t, `Trying to include a VNDK library`, ` - apex { - name: "myapex", - key: "myapex.key", - native_shared_libs: ["libc++"], // libc++ is a VNDK lib - vendor: true, - use_vndk_as_stable: true, - updatable: false, - } - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - }`) -} - -func TestVendorApex_use_vndk_as_stable(t *testing.T) { - // myapex myapex2 - // | | - // mybin ------. mybin2 - // \ \ / | - // (stable) .---\--------` | - // \ / \ | - // \ / \ / - // libvndk libvendor - // (vndk) - ctx := testApex(t, ` - apex { - name: "myapex", - key: "myapex.key", - binaries: ["mybin"], - vendor: true, - use_vndk_as_stable: true, - updatable: false, - } - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - cc_binary { - name: "mybin", - vendor: true, - shared_libs: ["libvndk", "libvendor"], - } - cc_library { - name: "libvndk", - vndk: { - enabled: true, - }, - vendor_available: true, - product_available: true, - } - cc_library { - name: "libvendor", - vendor: true, - stl: "none", - } - apex { - name: "myapex2", - key: "myapex.key", - binaries: ["mybin2"], - vendor: true, - use_vndk_as_stable: false, - updatable: false, - } - cc_binary { - name: "mybin2", - vendor: true, - shared_libs: ["libvndk", "libvendor"], - } - `, - android.FixtureModifyConfig(func(config android.Config) { - config.TestProductVariables.KeepVndk = proptools.BoolPtr(true) - }), - ) - - vendorVariant := "android_vendor.29_arm64_armv8-a" - - for _, tc := range []struct { - name string - apexName string - moduleName string - moduleVariant string - libs []string - contents []string - requireVndkNamespace bool - }{ - { - name: "use_vndk_as_stable", - apexName: "myapex", - moduleName: "mybin", - moduleVariant: vendorVariant + "_apex10000", - libs: []string{ - // should link with vendor variants of VNDK libs(libvndk/libc++) - "out/soong/.intermediates/libvndk/" + vendorVariant + "_shared/libvndk.so", - "out/soong/.intermediates/" + cc.DefaultCcCommonTestModulesDir + "libc++/" + vendorVariant + "_shared/libc++.so", - // unstable Vendor libs as APEX variant - "out/soong/.intermediates/libvendor/" + vendorVariant + "_shared_apex10000/libvendor.so", - }, - contents: []string{ - "bin/mybin", - "lib64/libvendor.so", - // VNDK libs (libvndk/libc++) are not included - }, - requireVndkNamespace: true, - }, - { - name: "!use_vndk_as_stable", - apexName: "myapex2", - moduleName: "mybin2", - moduleVariant: vendorVariant + "_myapex2", - libs: []string{ - // should link with "unique" APEX(myapex2) variant of VNDK libs(libvndk/libc++) - "out/soong/.intermediates/libvndk/" + vendorVariant + "_shared_myapex2/libvndk.so", - "out/soong/.intermediates/" + cc.DefaultCcCommonTestModulesDir + "libc++/" + vendorVariant + "_shared_myapex2/libc++.so", - // unstable vendor libs have "merged" APEX variants - "out/soong/.intermediates/libvendor/" + vendorVariant + "_shared_apex10000/libvendor.so", - }, - contents: []string{ - "bin/mybin2", - "lib64/libvendor.so", - // VNDK libs are included as well - "lib64/libvndk.so", - "lib64/libc++.so", - }, - requireVndkNamespace: false, - }, - } { - t.Run(tc.name, func(t *testing.T) { - // Check linked libs - ldRule := ctx.ModuleForTests(tc.moduleName, tc.moduleVariant).Rule("ld") - libs := names(ldRule.Args["libFlags"]) - for _, lib := range tc.libs { - ensureListContains(t, libs, lib) - } - // Check apex contents - ensureExactContents(t, ctx, tc.apexName, "android_common_"+tc.apexName, tc.contents) - - // Check "requireNativeLibs" - apexManifestRule := ctx.ModuleForTests(tc.apexName, "android_common_"+tc.apexName).Rule("apexManifestRule") - requireNativeLibs := names(apexManifestRule.Args["requireNativeLibs"]) - if tc.requireVndkNamespace { - ensureListContains(t, requireNativeLibs, ":vndk") - } else { - ensureListNotContains(t, requireNativeLibs, ":vndk") - } - }) - } -} - func TestProductVariant(t *testing.T) { ctx := testApex(t, ` apex { @@ -3202,7 +3048,7 @@ func TestProductVariant(t *testing.T) { `) cflags := strings.Fields( - ctx.ModuleForTests("foo", "android_product.29_arm64_armv8-a_myapex").Rule("cc").Args["cFlags"]) + ctx.ModuleForTests("foo", "android_product_arm64_armv8-a_apex10000").Rule("cc").Args["cFlags"]) ensureListContains(t, cflags, "-D__ANDROID_VNDK__") ensureListContains(t, cflags, "-D__ANDROID_APEX__") ensureListContains(t, cflags, "-D__ANDROID_PRODUCT__") @@ -3823,166 +3669,6 @@ func ensureExactDeapexedContents(t *testing.T, ctx *android.TestContext, moduleN assertFileListEquals(t, files, actualFiles) } -func TestVndkApexCurrent(t *testing.T) { - commonFiles := []string{ - "lib/libc++.so", - "lib64/libc++.so", - "etc/llndk.libraries.29.txt", - "etc/vndkcore.libraries.29.txt", - "etc/vndksp.libraries.29.txt", - "etc/vndkprivate.libraries.29.txt", - "etc/vndkproduct.libraries.29.txt", - } - testCases := []struct { - vndkVersion string - expectedFiles []string - }{ - { - vndkVersion: "current", - expectedFiles: append(commonFiles, - "lib/libvndk.so", - "lib/libvndksp.so", - "lib64/libvndk.so", - "lib64/libvndksp.so"), - }, - } - for _, tc := range testCases { - t.Run("VNDK.current with DeviceVndkVersion="+tc.vndkVersion, func(t *testing.T) { - ctx := testApex(t, ` - apex_vndk { - name: "com.android.vndk.current", - key: "com.android.vndk.current.key", - updatable: false, - } - - apex_key { - name: "com.android.vndk.current.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_library { - name: "libvndk", - srcs: ["mylib.cpp"], - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - system_shared_libs: [], - stl: "none", - apex_available: [ "com.android.vndk.current" ], - } - - cc_library { - name: "libvndksp", - srcs: ["mylib.cpp"], - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - system_shared_libs: [], - stl: "none", - apex_available: [ "com.android.vndk.current" ], - } - - // VNDK-Ext should not cause any problems - - cc_library { - name: "libvndk.ext", - srcs: ["mylib2.cpp"], - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - system_shared_libs: [], - stl: "none", - } - - cc_library { - name: "libvndksp.ext", - srcs: ["mylib2.cpp"], - vendor: true, - vndk: { - enabled: true, - support_system_process: true, - extends: "libvndksp", - }, - system_shared_libs: [], - stl: "none", - } - `+vndkLibrariesTxtFiles("current"), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.DeviceVndkVersion = proptools.StringPtr(tc.vndkVersion) - variables.KeepVndk = proptools.BoolPtr(true) - })) - ensureExactContents(t, ctx, "com.android.vndk.current", "android_common", tc.expectedFiles) - }) - } -} - -func TestVndkApexWithPrebuilt(t *testing.T) { - ctx := testApex(t, ` - apex_vndk { - name: "com.android.vndk.current", - key: "com.android.vndk.current.key", - updatable: false, - } - - apex_key { - name: "com.android.vndk.current.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_prebuilt_library_shared { - name: "libvndk", - srcs: ["libvndk.so"], - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - system_shared_libs: [], - stl: "none", - apex_available: [ "com.android.vndk.current" ], - } - - cc_prebuilt_library_shared { - name: "libvndk.arm", - srcs: ["libvndk.arm.so"], - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - enabled: false, - arch: { - arm: { - enabled: true, - }, - }, - system_shared_libs: [], - stl: "none", - apex_available: [ "com.android.vndk.current" ], - } - `+vndkLibrariesTxtFiles("current"), - withFiles(map[string][]byte{ - "libvndk.so": nil, - "libvndk.arm.so": nil, - })) - ensureExactContents(t, ctx, "com.android.vndk.current", "android_common", []string{ - "lib/libvndk.so", - "lib/libvndk.arm.so", - "lib64/libvndk.so", - "lib/libc++.so", - "lib64/libc++.so", - "etc/*", - }) -} - func vndkLibrariesTxtFiles(vers ...string) (result string) { for _, v := range vers { if v == "current" { @@ -4090,9 +3776,10 @@ func TestVndkApexVersion(t *testing.T) { func TestVndkApexNameRule(t *testing.T) { ctx := testApex(t, ` apex_vndk { - name: "com.android.vndk.current", + name: "com.android.vndk.v29", key: "myapex.key", file_contexts: ":myapex-file_contexts", + vndk_version: "29", updatable: false, } apex_vndk { @@ -4106,7 +3793,7 @@ func TestVndkApexNameRule(t *testing.T) { name: "myapex.key", public_key: "testkey.avbpubkey", private_key: "testkey.pem", - }`+vndkLibrariesTxtFiles("28", "current")) + }`+vndkLibrariesTxtFiles("28", "29")) assertApexName := func(expected, moduleName string) { module := ctx.ModuleForTests(moduleName, "android_common") @@ -4114,51 +3801,10 @@ func TestVndkApexNameRule(t *testing.T) { ensureContains(t, apexManifestRule.Args["opt"], "-v name "+expected) } - assertApexName("com.android.vndk.v29", "com.android.vndk.current") + assertApexName("com.android.vndk.v29", "com.android.vndk.v29") assertApexName("com.android.vndk.v28", "com.android.vndk.v28") } -func TestVndkApexSkipsNativeBridgeSupportedModules(t *testing.T) { - ctx := testApex(t, ` - apex_vndk { - name: "com.android.vndk.current", - key: "com.android.vndk.current.key", - file_contexts: ":myapex-file_contexts", - updatable: false, - } - - apex_key { - name: "com.android.vndk.current.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_library { - name: "libvndk", - srcs: ["mylib.cpp"], - vendor_available: true, - product_available: true, - native_bridge_supported: true, - host_supported: true, - vndk: { - enabled: true, - }, - system_shared_libs: [], - stl: "none", - apex_available: [ "com.android.vndk.current" ], - } - `+vndkLibrariesTxtFiles("current"), - withNativeBridgeEnabled) - - ensureExactContents(t, ctx, "com.android.vndk.current", "android_common", []string{ - "lib/libvndk.so", - "lib64/libvndk.so", - "lib/libc++.so", - "lib64/libc++.so", - "etc/*", - }) -} - func TestVndkApexDoesntSupportNativeBridgeSupported(t *testing.T) { testApexError(t, `module "com.android.vndk.current" .*: native_bridge_supported: .* doesn't support native bridge binary`, ` apex_vndk { @@ -4259,47 +3905,6 @@ func TestVndkApexWithBinder32(t *testing.T) { }) } -func TestVndkApexShouldNotProvideNativeLibs(t *testing.T) { - ctx := testApex(t, ` - apex_vndk { - name: "com.android.vndk.current", - key: "com.android.vndk.current.key", - file_contexts: ":myapex-file_contexts", - updatable: false, - } - - apex_key { - name: "com.android.vndk.current.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_library { - name: "libz", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - stubs: { - symbol_file: "libz.map.txt", - versions: ["30"], - } - } - `+vndkLibrariesTxtFiles("current"), withFiles(map[string][]byte{ - "libz.map.txt": nil, - })) - - apexManifestRule := ctx.ModuleForTests("com.android.vndk.current", "android_common").Rule("apexManifestRule") - provideNativeLibs := names(apexManifestRule.Args["provideNativeLibs"]) - ensureListEmpty(t, provideNativeLibs) - ensureExactContents(t, ctx, "com.android.vndk.current", "android_common", []string{ - "out/soong/.intermediates/libz/android_vendor.29_arm64_armv8-a_shared/libz.so:lib64/libz.so", - "out/soong/.intermediates/libz/android_vendor.29_arm_armv7-a-neon_shared/libz.so:lib/libz.so", - "*/*", - }) -} - func TestVendorApexWithVndkPrebuilts(t *testing.T) { ctx := testApex(t, "", android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { diff --git a/apex/vndk_test.go b/apex/vndk_test.go deleted file mode 100644 index 894aece9d..000000000 --- a/apex/vndk_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package apex - -import ( - "testing" - - "github.com/google/blueprint/proptools" - - "android/soong/android" -) - -func TestVndkApexUsesVendorVariant(t *testing.T) { - bp := ` - apex_vndk { - name: "com.android.vndk.current", - key: "mykey", - updatable: false, - } - apex_key { - name: "mykey", - } - cc_library { - name: "libfoo", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - system_shared_libs: [], - stl: "none", - } - ` + vndkLibrariesTxtFiles("current") - - ensureFileSrc := func(t *testing.T, files []fileInApex, path, src string) { - t.Helper() - for _, f := range files { - if f.path == path { - ensureContains(t, f.src, src) - return - } - } - t.Errorf("expected path %q not found", path) - } - - t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) { - ctx := testApex(t, bp) - - // libfoo doesn't have apex variants - for _, variant := range ctx.ModuleVariantsForTests("libfoo") { - ensureNotContains(t, variant, "_myapex") - } - - // VNDK APEX doesn't create apex variant - files := getFiles(t, ctx, "com.android.vndk.current", "android_common") - ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so") - }) - - t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) { - ctx := testApex(t, bp) - - files := getFiles(t, ctx, "com.android.vndk.current", "android_common") - ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so") - }) - - t.Run("VNDK APEX supports coverage variants", func(t *testing.T) { - ctx := testApex(t, bp, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.GcovCoverage = proptools.BoolPtr(true) - variables.Native_coverage = proptools.BoolPtr(true) - }), - ) - - files := getFiles(t, ctx, "com.android.vndk.current", "android_common") - ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so") - - files = getFiles(t, ctx, "com.android.vndk.current", "android_common_cov") - ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared_cov/libfoo.so") - }) -} diff --git a/cc/cc_test.go b/cc/cc_test.go index d1b728ea2..74fae04f4 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -17,7 +17,6 @@ package cc import ( "fmt" "os" - "path/filepath" "reflect" "regexp" "runtime" @@ -39,17 +38,6 @@ func TestMain(m *testing.M) { } var prepareForCcTest = android.GroupFixturePreparers( - PrepareForTestWithCcIncludeVndk, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.VendorApiLevel = StringPtr("202404") - variables.DeviceVndkVersion = StringPtr("current") - variables.KeepVndk = BoolPtr(true) - variables.Platform_vndk_version = StringPtr("29") - }), -) - -// TODO(b/316829758) Update prepareForCcTest with this configuration and remove prepareForCcTestWithoutVndk -var prepareForCcTestWithoutVndk = android.GroupFixturePreparers( PrepareForIntegrationTestWithCc, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.VendorApiLevel = StringPtr("202404") @@ -123,30 +111,14 @@ func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) func testCcError(t *testing.T, pattern string, bp string) { t.Helper() config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - testCcErrorWithConfig(t, pattern, config) - return -} - -// testCcErrorProductVndk runs tests using the prepareForCcTest -// -// See testCc for an explanation as to how to stop using this deprecated method. -// -// deprecated -func testCcErrorProductVndk(t *testing.T, pattern string, bp string) { - t.Helper() - config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") testCcErrorWithConfig(t, pattern, config) return } const ( coreVariant = "android_arm64_armv8-a_shared" - vendorVariant = "android_vendor.29_arm64_armv8-a_shared" - productVariant = "android_product.29_arm64_armv8-a_shared" + vendorVariant = "android_vendor_arm64_armv8-a_shared" + productVariant = "android_product_arm64_armv8-a_shared" recoveryVariant = "android_recovery_arm64_armv8-a_shared" ) @@ -302,44 +274,6 @@ func TestInstallPartition(t *testing.T) { checkInstallPartition(t, ctx, "libproduct_odmavailable", vendorVariant, "odm") } -func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string, - isVndkSp bool, extends string, variant string) { - - t.Helper() - - mod := ctx.ModuleForTests(name, variant).Module().(*Module) - - // Check library properties. - lib, ok := mod.compiler.(*libraryDecorator) - if !ok { - t.Errorf("%q must have libraryDecorator", name) - } else if lib.baseInstaller.subDir != subDir { - t.Errorf("%q must use %q as subdir but it is using %q", name, subDir, - lib.baseInstaller.subDir) - } - - // Check VNDK properties. - if mod.vndkdep == nil { - t.Fatalf("%q must have `vndkdep`", name) - } - if !mod.IsVndk() { - t.Errorf("%q IsVndk() must equal to true", name) - } - if mod.IsVndkSp() != isVndkSp { - t.Errorf("%q IsVndkSp() must equal to %t", name, isVndkSp) - } - - // Check VNDK extension properties. - isVndkExt := extends != "" - if mod.IsVndkExt() != isVndkExt { - t.Errorf("%q IsVndkExt() must equal to %t", name, isVndkExt) - } - - if actualExtends := mod.getVndkExtendsModuleName(); actualExtends != extends { - t.Errorf("%q must extend from %q but get %q", name, extends, actualExtends) - } -} - func checkWriteFileOutput(t *testing.T, ctx *android.TestContext, params android.TestingBuildParams, expected []string) { t.Helper() content := android.ContentFromFileRuleForTests(t, ctx, params) @@ -347,344 +281,6 @@ func checkWriteFileOutput(t *testing.T, ctx *android.TestContext, params android assertArrayString(t, actual, expected) } -func checkVndkOutput(t *testing.T, ctx *android.TestContext, output string, expected []string) { - t.Helper() - vndkSnapshot := ctx.SingletonForTests("vndk-snapshot") - checkWriteFileOutput(t, ctx, vndkSnapshot.Output(output), expected) -} - -func checkVndkLibrariesOutput(t *testing.T, ctx *android.TestContext, module string, expected []string) { - t.Helper() - got := ctx.ModuleForTests(module, "android_common").Module().(*vndkLibrariesTxt).fileNames - assertArrayString(t, got, expected) -} - -func TestVndk(t *testing.T) { - t.Parallel() - bp := ` - cc_library { - name: "libvndk", - vendor_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_private", - vendor_available: true, - vndk: { - enabled: true, - private: true, - }, - nocrt: true, - stem: "libvndk-private", - } - - cc_library { - name: "libvndk_product", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - target: { - vendor: { - cflags: ["-DTEST"], - }, - product: { - cflags: ["-DTEST"], - }, - }, - } - - cc_library { - name: "libvndk_sp", - vendor_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - suffix: "-x", - } - - cc_library { - name: "libvndk_sp_private", - vendor_available: true, - vndk: { - enabled: true, - support_system_process: true, - private: true, - }, - nocrt: true, - target: { - vendor: { - suffix: "-x", - }, - }, - } - - cc_library { - name: "libvndk_sp_product_private", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - private: true, - }, - nocrt: true, - target: { - vendor: { - suffix: "-x", - }, - product: { - suffix: "-x", - }, - }, - } - - cc_library { - name: "libllndk", - llndk: { - symbol_file: "libllndk.map.txt", - export_llndk_headers: ["libllndk_headers"], - } - } - - cc_library { - name: "libclang_rt.hwasan-llndk", - llndk: { - symbol_file: "libclang_rt.hwasan.map.txt", - } - } - - cc_library_headers { - name: "libllndk_headers", - llndk: { - llndk_headers: true, - }, - export_include_dirs: ["include"], - } - - llndk_libraries_txt { - name: "llndk.libraries.txt", - } - vndkcore_libraries_txt { - name: "vndkcore.libraries.txt", - } - vndksp_libraries_txt { - name: "vndksp.libraries.txt", - } - vndkprivate_libraries_txt { - name: "vndkprivate.libraries.txt", - } - vndkproduct_libraries_txt { - name: "vndkproduct.libraries.txt", - } - vndkcorevariant_libraries_txt { - name: "vndkcorevariant.libraries.txt", - insert_vndk_version: false, - } - ` - - config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - - ctx := testCcWithConfig(t, config) - - // subdir == "" because VNDK libs are not supposed to be installed separately. - // They are installed as part of VNDK APEX instead. - checkVndkModule(t, ctx, "libvndk", "", false, "", vendorVariant) - checkVndkModule(t, ctx, "libvndk_private", "", false, "", vendorVariant) - checkVndkModule(t, ctx, "libvndk_product", "", false, "", vendorVariant) - checkVndkModule(t, ctx, "libvndk_sp", "", true, "", vendorVariant) - checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", vendorVariant) - checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", vendorVariant) - - checkVndkModule(t, ctx, "libvndk_product", "", false, "", productVariant) - checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", productVariant) - - // Check VNDK snapshot output. - snapshotDir := "vndk-snapshot" - snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") - - vndkLibPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s", - "arm64", "armv8-a")) - vndkLib2ndPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s", - "arm", "armv7-a-neon")) - - vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core") - vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp") - llndkLibPath := filepath.Join(vndkLibPath, "shared", "llndk-stub") - - vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core") - vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp") - llndkLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "llndk-stub") - - variant := "android_vendor.29_arm64_armv8-a_shared" - variant2nd := "android_vendor.29_arm_armv7-a-neon_shared" - - snapshotSingleton := ctx.SingletonForTests("vndk-snapshot") - - CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLibPath, variant) - CheckSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLib2ndPath, variant2nd) - CheckSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLibPath, variant) - CheckSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLib2ndPath, variant2nd) - CheckSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLibPath, variant) - CheckSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLib2ndPath, variant2nd) - CheckSnapshot(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", llndkLibPath, variant) - CheckSnapshot(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", llndkLib2ndPath, variant2nd) - - snapshotConfigsPath := filepath.Join(snapshotVariantPath, "configs") - CheckSnapshot(t, ctx, snapshotSingleton, "llndk.libraries.txt", "llndk.libraries.txt", snapshotConfigsPath, "android_common") - CheckSnapshot(t, ctx, snapshotSingleton, "vndkcore.libraries.txt", "vndkcore.libraries.txt", snapshotConfigsPath, "android_common") - CheckSnapshot(t, ctx, snapshotSingleton, "vndksp.libraries.txt", "vndksp.libraries.txt", snapshotConfigsPath, "android_common") - CheckSnapshot(t, ctx, snapshotSingleton, "vndkprivate.libraries.txt", "vndkprivate.libraries.txt", snapshotConfigsPath, "android_common") - CheckSnapshot(t, ctx, snapshotSingleton, "vndkproduct.libraries.txt", "vndkproduct.libraries.txt", snapshotConfigsPath, "android_common") - - checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{ - "LLNDK: libc.so", - "LLNDK: libdl.so", - "LLNDK: libft2.so", - "LLNDK: libllndk.so", - "LLNDK: libm.so", - "VNDK-SP: libc++.so", - "VNDK-SP: libvndk_sp-x.so", - "VNDK-SP: libvndk_sp_private-x.so", - "VNDK-SP: libvndk_sp_product_private-x.so", - "VNDK-core: libvndk-private.so", - "VNDK-core: libvndk.so", - "VNDK-core: libvndk_product.so", - "VNDK-private: libft2.so", - "VNDK-private: libvndk-private.so", - "VNDK-private: libvndk_sp_private-x.so", - "VNDK-private: libvndk_sp_product_private-x.so", - "VNDK-product: libc++.so", - "VNDK-product: libvndk_product.so", - "VNDK-product: libvndk_sp_product_private-x.so", - }) - checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", []string{"libc.so", "libclang_rt.hwasan-llndk.so", "libdl.so", "libft2.so", "libllndk.so", "libm.so"}) - checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk-private.so", "libvndk.so", "libvndk_product.so"}) - checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", []string{"libc++.so", "libvndk_sp-x.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"}) - checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", []string{"libft2.so", "libvndk-private.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"}) - checkVndkLibrariesOutput(t, ctx, "vndkproduct.libraries.txt", []string{"libc++.so", "libvndk_product.so", "libvndk_sp_product_private-x.so"}) - checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", nil) -} - -func TestVndkWithHostSupported(t *testing.T) { - t.Parallel() - ctx := testCc(t, ` - cc_library { - name: "libvndk_host_supported", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - host_supported: true, - } - - cc_library { - name: "libvndk_host_supported_but_disabled_on_device", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - host_supported: true, - enabled: false, - target: { - host: { - enabled: true, - } - } - } - - vndkcore_libraries_txt { - name: "vndkcore.libraries.txt", - } - `) - - checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk_host_supported.so"}) -} - -func TestVndkLibrariesTxtAndroidMk(t *testing.T) { - t.Parallel() - bp := ` - llndk_libraries_txt { - name: "llndk.libraries.txt", - insert_vndk_version: true, - }` - config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - config.TestProductVariables.KeepVndk = BoolPtr(true) - ctx := testCcWithConfig(t, config) - - module := ctx.ModuleForTests("llndk.libraries.txt", "android_common") - entries := android.AndroidMkEntriesForTest(t, ctx, module.Module())[0] - assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.29.txt"}) -} - -func TestVndkUsingCoreVariant(t *testing.T) { - t.Parallel() - bp := ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk2", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - private: true, - }, - nocrt: true, - } - - vndkcorevariant_libraries_txt { - name: "vndkcorevariant.libraries.txt", - insert_vndk_version: false, - } - ` - - config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) - config.TestProductVariables.KeepVndk = BoolPtr(true) - - setVndkMustUseVendorVariantListForTest(config, []string{"libvndk"}) - - ctx := testCcWithConfig(t, config) - - checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", []string{"libc++.so", "libvndk2.so", "libvndk_sp.so"}) -} - func TestDataLibs(t *testing.T) { t.Parallel() bp := ` @@ -702,9 +298,6 @@ func TestDataLibs(t *testing.T) { ` config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) ctx := testCcWithConfig(t, config) module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module() @@ -761,9 +354,6 @@ func TestDataLibsRelativeInstallPath(t *testing.T) { ` config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) ctx := testCcWithConfig(t, config) module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module() @@ -859,247 +449,9 @@ func TestTestLibraryTestSuites(t *testing.T) { } } -func TestVndkModuleError(t *testing.T) { - t.Parallel() - // Check the error message for vendor_available and product_available properties. - testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`", ` - cc_library { - name: "libvndk", - vndk: { - enabled: true, - }, - nocrt: true, - } - `) - - testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`", ` - cc_library { - name: "libvndk", - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - `) - - testCcErrorProductVndk(t, "product properties must have the same values with the vendor properties for VNDK modules", ` - cc_library { - name: "libvndkprop", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - target: { - vendor: { - cflags: ["-DTEST",], - }, - }, - } - `) -} - -func TestVndkDepError(t *testing.T) { - t.Parallel() - // Check whether an error is emitted when a VNDK lib depends on a system lib. - testCcError(t, "dependency \".*\" of \".*\" missing variant", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - shared_libs: ["libfwk"], // Cause error - nocrt: true, - } - - cc_library { - name: "libfwk", - nocrt: true, - } - `) - - // Check whether an error is emitted when a VNDK lib depends on a vendor lib. - testCcError(t, "dependency \".*\" of \".*\" missing variant", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - shared_libs: ["libvendor"], // Cause error - nocrt: true, - } - - cc_library { - name: "libvendor", - vendor: true, - nocrt: true, - } - `) - - // Check whether an error is emitted when a VNDK-SP lib depends on a system lib. - testCcError(t, "dependency \".*\" of \".*\" missing variant", ` - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - shared_libs: ["libfwk"], // Cause error - nocrt: true, - } - - cc_library { - name: "libfwk", - nocrt: true, - } - `) - - // Check whether an error is emitted when a VNDK-SP lib depends on a vendor lib. - testCcError(t, "dependency \".*\" of \".*\" missing variant", ` - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - shared_libs: ["libvendor"], // Cause error - nocrt: true, - } - - cc_library { - name: "libvendor", - vendor: true, - nocrt: true, - } - `) - - // Check whether an error is emitted when a VNDK-SP lib depends on a VNDK lib. - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - shared_libs: ["libvndk"], // Cause error - nocrt: true, - } - - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - `) - - // Check whether an error is emitted when a VNDK lib depends on a non-VNDK lib. - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - shared_libs: ["libnonvndk"], - nocrt: true, - } - - cc_library { - name: "libnonvndk", - vendor_available: true, - product_available: true, - nocrt: true, - } - `) - - // Check whether an error is emitted when a VNDK-private lib depends on a non-VNDK lib. - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndkprivate", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - private: true, - }, - shared_libs: ["libnonvndk"], - nocrt: true, - } - - cc_library { - name: "libnonvndk", - vendor_available: true, - product_available: true, - nocrt: true, - } - `) - - // Check whether an error is emitted when a VNDK-sp lib depends on a non-VNDK lib. - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndksp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - shared_libs: ["libnonvndk"], - nocrt: true, - } - - cc_library { - name: "libnonvndk", - vendor_available: true, - product_available: true, - nocrt: true, - } - `) - - // Check whether an error is emitted when a VNDK-sp-private lib depends on a non-VNDK lib. - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndkspprivate", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - private: true, - }, - shared_libs: ["libnonvndk"], - nocrt: true, - } - - cc_library { - name: "libnonvndk", - vendor_available: true, - product_available: true, - nocrt: true, - } - `) -} - func TestDoubleLoadbleDep(t *testing.T) { t.Parallel() - // okay to link : LLNDK -> double_loadable VNDK + // okay to link : LLNDK -> double_loadable testCc(t, ` cc_library { name: "libllndk", @@ -1113,32 +465,9 @@ func TestDoubleLoadbleDep(t *testing.T) { name: "libdoubleloadable", vendor_available: true, product_available: true, - vndk: { - enabled: true, - }, double_loadable: true, } `) - // okay to link : LLNDK -> VNDK-SP - testCc(t, ` - cc_library { - name: "libllndk", - shared_libs: ["libvndksp"], - llndk: { - symbol_file: "libllndk.map.txt", - } - } - - cc_library { - name: "libvndksp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - } - `) // okay to link : double_loadable -> double_loadable testCc(t, ` cc_library { @@ -1154,15 +483,12 @@ func TestDoubleLoadbleDep(t *testing.T) { double_loadable: true, } `) - // okay to link : double_loadable VNDK -> double_loadable VNDK private + // okay to link : double_loadable -> double_loadable testCc(t, ` cc_library { name: "libdoubleloadable", vendor_available: true, product_available: true, - vndk: { - enabled: true, - }, double_loadable: true, shared_libs: ["libnondoubleloadable"], } @@ -1171,10 +497,6 @@ func TestDoubleLoadbleDep(t *testing.T) { name: "libnondoubleloadable", vendor_available: true, product_available: true, - vndk: { - enabled: true, - private: true, - }, double_loadable: true, } `) @@ -1204,7 +526,7 @@ func TestDoubleLoadbleDep(t *testing.T) { func TestDoubleLoadableDepError(t *testing.T) { t.Parallel() - // Check whether an error is emitted when a LLNDK depends on a non-double_loadable VNDK lib. + // Check whether an error is emitted when a LLNDK depends on a non-double_loadable lib. testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", ` cc_library { name: "libllndk", @@ -1218,9 +540,6 @@ func TestDoubleLoadableDepError(t *testing.T) { name: "libnondoubleloadable", vendor_available: true, product_available: true, - vndk: { - enabled: true, - }, } `) @@ -1285,999 +604,13 @@ func TestDoubleLoadableDepError(t *testing.T) { `) } -func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) { - t.Parallel() - testCcError(t, "module \"libvndksp\" variant .*: .*: VNDK-SP must only depend on VNDK-SP", ` - cc_library { - name: "libvndksp", - shared_libs: ["libanothervndksp"], - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - } - } - - cc_library { - name: "libllndk", - shared_libs: ["libanothervndksp"], - } - - cc_library { - name: "libanothervndksp", - vendor_available: true, - product_available: true, - } - `) -} - -func TestVndkExt(t *testing.T) { - t.Parallel() - // This test checks the VNDK-Ext properties. - bp := ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - cc_library { - name: "libvndk2", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - target: { - vendor: { - suffix: "-suffix", - }, - product: { - suffix: "-suffix", - }, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - - cc_library { - name: "libvndk2_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk2", - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext_product", - product_specific: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - - cc_library { - name: "libvndk2_ext_product", - product_specific: true, - vndk: { - enabled: true, - extends: "libvndk2", - }, - nocrt: true, - } - ` - config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - - ctx := testCcWithConfig(t, config) - - checkVndkModule(t, ctx, "libvndk_ext", "vndk", false, "libvndk", vendorVariant) - checkVndkModule(t, ctx, "libvndk_ext_product", "vndk", false, "libvndk", productVariant) - - mod_vendor := ctx.ModuleForTests("libvndk2_ext", vendorVariant).Module().(*Module) - assertString(t, mod_vendor.outputFile.Path().Base(), "libvndk2-suffix.so") - - mod_product := ctx.ModuleForTests("libvndk2_ext_product", productVariant).Module().(*Module) - assertString(t, mod_product.outputFile.Path().Base(), "libvndk2-suffix.so") -} - -func TestVndkExtError(t *testing.T) { - t.Parallel() - // This test ensures an error is emitted in ill-formed vndk-ext definition. - testCcError(t, "must set `vendor: true` or `product_specific: true` to set `extends: \".*\"`", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - `) - - testCcError(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - `) - - testCcErrorProductVndk(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext_product", - product_specific: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - `) - - testCcErrorProductVndk(t, "must not set at the same time as `vndk: {extends: \"\\.\\.\\.\"}`", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext_product", - product_specific: true, - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - `) -} - -func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) { - t.Parallel() - // This test ensures an error is emitted for inconsistent support_system_process. - testCcError(t, "module \".*\" with mismatched support_system_process", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - support_system_process: true, - }, - nocrt: true, - } - `) - - testCcError(t, "module \".*\" with mismatched support_system_process", ` - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk_sp", - }, - nocrt: true, - } - `) -} - -func TestVndkExtVendorAvailableFalseError(t *testing.T) { - t.Parallel() - // This test ensures an error is emitted when a VNDK-Ext library extends a VNDK library - // with `private: true`. - testCcError(t, "`extends` refers module \".*\" which has `private: true`", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - private: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - `) - - testCcErrorProductVndk(t, "`extends` refers module \".*\" which has `private: true`", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - private: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext_product", - product_specific: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - `) -} - -func TestVendorModuleUseVndkExt(t *testing.T) { - t.Parallel() - // This test ensures a vendor module can depend on a VNDK-Ext library. - testCc(t, ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk_sp", - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvendor", - vendor: true, - shared_libs: ["libvndk_ext", "libvndk_sp_ext"], - nocrt: true, - } - `) -} - -func TestVndkExtUseVendorLib(t *testing.T) { - t.Parallel() - // This test ensures a VNDK-Ext library can depend on a vendor library. - testCc(t, ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - shared_libs: ["libvendor"], - nocrt: true, - } - - cc_library { - name: "libvendor", - vendor: true, - nocrt: true, - } - `) - - // This test ensures a VNDK-SP-Ext library can depend on a vendor library. - testCc(t, ` - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk_sp", - support_system_process: true, - }, - shared_libs: ["libvendor"], // Cause an error - nocrt: true, - } - - cc_library { - name: "libvendor", - vendor: true, - nocrt: true, - } - `) -} - -func TestProductVndkExtDependency(t *testing.T) { - t.Parallel() - bp := ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext_product", - product_specific: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - shared_libs: ["libproduct_for_vndklibs"], - nocrt: true, - } - - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_ext_product", - product_specific: true, - vndk: { - enabled: true, - extends: "libvndk_sp", - support_system_process: true, - }, - shared_libs: ["libproduct_for_vndklibs"], - nocrt: true, - } - - cc_library { - name: "libproduct", - product_specific: true, - shared_libs: ["libvndk_ext_product", "libvndk_sp_ext_product"], - nocrt: true, - } - - cc_library { - name: "libproduct_for_vndklibs", - product_specific: true, - nocrt: true, - } - ` - config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - - testCcWithConfig(t, config) -} - -func TestVndkSpExtUseVndkError(t *testing.T) { - t.Parallel() - // This test ensures an error is emitted if a VNDK-SP-Ext library depends on a VNDK - // library. - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk_sp", - support_system_process: true, - }, - shared_libs: ["libvndk"], // Cause an error - nocrt: true, - } - `) - - // This test ensures an error is emitted if a VNDK-SP-Ext library depends on a VNDK-Ext - // library. - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk_sp", - support_system_process: true, - }, - shared_libs: ["libvndk_ext"], // Cause an error - nocrt: true, - } - `) -} - -func TestVndkUseVndkExtError(t *testing.T) { - t.Parallel() - // This test ensures an error is emitted if a VNDK/VNDK-SP library depends on a - // VNDK-Ext/VNDK-SP-Ext library. - testCcError(t, "dependency \".*\" of \".*\" missing variant", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - - cc_library { - name: "libvndk2", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - shared_libs: ["libvndk_ext"], - nocrt: true, - } - `) - - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - nocrt: true, - } - - cc_library { - name: "libvndk2", - vendor_available: true, - vndk: { - enabled: true, - }, - target: { - vendor: { - shared_libs: ["libvndk_ext"], - }, - }, - nocrt: true, - } - `) - - testCcError(t, "dependency \".*\" of \".*\" missing variant", ` - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk_sp", - support_system_process: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_2", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - shared_libs: ["libvndk_sp_ext"], - nocrt: true, - } - `) - - testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp_ext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk_sp", - }, - nocrt: true, - } - - cc_library { - name: "libvndk_sp2", - vendor_available: true, - vndk: { - enabled: true, - }, - target: { - vendor: { - shared_libs: ["libvndk_sp_ext"], - }, - }, - nocrt: true, - } - `) -} - -func TestEnforceProductVndkVersion(t *testing.T) { - t.Parallel() - bp := ` - cc_library { - name: "libllndk", - llndk: { - symbol_file: "libllndk.map.txt", - } - } - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - nocrt: true, - } - cc_library { - name: "libvndk_sp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - nocrt: true, - } - cc_library { - name: "libva", - vendor_available: true, - nocrt: true, - } - cc_library { - name: "libpa", - product_available: true, - nocrt: true, - } - cc_library { - name: "libboth_available", - vendor_available: true, - product_available: true, - nocrt: true, - srcs: ["foo.c"], - target: { - vendor: { - suffix: "-vendor", - }, - product: { - suffix: "-product", - }, - } - } - cc_library { - name: "libproduct_va", - product_specific: true, - vendor_available: true, - nocrt: true, - } - cc_library { - name: "libprod", - product_specific: true, - shared_libs: [ - "libllndk", - "libvndk", - "libvndk_sp", - "libpa", - "libboth_available", - "libproduct_va", - ], - nocrt: true, - } - cc_library { - name: "libvendor", - vendor: true, - shared_libs: [ - "libllndk", - "libvndk", - "libvndk_sp", - "libva", - "libboth_available", - "libproduct_va", - ], - nocrt: true, - } - ` - - ctx := prepareForCcTest.RunTestWithBp(t, bp).TestContext - - checkVndkModule(t, ctx, "libvndk", "", false, "", productVariant) - checkVndkModule(t, ctx, "libvndk_sp", "", true, "", productVariant) - - mod_vendor := ctx.ModuleForTests("libboth_available", vendorVariant).Module().(*Module) - assertString(t, mod_vendor.outputFile.Path().Base(), "libboth_available-vendor.so") - - mod_product := ctx.ModuleForTests("libboth_available", productVariant).Module().(*Module) - assertString(t, mod_product.outputFile.Path().Base(), "libboth_available-product.so") - - ensureStringContains := func(t *testing.T, str string, substr string) { - t.Helper() - if !strings.Contains(str, substr) { - t.Errorf("%q is not found in %v", substr, str) - } - } - ensureStringNotContains := func(t *testing.T, str string, substr string) { - t.Helper() - if strings.Contains(str, substr) { - t.Errorf("%q is found in %v", substr, str) - } - } - - // _static variant is used since _shared reuses *.o from the static variant - vendor_static := ctx.ModuleForTests("libboth_available", strings.Replace(vendorVariant, "_shared", "_static", 1)) - product_static := ctx.ModuleForTests("libboth_available", strings.Replace(productVariant, "_shared", "_static", 1)) - - vendor_cflags := vendor_static.Rule("cc").Args["cFlags"] - ensureStringContains(t, vendor_cflags, "-D__ANDROID_VNDK__") - ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR__") - ensureStringNotContains(t, vendor_cflags, "-D__ANDROID_PRODUCT__") - ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR_API__=202404") - - product_cflags := product_static.Rule("cc").Args["cFlags"] - ensureStringContains(t, product_cflags, "-D__ANDROID_VNDK__") - ensureStringContains(t, product_cflags, "-D__ANDROID_PRODUCT__") - ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR__") - ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR_API__=202404") -} - -func TestEnforceProductVndkVersionErrors(t *testing.T) { - t.Parallel() - testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", ` - cc_library { - name: "libprod", - product_specific: true, - shared_libs: [ - "libvendor", - ], - nocrt: true, - } - cc_library { - name: "libvendor", - vendor: true, - nocrt: true, - } - `) - testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", ` - cc_library { - name: "libprod", - product_specific: true, - shared_libs: [ - "libsystem", - ], - nocrt: true, - } - cc_library { - name: "libsystem", - nocrt: true, - } - `) - testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", ` - cc_library { - name: "libprod", - product_specific: true, - shared_libs: [ - "libva", - ], - nocrt: true, - } - cc_library { - name: "libva", - vendor_available: true, - nocrt: true, - } - `) - testCcErrorProductVndk(t, "non-VNDK module should not link to \".*\" which has `private: true`", ` - cc_library { - name: "libprod", - product_specific: true, - shared_libs: [ - "libvndk_private", - ], - nocrt: true, - } - cc_library { - name: "libvndk_private", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - private: true, - }, - nocrt: true, - } - `) - testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", ` - cc_library { - name: "libprod", - product_specific: true, - shared_libs: [ - "libsystem_ext", - ], - nocrt: true, - } - cc_library { - name: "libsystem_ext", - system_ext_specific: true, - nocrt: true, - } - `) - testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:", ` - cc_library { - name: "libsystem", - shared_libs: [ - "libproduct_va", - ], - nocrt: true, - } - cc_library { - name: "libproduct_va", - product_specific: true, - vendor_available: true, - nocrt: true, - } - `) -} - func TestMakeLinkType(t *testing.T) { t.Parallel() bp := ` - cc_library { - name: "libvndk", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - }, - } - cc_library { - name: "libvndksp", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, - } - cc_library { - name: "libvndkprivate", - vendor_available: true, - product_available: true, - vndk: { - enabled: true, - private: true, - }, - } cc_library { name: "libvendor", vendor: true, } - cc_library { - name: "libvndkext", - vendor: true, - vndk: { - enabled: true, - extends: "libvndk", - }, - } vndk_prebuilt_shared { name: "prevndk", version: "27", @@ -2307,40 +640,15 @@ func TestMakeLinkType(t *testing.T) { private: true, } } - llndk_libraries_txt { name: "llndk.libraries.txt", } - vndkcore_libraries_txt { - name: "vndkcore.libraries.txt", - } - vndksp_libraries_txt { - name: "vndksp.libraries.txt", - } - vndkprivate_libraries_txt { - name: "vndkprivate.libraries.txt", - } - vndkcorevariant_libraries_txt { - name: "vndkcorevariant.libraries.txt", - insert_vndk_version: false, - } ` config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") // native:vndk ctx := testCcWithConfig(t, config) - checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", - []string{"libvndk.so", "libvndkprivate.so"}) - checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", - []string{"libc++.so", "libvndksp.so"}) - checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", - []string{"libc.so", "libdl.so", "libft2.so", "libllndk.so", "libllndkprivate.so", "libm.so"}) - checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", - []string{"libft2.so", "libllndkprivate.so", "libvndkprivate.so"}) - vendorVariant27 := "android_vendor.27_arm64_armv8-a_shared" tests := []struct { @@ -2348,15 +656,9 @@ func TestMakeLinkType(t *testing.T) { name string expected string }{ - {vendorVariant, "libvndk", "native:vndk"}, - {vendorVariant, "libvndksp", "native:vndk"}, - {vendorVariant, "libvndkprivate", "native:vndk_private"}, {vendorVariant, "libvendor", "native:vendor"}, - {vendorVariant, "libvndkext", "native:vendor"}, {vendorVariant, "libllndk", "native:vndk"}, {vendorVariant27, "prevndk.vndk.27.arm.binder32", "native:vndk"}, - {coreVariant, "libvndk", "native:platform"}, - {coreVariant, "libvndkprivate", "native:platform"}, {coreVariant, "libllndk", "native:platform"}, } for _, test := range tests { @@ -2674,18 +976,18 @@ func TestLlndkLibrary(t *testing.T) { `) actual := result.ModuleVariantsForTests("libllndk") for i := 0; i < len(actual); i++ { - if !strings.HasPrefix(actual[i], "android_vendor.29_") { + if !strings.HasPrefix(actual[i], "android_vendor_") { actual = append(actual[:i], actual[i+1:]...) i-- } } expected := []string{ - "android_vendor.29_arm64_armv8-a_shared", - "android_vendor.29_arm_armv7-a-neon_shared", + "android_vendor_arm64_armv8-a_shared", + "android_vendor_arm_armv7-a-neon_shared", } android.AssertArrayString(t, "variants for llndk stubs", expected, actual) - params := result.ModuleForTests("libllndk", "android_vendor.29_arm_armv7-a-neon_shared").Description("generate stub") + params := result.ModuleForTests("libllndk", "android_vendor_arm_armv7-a-neon_shared").Description("generate stub") android.AssertSame(t, "use Vendor API level for default stubs", "202404", params.Args["apiLevel"]) checkExportedIncludeDirs := func(module, variant string, expectedDirs ...string) { @@ -2697,11 +999,11 @@ func TestLlndkLibrary(t *testing.T) { } checkExportedIncludeDirs("libllndk", "android_arm64_armv8-a_shared", "include") - checkExportedIncludeDirs("libllndk", "android_vendor.29_arm64_armv8-a_shared", "include") + checkExportedIncludeDirs("libllndk", "android_vendor_arm64_armv8-a_shared", "include") checkExportedIncludeDirs("libllndk_with_external_headers", "android_arm64_armv8-a_shared", "include") - checkExportedIncludeDirs("libllndk_with_external_headers", "android_vendor.29_arm64_armv8-a_shared", "include_llndk") + checkExportedIncludeDirs("libllndk_with_external_headers", "android_vendor_arm64_armv8-a_shared", "include_llndk") checkExportedIncludeDirs("libllndk_with_override_headers", "android_arm64_armv8-a_shared", "include") - checkExportedIncludeDirs("libllndk_with_override_headers", "android_vendor.29_arm64_armv8-a_shared", "include_llndk") + checkExportedIncludeDirs("libllndk_with_override_headers", "android_vendor_arm64_armv8-a_shared", "include_llndk") } func TestLlndkHeaders(t *testing.T) { @@ -2733,7 +1035,7 @@ func TestLlndkHeaders(t *testing.T) { `) // _static variant is used since _shared reuses *.o from the static variant - cc := ctx.ModuleForTests("libvendor", "android_vendor.29_arm_armv7-a-neon_static").Rule("cc") + cc := ctx.ModuleForTests("libvendor", "android_vendor_arm_armv7-a-neon_static").Rule("cc") cflags := cc.Args["cFlags"] if !strings.Contains(cflags, "-Imy_include") { t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags) @@ -2855,7 +1157,7 @@ func TestRuntimeLibs(t *testing.T) { // runtime_libs for vendor variants have '.vendor' suffixes if the modules have both core // and vendor variants. - variant = "android_vendor.29_arm64_armv8-a_shared" + variant = "android_vendor_arm64_armv8-a_shared" module = ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module) checkRuntimeLibs(t, []string{"liball_available.vendor"}, module) @@ -2865,7 +1167,7 @@ func TestRuntimeLibs(t *testing.T) { // runtime_libs for product variants have '.product' suffixes if the modules have both core // and product variants. - variant = "android_product.29_arm64_armv8-a_shared" + variant = "android_product_arm64_armv8-a_shared" module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module) checkRuntimeLibs(t, []string{"liball_available.product"}, module) @@ -2882,7 +1184,7 @@ func TestExcludeRuntimeLibs(t *testing.T) { module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module) checkRuntimeLibs(t, []string{"liball_available"}, module) - variant = "android_vendor.29_arm64_armv8-a_shared" + variant = "android_vendor_arm64_armv8-a_shared" module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module) checkRuntimeLibs(t, nil, module) } @@ -3065,9 +1367,6 @@ func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) { ` config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) - config.TestProductVariables.DeviceVndkVersion = StringPtr("current") - config.TestProductVariables.Platform_vndk_version = StringPtr("29") - config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) ctx := testCcWithConfig(t, config) module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module() @@ -4795,8 +3094,7 @@ func TestStrippedAllOutputFile(t *testing.T) { } } -// TODO(b/316829758) Remove this test and do not set VNDK version from other tests -func TestImageVariantsWithoutVndk(t *testing.T) { +func TestImageVariants(t *testing.T) { t.Parallel() bp := ` @@ -4815,7 +3113,7 @@ func TestImageVariantsWithoutVndk(t *testing.T) { } ` - ctx := prepareForCcTestWithoutVndk.RunTestWithBp(t, bp) + ctx := prepareForCcTest.RunTestWithBp(t, bp) hasDep := func(m android.Module, wantDep android.Module) bool { t.Helper() @@ -4843,7 +3141,7 @@ func TestImageVariantsWithoutVndk(t *testing.T) { testDepWithVariant("product") } -func TestVendorSdkVersionWithoutVndk(t *testing.T) { +func TestVendorSdkVersion(t *testing.T) { t.Parallel() bp := ` @@ -4861,7 +3159,7 @@ func TestVendorSdkVersionWithoutVndk(t *testing.T) { } ` - ctx := prepareForCcTestWithoutVndk.RunTestWithBp(t, bp) + ctx := prepareForCcTest.RunTestWithBp(t, bp) testSdkVersionFlag := func(module, version string) { flags := ctx.ModuleForTests(module, "android_vendor_arm64_armv8-a_static").Rule("cc").Args["cFlags"] android.AssertStringDoesContain(t, "min sdk version", flags, "-target aarch64-linux-android"+version) @@ -4871,7 +3169,7 @@ func TestVendorSdkVersionWithoutVndk(t *testing.T) { testSdkVersionFlag("libbar", "29") ctx = android.GroupFixturePreparers( - prepareForCcTestWithoutVndk, + prepareForCcTest, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { if variables.BuildFlags == nil { variables.BuildFlags = make(map[string]string) diff --git a/cc/genrule_test.go b/cc/genrule_test.go index 08962065a..b3d511679 100644 --- a/cc/genrule_test.go +++ b/cc/genrule_test.go @@ -200,7 +200,7 @@ func TestVendorProductVariantGenrule(t *testing.T) { } ` t.Helper() - ctx := PrepareForTestWithCcIncludeVndk.RunTestWithBp(t, bp) + ctx := PrepareForIntegrationTestWithCc.RunTestWithBp(t, bp) variants := ctx.ModuleVariantsForTests("gen") if !slices.Contains(variants, "android_vendor_arm64_armv8-a") { diff --git a/cc/library_stub.go b/cc/library_stub.go index aab666408..cddb1b5e1 100644 --- a/cc/library_stub.go +++ b/cc/library_stub.go @@ -496,11 +496,10 @@ func (v *CcApiVariant) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) func (v *CcApiVariant) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool { return false } func (v *CcApiVariant) ExtraImageVariations(ctx android.BaseModuleContext) []string { var variations []string - platformVndkVersion := ctx.DeviceConfig().PlatformVndkVersion() if String(v.properties.Variant) == "llndk" { - variations = append(variations, VendorVariationPrefix+platformVndkVersion) - variations = append(variations, ProductVariationPrefix+platformVndkVersion) + variations = append(variations, VendorVariation) + variations = append(variations, ProductVariation) } return variations diff --git a/cc/library_stub_test.go b/cc/library_stub_test.go index 528577a21..4df0a4186 100644 --- a/cc/library_stub_test.go +++ b/cc/library_stub_test.go @@ -71,8 +71,8 @@ func TestApiLibraryReplacesExistingModule(t *testing.T) { android.AssertBoolEquals(t, "original library should be linked with non-stub variant", true, hasDirectDependency(t, ctx, libfoo, libbar)) android.AssertBoolEquals(t, "Stub library from API surface should be not linked with non-stub variant", false, hasDirectDependency(t, ctx, libfoo, libbarApiImport)) - libfooVendor := ctx.ModuleForTests("libfoo", "android_vendor.29_arm64_armv8-a_shared").Module() - libbarApiImportVendor := ctx.ModuleForTests("libbar.apiimport", "android_vendor.29_arm64_armv8-a_shared").Module() + libfooVendor := ctx.ModuleForTests("libfoo", "android_vendor_arm64_armv8-a_shared").Module() + libbarApiImportVendor := ctx.ModuleForTests("libbar.apiimport", "android_vendor_arm64_armv8-a_shared").Module() android.AssertBoolEquals(t, "original library should not be linked", false, hasDirectDependency(t, ctx, libfooVendor, libbar)) android.AssertBoolEquals(t, "Stub library from API surface should be linked", true, hasDirectDependency(t, ctx, libfooVendor, libbarApiImportVendor)) @@ -102,8 +102,8 @@ func TestApiLibraryDoNotRequireOriginalModule(t *testing.T) { ctx := prepareForCcTest.RunTestWithBp(t, bp) - libfoo := ctx.ModuleForTests("libfoo", "android_vendor.29_arm64_armv8-a_shared").Module() - libbarApiImport := ctx.ModuleForTests("libbar.apiimport", "android_vendor.29_arm64_armv8-a_shared").Module() + libfoo := ctx.ModuleForTests("libfoo", "android_vendor_arm64_armv8-a_shared").Module() + libbarApiImport := ctx.ModuleForTests("libbar.apiimport", "android_vendor_arm64_armv8-a_shared").Module() android.AssertBoolEquals(t, "Stub library from API surface should be linked", true, hasDirectDependency(t, ctx, libfoo, libbarApiImport)) } @@ -135,9 +135,9 @@ func TestApiLibraryShouldNotReplaceWithoutApiImport(t *testing.T) { ctx := prepareForCcTest.RunTestWithBp(t, bp) - libfoo := ctx.ModuleForTests("libfoo", "android_vendor.29_arm64_armv8-a_shared").Module() - libbar := ctx.ModuleForTests("libbar", "android_vendor.29_arm64_armv8-a_shared").Module() - libbarApiImport := ctx.ModuleForTests("libbar.apiimport", "android_vendor.29_arm64_armv8-a_shared").Module() + libfoo := ctx.ModuleForTests("libfoo", "android_vendor_arm64_armv8-a_shared").Module() + libbar := ctx.ModuleForTests("libbar", "android_vendor_arm64_armv8-a_shared").Module() + libbarApiImport := ctx.ModuleForTests("libbar.apiimport", "android_vendor_arm64_armv8-a_shared").Module() android.AssertBoolEquals(t, "original library should be linked", true, hasDirectDependency(t, ctx, libfoo, libbar)) android.AssertBoolEquals(t, "Stub library from API surface should not be linked", false, hasDirectDependency(t, ctx, libfoo, libbarApiImport)) @@ -174,13 +174,13 @@ func TestExportDirFromStubLibrary(t *testing.T) { } ` ctx := prepareForCcTest.RunTestWithBp(t, bp) - vendorCFlags := ctx.ModuleForTests("vendorbin", "android_vendor.29_arm64_armv8-a").Rule("cc").Args["cFlags"] + vendorCFlags := ctx.ModuleForTests("vendorbin", "android_vendor_arm64_armv8-a").Rule("cc").Args["cFlags"] android.AssertStringDoesContain(t, "Vendor binary should compile using headers provided by stub", vendorCFlags, "-Istub_include_dir") android.AssertStringDoesNotContain(t, "Vendor binary should not compile using headers of source", vendorCFlags, "-Isource_include_dir") android.AssertStringDoesContain(t, "Vendor binary should compile using system headers provided by stub", vendorCFlags, "-isystem stub_system_include_dir") android.AssertStringDoesNotContain(t, "Vendor binary should not compile using system headers of source", vendorCFlags, "-isystem source_system_include_dir") - vendorImplicits := ctx.ModuleForTests("vendorbin", "android_vendor.29_arm64_armv8-a").Rule("cc").OrderOnly.Strings() + vendorImplicits := ctx.ModuleForTests("vendorbin", "android_vendor_arm64_armv8-a").Rule("cc").OrderOnly.Strings() // Building the stub.so file first assembles its .h files in multi-tree out. // These header files are required for compiling the other API domain (vendor in this case) android.AssertStringListContains(t, "Vendor binary compilation should have an implicit dep on the stub .so file", vendorImplicits, "libfoo.so") @@ -223,17 +223,17 @@ func TestApiLibraryWithLlndkVariant(t *testing.T) { ctx := prepareForCcTest.RunTestWithBp(t, bp) - binfoo := ctx.ModuleForTests("binfoo", "android_vendor.29_arm64_armv8-a").Module() - libbarApiImport := ctx.ModuleForTests("libbar.apiimport", "android_vendor.29_arm64_armv8-a_shared").Module() - libbarApiVariant := ctx.ModuleForTests("libbar.llndk.apiimport", "android_vendor.29_arm64_armv8-a").Module() + binfoo := ctx.ModuleForTests("binfoo", "android_vendor_arm64_armv8-a").Module() + libbarApiImport := ctx.ModuleForTests("libbar.apiimport", "android_vendor_arm64_armv8-a_shared").Module() + libbarApiVariant := ctx.ModuleForTests("libbar.llndk.apiimport", "android_vendor_arm64_armv8-a").Module() android.AssertBoolEquals(t, "Stub library from API surface should be linked", true, hasDirectDependency(t, ctx, binfoo, libbarApiImport)) android.AssertBoolEquals(t, "Stub library variant from API surface should be linked", true, hasDirectDependency(t, ctx, libbarApiImport, libbarApiVariant)) - binFooLibFlags := ctx.ModuleForTests("binfoo", "android_vendor.29_arm64_armv8-a").Rule("ld").Args["libFlags"] + binFooLibFlags := ctx.ModuleForTests("binfoo", "android_vendor_arm64_armv8-a").Rule("ld").Args["libFlags"] android.AssertStringDoesContain(t, "Vendor binary should be linked with LLNDK variant source", binFooLibFlags, "libbar.llndk.apiimport.so") - binFooCFlags := ctx.ModuleForTests("binfoo", "android_vendor.29_arm64_armv8-a").Rule("cc").Args["cFlags"] + binFooCFlags := ctx.ModuleForTests("binfoo", "android_vendor_arm64_armv8-a").Rule("cc").Args["cFlags"] android.AssertStringDoesContain(t, "Vendor binary should include headers from the LLNDK variant source", binFooCFlags, "-Ilibbar_llndk_include") } @@ -446,12 +446,12 @@ func TestApiLibraryWithMultipleVariants(t *testing.T) { binfoo := ctx.ModuleForTests("binfoo", "android_arm64_armv8-a_sdk").Module() libbarApiImportv29 := ctx.ModuleForTests("libbar.apiimport", "android_arm64_armv8-a_sdk_shared_29").Module() - libbarApiImportLlndk := ctx.ModuleForTests("libbar.apiimport", "android_vendor.29_arm64_armv8-a_shared").Module() + libbarApiImportLlndk := ctx.ModuleForTests("libbar.apiimport", "android_vendor_arm64_armv8-a_shared").Module() android.AssertBoolEquals(t, "Binary using SDK should be linked with API library from NDK variant", true, hasDirectDependency(t, ctx, binfoo, libbarApiImportv29)) android.AssertBoolEquals(t, "Binary using SDK should not be linked with API library from LLNDK variant", false, hasDirectDependency(t, ctx, binfoo, libbarApiImportLlndk)) - binbaz := ctx.ModuleForTests("binbaz", "android_vendor.29_arm64_armv8-a").Module() + binbaz := ctx.ModuleForTests("binbaz", "android_vendor_arm64_armv8-a").Module() android.AssertBoolEquals(t, "Vendor binary should be linked with API library from LLNDK variant", true, hasDirectDependency(t, ctx, binbaz, libbarApiImportLlndk)) android.AssertBoolEquals(t, "Vendor binary should not be linked with API library from NDK variant", false, hasDirectDependency(t, ctx, binbaz, libbarApiImportv29)) diff --git a/cc/object_test.go b/cc/object_test.go index c0d133190..004dfd3e7 100644 --- a/cc/object_test.go +++ b/cc/object_test.go @@ -41,7 +41,7 @@ func TestMinSdkVersionsOfCrtObjects(t *testing.T) { {"android_arm64_armv8-a_sdk_29", "29"}, {"android_arm64_armv8-a_sdk_30", "30"}, {"android_arm64_armv8-a_sdk_current", "10000"}, - {"android_vendor.29_arm64_armv8-a", "29"}, + {"android_vendor_arm64_armv8-a", "10000"}, } ctx := prepareForCcTest.RunTestWithBp(t, bp) @@ -50,7 +50,7 @@ func TestMinSdkVersionsOfCrtObjects(t *testing.T) { expected := "-target aarch64-linux-android" + v.num + " " android.AssertStringDoesContain(t, "cflag", cflags, expected) } - ctx = prepareForCcTestWithoutVndk.RunTestWithBp(t, bp) + ctx = prepareForCcTest.RunTestWithBp(t, bp) android.AssertStringDoesContain(t, "cflag", ctx.ModuleForTests("crt_foo", "android_vendor_arm64_armv8-a").Rule("cc").Args["cFlags"], "-target aarch64-linux-android10000 ") diff --git a/cc/testing.go b/cc/testing.go index 9c2900cdd..3bdc3836f 100644 --- a/cc/testing.go +++ b/cc/testing.go @@ -305,10 +305,7 @@ func commonDefaultModules() string { recovery_available: true, host_supported: true, min_sdk_version: "29", - vndk: { - enabled: true, - support_system_process: true, - }, + double_loadable: true, apex_available: [ "//apex_available:platform", "//apex_available:anyapex", @@ -624,19 +621,6 @@ var PrepareForTestOnLinuxBionic = android.GroupFixturePreparers( android.FixtureOverrideTextFile(linuxBionicDefaultsPath, withLinuxBionic()), ) -// This adds some additional modules and singletons which might negatively impact the performance -// of tests so they are not included in the PrepareForIntegrationTestWithCc. -var PrepareForTestWithCcIncludeVndk = android.GroupFixturePreparers( - PrepareForIntegrationTestWithCc, - android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { - snapshot.VendorSnapshotImageSingleton.Init(ctx) - snapshot.RecoverySnapshotImageSingleton.Init(ctx) - RegisterVendorSnapshotModules(ctx) - RegisterRecoverySnapshotModules(ctx) - ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton) - }), -) - // PrepareForTestWithHostMusl sets the host configuration to musl libc instead of glibc. It also disables the test // on mac, which doesn't support musl libc, and adds musl modules. var PrepareForTestWithHostMusl = android.GroupFixturePreparers( @@ -722,7 +706,6 @@ func CreateTestContext(config android.Config) *android.TestContext { snapshot.RecoverySnapshotImageSingleton.Init(ctx) RegisterVendorSnapshotModules(ctx) RegisterRecoverySnapshotModules(ctx) - ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton) RegisterVndkLibraryTxtTypes(ctx) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) diff --git a/cc/vendor_public_library_test.go b/cc/vendor_public_library_test.go index 769be0973..7385f2b88 100644 --- a/cc/vendor_public_library_test.go +++ b/cc/vendor_public_library_test.go @@ -65,8 +65,8 @@ func TestVendorPublicLibraries(t *testing.T) { `) coreVariant := "android_arm64_armv8-a_shared" - vendorVariant := "android_vendor.29_arm64_armv8-a_shared" - productVariant := "android_product.29_arm64_armv8-a_shared" + vendorVariant := "android_vendor_arm64_armv8-a_shared" + productVariant := "android_product_arm64_armv8-a_shared" // test if header search paths are correctly added // _static variant is used since _shared reuses *.o from the static variant diff --git a/rust/testing.go b/rust/testing.go index d9cacdc27..986e34e29 100644 --- a/rust/testing.go +++ b/rust/testing.go @@ -47,7 +47,7 @@ var PrepareForIntegrationTestWithRust = android.GroupFixturePreparers( var PrepareForTestWithRustIncludeVndk = android.GroupFixturePreparers( PrepareForIntegrationTestWithRust, - cc.PrepareForTestWithCcIncludeVndk, + cc.PrepareForIntegrationTestWithCc, ) func GatherRequiredDepsForTest() string {