diff options
| author | 2024-11-08 18:22:15 +0000 | |
|---|---|---|
| committer | 2024-11-08 18:22:15 +0000 | |
| commit | 25fc1093717f8829a4a39ee1a596376b10d9ed6e (patch) | |
| tree | 0876e855315db34d85114471d44a0ee3c99fbc8d | |
| parent | 7ef7684d0c4468f8135aab064972fc482dc4bc16 (diff) | |
| parent | 3e85da88f56d0862ac817e7c72ec69451f4535ee (diff) | |
Merge "Remove magic implementation selection based on test_for" into main
| -rw-r--r-- | apex/apex_test.go | 190 | ||||
| -rw-r--r-- | cc/cc.go | 32 | ||||
| -rw-r--r-- | cc/cc_test.go | 105 |
3 files changed, 0 insertions, 327 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go index 54c1facd5..4e6aa1353 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -8713,196 +8713,6 @@ func TestApexPermittedPackagesRules(t *testing.T) { } } -func TestTestFor(t *testing.T) { - t.Parallel() - ctx := testApex(t, ` - apex { - name: "myapex", - key: "myapex.key", - native_shared_libs: ["mylib", "myprivlib"], - updatable: false, - } - - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_library { - name: "mylib", - srcs: ["mylib.cpp"], - system_shared_libs: [], - stl: "none", - stubs: { - versions: ["1"], - }, - apex_available: ["myapex"], - } - - cc_library { - name: "myprivlib", - srcs: ["mylib.cpp"], - system_shared_libs: [], - stl: "none", - apex_available: ["myapex"], - } - - - cc_test { - name: "mytest", - gtest: false, - srcs: ["mylib.cpp"], - system_shared_libs: [], - stl: "none", - shared_libs: ["mylib", "myprivlib", "mytestlib"], - test_for: ["myapex"] - } - - cc_library { - name: "mytestlib", - srcs: ["mylib.cpp"], - system_shared_libs: [], - shared_libs: ["mylib", "myprivlib"], - stl: "none", - test_for: ["myapex"], - } - - cc_benchmark { - name: "mybench", - srcs: ["mylib.cpp"], - system_shared_libs: [], - shared_libs: ["mylib", "myprivlib"], - stl: "none", - test_for: ["myapex"], - } - `) - - ensureLinkedLibIs := func(mod, variant, linkedLib, expectedVariant string) { - ldFlags := strings.Split(ctx.ModuleForTests(mod, variant).Rule("ld").Args["libFlags"], " ") - mylibLdFlags := android.FilterListPred(ldFlags, func(s string) bool { return strings.HasPrefix(s, linkedLib) }) - android.AssertArrayString(t, "unexpected "+linkedLib+" link library for "+mod, []string{linkedLib + expectedVariant}, mylibLdFlags) - } - - // These modules are tests for the apex, therefore are linked to the - // actual implementation of mylib instead of its stub. - ensureLinkedLibIs("mytest", "android_arm64_armv8-a", "out/soong/.intermediates/mylib/", "android_arm64_armv8-a_shared/mylib.so") - ensureLinkedLibIs("mytestlib", "android_arm64_armv8-a_shared", "out/soong/.intermediates/mylib/", "android_arm64_armv8-a_shared/mylib.so") - ensureLinkedLibIs("mybench", "android_arm64_armv8-a", "out/soong/.intermediates/mylib/", "android_arm64_armv8-a_shared/mylib.so") -} - -func TestIndirectTestFor(t *testing.T) { - t.Parallel() - ctx := testApex(t, ` - apex { - name: "myapex", - key: "myapex.key", - native_shared_libs: ["mylib", "myprivlib"], - updatable: false, - } - - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_library { - name: "mylib", - srcs: ["mylib.cpp"], - system_shared_libs: [], - stl: "none", - stubs: { - versions: ["1"], - }, - apex_available: ["myapex"], - } - - cc_library { - name: "myprivlib", - srcs: ["mylib.cpp"], - system_shared_libs: [], - stl: "none", - shared_libs: ["mylib"], - apex_available: ["myapex"], - } - - cc_library { - name: "mytestlib", - srcs: ["mylib.cpp"], - system_shared_libs: [], - shared_libs: ["myprivlib"], - stl: "none", - test_for: ["myapex"], - } - `) - - ensureLinkedLibIs := func(mod, variant, linkedLib, expectedVariant string) { - ldFlags := strings.Split(ctx.ModuleForTests(mod, variant).Rule("ld").Args["libFlags"], " ") - mylibLdFlags := android.FilterListPred(ldFlags, func(s string) bool { return strings.HasPrefix(s, linkedLib) }) - android.AssertArrayString(t, "unexpected "+linkedLib+" link library for "+mod, []string{linkedLib + expectedVariant}, mylibLdFlags) - } - - // The platform variant of mytestlib links to the platform variant of the - // internal myprivlib. - ensureLinkedLibIs("mytestlib", "android_arm64_armv8-a_shared", "out/soong/.intermediates/myprivlib/", "android_arm64_armv8-a_shared/myprivlib.so") - - // The platform variant of myprivlib links to the platform variant of mylib - // and bypasses its stubs. - ensureLinkedLibIs("myprivlib", "android_arm64_armv8-a_shared", "out/soong/.intermediates/mylib/", "android_arm64_armv8-a_shared/mylib.so") -} - -func TestTestForForLibInOtherApex(t *testing.T) { - t.Parallel() - // This case is only allowed for known overlapping APEXes, i.e. the ART APEXes. - _ = testApex(t, ` - apex { - name: "com.android.art", - key: "myapex.key", - native_shared_libs: ["libnativebridge"], - updatable: false, - } - - apex { - name: "com.android.art.debug", - key: "myapex.key", - native_shared_libs: ["libnativebridge", "libnativebrdige_test"], - updatable: false, - } - - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - cc_library { - name: "libnativebridge", - srcs: ["libnativebridge.cpp"], - system_shared_libs: [], - stl: "none", - stubs: { - versions: ["1"], - }, - apex_available: ["com.android.art", "com.android.art.debug"], - } - - cc_library { - name: "libnativebrdige_test", - srcs: ["mylib.cpp"], - system_shared_libs: [], - shared_libs: ["libnativebridge"], - stl: "none", - apex_available: ["com.android.art.debug"], - test_for: ["com.android.art"], - } - `, - android.MockFS{ - "system/sepolicy/apex/com.android.art-file_contexts": nil, - "system/sepolicy/apex/com.android.art.debug-file_contexts": nil, - }.AddToFixture()) -} - // TODO(jungjw): Move this to proptools func intPtr(i int) *int { return &i @@ -3360,10 +3360,6 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool { depName := ctx.OtherModuleName(dep) - thisModule, ok := ctx.Module().(android.ApexModule) - if !ok { - panic(fmt.Errorf("Not an APEX module: %q", ctx.ModuleName())) - } inVendorOrProduct := false bootstrap := false @@ -3393,34 +3389,6 @@ func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool { isNotInPlatform := dep.(android.ApexModule).NotInPlatform() useStubs = isNotInPlatform && !bootstrap - - if useStubs { - // Another exception: if this module is a test for an APEX, then - // it is linked with the non-stub variant of a module in the APEX - // as if this is part of the APEX. - testFor, _ := android.ModuleProvider(ctx, android.ApexTestForInfoProvider) - for _, apexContents := range testFor.ApexContents { - if apexContents.DirectlyInApex(depName) { - useStubs = false - break - } - } - } - if useStubs { - // Yet another exception: If this module and the dependency are - // available to the same APEXes then skip stubs between their - // platform variants. This complements the test_for case above, - // which avoids the stubs on a direct APEX library dependency, by - // avoiding stubs for indirect test dependencies as well. - // - // TODO(b/183882457): This doesn't work if the two libraries have - // only partially overlapping apex_available. For that test_for - // modules would need to be split into APEX variants and resolved - // separately for each APEX they have access to. - if android.AvailableToSameApexes(thisModule, dep.(android.ApexModule)) { - useStubs = false - } - } } else { // If building for APEX, use stubs when the parent is in any APEX that // the child is not in. diff --git a/cc/cc_test.go b/cc/cc_test.go index df239cbb5..bcf0a2c5d 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -1505,111 +1505,6 @@ func TestVersionedStubs(t *testing.T) { } } -func TestStubsForLibraryInMultipleApexes(t *testing.T) { - t.Parallel() - ctx := testCc(t, ` - cc_library_shared { - name: "libFoo", - srcs: ["foo.c"], - stubs: { - symbol_file: "foo.map.txt", - versions: ["current"], - }, - apex_available: ["bar", "a1"], - } - - cc_library_shared { - name: "libBar", - srcs: ["bar.c"], - shared_libs: ["libFoo"], - apex_available: ["a1"], - } - - cc_library_shared { - name: "libA1", - srcs: ["a1.c"], - shared_libs: ["libFoo"], - apex_available: ["a1"], - } - - cc_library_shared { - name: "libBarA1", - srcs: ["bara1.c"], - shared_libs: ["libFoo"], - apex_available: ["bar", "a1"], - } - - cc_library_shared { - name: "libAnyApex", - srcs: ["anyApex.c"], - shared_libs: ["libFoo"], - apex_available: ["//apex_available:anyapex"], - } - - cc_library_shared { - name: "libBaz", - srcs: ["baz.c"], - shared_libs: ["libFoo"], - apex_available: ["baz"], - } - - cc_library_shared { - name: "libQux", - srcs: ["qux.c"], - shared_libs: ["libFoo"], - apex_available: ["qux", "bar"], - }`) - - variants := ctx.ModuleVariantsForTests("libFoo") - expectedVariants := []string{ - "android_arm64_armv8-a_shared", - "android_arm64_armv8-a_shared_current", - "android_arm_armv7-a-neon_shared", - "android_arm_armv7-a-neon_shared_current", - } - variantsMismatch := false - if len(variants) != len(expectedVariants) { - variantsMismatch = true - } else { - for _, v := range expectedVariants { - if !inList(v, variants) { - variantsMismatch = false - } - } - } - if variantsMismatch { - t.Errorf("variants of libFoo expected:\n") - for _, v := range expectedVariants { - t.Errorf("%q\n", v) - } - t.Errorf(", but got:\n") - for _, v := range variants { - t.Errorf("%q\n", v) - } - } - - linkAgainstFoo := []string{"libBarA1"} - linkAgainstFooStubs := []string{"libBar", "libA1", "libBaz", "libQux", "libAnyApex"} - - libFooPath := "libFoo/android_arm64_armv8-a_shared/libFoo.so" - for _, lib := range linkAgainstFoo { - libLinkRule := ctx.ModuleForTests(lib, "android_arm64_armv8-a_shared").Rule("ld") - libFlags := libLinkRule.Args["libFlags"] - if !strings.Contains(libFlags, libFooPath) { - t.Errorf("%q: %q is not found in %q", lib, libFooPath, libFlags) - } - } - - libFooStubPath := "libFoo/android_arm64_armv8-a_shared_current/libFoo.so" - for _, lib := range linkAgainstFooStubs { - libLinkRule := ctx.ModuleForTests(lib, "android_arm64_armv8-a_shared").Rule("ld") - libFlags := libLinkRule.Args["libFlags"] - if !strings.Contains(libFlags, libFooStubPath) { - t.Errorf("%q: %q is not found in %q", lib, libFooStubPath, libFlags) - } - } -} - func TestVersioningMacro(t *testing.T) { t.Parallel() for _, tc := range []struct{ moduleName, expected string }{ |