summaryrefslogtreecommitdiff
path: root/java/bootclasspath_fragment_test.go
AgeCommit message (Collapse)Author
2025-02-12Don't panic in ModuleForTests and friends Colin Cross
Panicking in ModuleForTests and similar test helper functions was a mistake. Go's test runner stops running tests as soon as any test panics, which means debugging multiple tests panicking requires rerunning all the tests after fixing each panic to find the next one. Pass the *testing.T into ModuleForTests and friends so that it can call t.Fatalf instead. Test: all soong tests pass Change-Id: I5d0f2424eaf04fb795079e6d1e4b9469d8c7033c
2025-01-31Add t.Parallel() to java tests Colin Cross
Speeds up go test ./java from 32 seconds to 9 seconds. Test: go test ./java Change-Id: I4c6640e787c0744c6dfda03b7382839b452e24cf
2024-11-11Make Contents and Standalone_contents configurable Spandan Das
For use in Android.bp select statements Test: m nothing --no-skip-soong-tests Bug: 373868171 Change-Id: I2ca90dd1289c4cf7f728a00db93d08516856fdfa
2024-08-12Merge SingletonProviderContext with OtherModuleProviderContext Yu Liu
Bug: 358425833 Test: CI Change-Id: I8e3f40dc3cfc5337008b419801f8e6bf2d48e8b2
2024-08-09Add PrepareForTestWithBuildFlag Colin Cross
Add a helper function that creates a test fixture preparer that sets a build flag, and use it everywhere that was setting build flags manually. Test: all soong tests Flag: EXEMPT refactor Change-Id: I68d50d68787a30d091f0827e8caa51f5c5a762ef
2024-01-23Make hiddenAPIFlagFileCategory an int Cole Faust
hiddenAPIFlagFileCategory used to contain function pointers, and is used in a provider. Providers must be serializable for incremental soong support, so the function pointers must be removed. Refactor hiddenAPIFlagFileCategory into a simple int. Bug: 322069292 Test: m nothing --no-skip-soong-tests Change-Id: I2bd50fa1b59979f30869b405314cbef16ee345f1
2024-01-12Enable hiddenapi check for exportable stubs Jihoon Kang
This change modifies the dependencies of the hiddenapi to always depend on the exportable stubs, instead of the currently utilized everything stubs. To support this, the full api surface exportable stubs are defined in a separate change at the `frameworks/base` project. Note that the full api surface exportable stubs are only used for the hiddenapi purpose, and `sdk_version` continues to utilize the currently existing everything stubs. Currently, this feature is hidden behind the build flag "RELEASE_HIDDEN_API_EXPORTABLE_STUBS". This feature will be fully enabled once metalava fully supports handling of the flagged apis. Test: ENABLE_HIDDENAPI_FLAGS=true m Bug: 317426356 Change-Id: I109b7cd27b20ceffcdf1766ab8106b0c276be2b3
2023-12-14Convert ModuleProvder to generic providers API Colin Cross
Convert all of the callers of ModuleProvider/ModuleHasProvider to use the type-safe android.SingletonModuleProvider API. Bug: 316410648 Test: builds Change-Id: I6f11638546b64749e451cebbf33140248dc1d193
2023-10-11Utilize module lib and test api superset module in hiddenapi Jihoon Kang
Hiddenapi takes a single widest api scope stub dex jar as an input, as the tool does not support handling duplicate classes passed as inputs. A problem regarding this is that the test and module lib api surfaces do not strictly have a subset/superset relationship, unlike other api surfaces. This has not become a problem for stubs generated from source files as the stubs contain all methods in the source files, but became a problem for stubs genereated from text files as the stubs only contain the methods that are essential for compilation of the stubs and its reverse dependencies, and there were cases where the hiddenapi flags are not properly propagated to the subclasses. To resolve this problem, a java_api_library module that provides the union of the test and the module lib api surfaces was introcudes. Since hiddenapi_modular currently defines the module lib api surface to be a wider api scope over the test api scope, the new module can be passed as input to hiddenapi over the module lib non updatable stub module to resolve the problem. Test: enable hiddenapi for from-text stub build && ENABLE_HIDDENAPI_FLAGS=true m --build-from-text-stub Bug: 191644675 Bug: 275570206 Change-Id: I9a230ec5082c52ed866f29b0748814f2cf10279b
2023-07-11Fix some tests for dexpreopt and remove unnecessary tests. Jiakai Zhang
This CL is to prepare for the changes in http://r.android.com/2652081. See the description of that CL for the reasons. Some tests were set up in a fragile way and were easy to be broken when the implementation changes. This CL is a pure test change that fixes them. This CL also removes TestNoUpdatableJarsInBootImage. That test checks what should go to the ART boot image and what should go to the platform one, which does not apply today because boot images are not associated with mainline modules anymore: a boot image may take jars from multiple mainline modules and the platform, and a mainline module can contribute to multiple boot images. In practice, we have ART jars in the platform boot image, and we are going to add core-icu4j and consrypt to the ART boot image, which is now for testing only. Bug: 290583827 Test: m nothing Change-Id: I22c45cbf6f853b030b68edb51197854e9c53a02e
2023-06-15Cleanup remaining android.JavaApiLibraryName() references Jihoon Kang
Since the name of the java_library generated from sdk_library per api scope does not depend on the build configuration anymore, all dependency switching "magic" via android.JavaApiLibraryName() can be removed. This change also removes from-text-build-specific test cases, as those test cases depend on build configurations. Test: m nothing && m nothing --build-from-text-stub Bug: 287340610 Change-Id: I3bac35259e0cbaa16432a46cb2b128951c9bc075
2023-05-22Fix bootclasspath_fragment build failure during from-text stub build Jihoon Kang
This change enables bootclasspath_fragment module to be correctly built during from-text stub build by android-non-updatable module to be interpreted as its java_api_library equivalent. Test: go test ./java Bug: 279460171 Change-Id: Ia6b60edcb60782977cc59855f1cf5d3a46e9f682
2022-09-16Merge "Revert "bootclasspath_fragment: Treat some specific modules as test"" Treehugger Robot
2022-09-14Revert "bootclasspath_fragment: Treat some specific modules as test" Paul Duffin
This reverts commit ff9b6faba2b9a949289c70657db87c0b1790cc07. Reason for revert: No longer needed Bug: 194063708 Test: m nothing Change-Id: Ic2f6761c9a0a00a612724cb429f002a16522e53f
2022-09-09add jacocoagent by default to Java modules Sam Delmerico
On coverage builds, R8 will fail to properly optimize and fail the build if ignore_warnings: false, because jacoco injects dependencies on jacocoagent classes, but the jacocoagent library is not part of the classpath libraries passed in to R8 in its arguments. Instead we can add jacocoagent as a libs dependency for these modules so that it will get pulled into the r8 flags. Bug: 243903417 Test: m Change-Id: Icc24cc260b896fc800125a0318308d823ccf7a83
2022-08-31jacoco libs dependency for instrumented libraries Sam Delmerico
On coverage builds, R8 will fail to properly optimize and fail the build if ignore_warnings: false, because jacoco injects dependencies on jacocoagent classes, but the jacocoagent library is not part of the classpath libraries passed in to R8 in its arguments. Instead we can add jacocoagent as a libs dependency for these modules so that it will get pulled into the r8 flags. Bug: 243903417 Test: add optimize.ignore_warnings: false to NetworkStackAppDefaults && make SKIP_ABI_CHECKS=true PRODUCT=cf_x86_phone-userdebug \ EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true \ CLANG_COVERAGE=true COVERAGE_PATHS="" \ TARGET_USERDATAIMAGE_PARTITION_SIZE=17179869184 \ SKIP_BOOT_JARS_CHECK=true \ NetworkStack Change-Id: I71313b1fd35437ec52890f5c30b3fd1381c7c3d2
2022-08-19Add hidden API properties to java_sdk_library modules Paul Duffin
Previously, hidden API properties were only allowed on bootclasspath_fragment and platform_bootclasspath module types. This change allows them to be specified on java_sdk_library modules too. It involves the following changes: 1. Add the properties to the java.Module. 2. Populate and provide a HiddenAPIPropertyInfo struct from java_sdk_library modules. 3. Modify bootclasspath_fragment to merge information gathered from its content libraries as if it was specified on the fragment itself. Bug: 240406019 Test: m nothing packages/modules/common/build/mainline_modules_sdks.sh # Ran the previous command with and without this change to make # sure that this change does not change the sdk snapshot # contents. Change-Id: I64eb71c2039ddc14cf380689d0cec7ec221f5b88
2022-05-27bootclasspath_fragment: Require at least one hidden_api package property Paul Duffin
Previously, the split_packages, single_packages and package_prefixes properties were all optional and the split_packages defaulted to ["*"]. As that value conflicted with the other package properties that meant that split_packages always had to be specified even if it was to just set it to an empty array. This change requires at least one of them to be specified and defaults split_packages to an empty list which means it is not required, although it can be helpful to make that explicit. Bug: 194063708 Test: m nothing Change-Id: I5a4c2d68e72e39f5c4a2441326dfce8685fc8ff2
2022-05-27bootclasspath_fragment: Treat some specific modules as test Paul Duffin
Treats bootclasspath_fragment modules that have not yet been converted to test modules as if they were test modules. This is a temporary work around to ease the migration to bootclasspath_fragment_test modules and is expected to be reverted. Bug: 194063708 Test: m nothing Change-Id: I093fbec4e926719b644c64ebfc63f9e3070e28db
2022-05-27bootclasspath_fragment: Add test specific module type Paul Duffin
This is needed to allow the behavior of the bootclasspath_fragment to be tweaked for test fragments. Bug: 194063708 Test: m nothing Change-Id: Iee5c09d5b580d088ba081d95a788dbde883078ed
2021-08-10Fix tests to use correct fixtures for configuring (Apex)BootJars. satayev
This is in preparation to r.android.com/1740313 where setting correct variables would be enforced (i.e. apex and non-apex boot jars must be in config.ApexBootJars and config.BootJars correspondingly). Bug: 191369843 Test: m nothing Change-Id: Ic86680c1f7af53d229083b2cc58beb3ceccb4b6a
2021-06-30Support using java_sdk_library components in stub_libs Paul Duffin
Previously, if a bootclasspath_fragment had both a java_sdk_library module and one of its components in stub_libs properties they would be treated as separate modules instead of simply different APIs from the same module. That would result in them both providing stub dex jars to "hiddenapi list" which would fail because it found duplicate definitions of the same class. e.g. Specifying something like this: api: { stub_libs: [ "art.module.public.api", ], }, core_platform_api: { stub_libs: [ "art.module.public.api.stubs.module_lib", ], }, would cause "hiddenapi list" to fail because it would have been passed paths to two dex jars (actually the same dex jar but that does not matter) each of which defined the same class, e.g. java.lang.Object. This change treats the "art.module.public.api.stubs.module_lib" and "art.module.public.api" modules as being the same for the purposes of hidden API processing. Bug: 192446466 Test: m nothing Change-Id: I9de96337f64f26e24cff040d4bbed9eecc67b1ed
2021-06-28Calculate widest stub dex jars per module Paul Duffin
Previously, the stub dex jars for each HiddenAPIScope was created by merging the stub dex jars provided by each module for that scope. Then the widest stub dex jars were chosen. So, if module A provided public, system and test stub dex jars and module B provided only public then the stub dex jars for each scope would be: * public -> A,B * system -> A * test -> A So, the widest API scope for which there are stub dex jars is "test" and so the widest stub dex jars would just come from module A and not module B. So, when "hiddenapi list" is run for module C which depends on modules A and B it only gets given stub dex jars for module A which means that it cannot resolve all the types that C may use which can lead to incorrect flags being generated. This change does not merge the stub dex jars from each module together and instead keeps them separate by module. The widest stub dex jars list is constructed by asking each module in turn for their widest stub dex jars. e.g. Given the above example we would have: Module A: * public * system * test <- widest Module B: * public <- widest So, the widest stub dex jars will be A's test and B's public stub dex jars. Bug: 179354495 Test: m out/soong/hiddenapi-flags.csv - make sure that this does not change the file. Change-Id: Ib137825ebffe94b2bf220732bae6077f7b7ac6db
2021-06-27Add test to show issues with widest stub dex jars Paul Duffin
The widest stub dex jars should include the widest stub dex jars provided by each module. So, if module A has public, system and test and module B has only public then the widest stub dex jars should include module A's test and module B's public stub dex jars. Instead, they just include module A's test. That behaviour is needed so that when the "hiddenapi list" tool is run against a module C that it is passed stub dex jars from both module A and module B so that any references to the types provided by those APIs can be resolved. A follow up change will fix this issue. Bug: 179354495 Test: m nothing Change-Id: Ibd31964e8d2a33fa92fbd0b800c9fe054ee359c7
2021-06-24Add HiddenAPIScope to replace use of SdkKind Paul Duffin
Previously, the hidden API processing used SdkKind to identify the API scopes, e.g. public, system, etc. that are of interest for hidden API processing. Unfortunately, there is a mismatch between the SdkKind and what hidden API processing needs. e.g. SdkKind includes values that are not used by hidden API processing and hidden API processing needs additional API scope specific information not provided by SdkKind. The apiScope struct used in sdk_library.go is also not a suitable representation for similar reasons. This change adds the HiddenAPIScope (following a similar approach as apiScope) that rectifies that and uses it as a replacement for SdkKind in most parts of the hidden API processing. The SdkKind is still used for retrieving information from java_sdk_library[_import] modules. Follow up changes will extend the HiddenAPIScope with more information. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv - make sure that this change has no effect on the generated flags. Change-Id: I97968f58535121652852b8d25217aa288afd2bfd
2021-05-24Tighten bootclasspath_fragment property validation Paul Duffin
Previously, due to legacy reasons, the property validation did not require a contents property and allowed the image_name to be either "art" or "boot". Those reasons no longer apply and so this change requires a contents property and only allows the image_name to be set to "art" if specified. Bug: 177892522 Test: m nothing Change-Id: I8855d6e5365ef0b55490e90e7b6c0081cf070ee5
2021-05-24Support hidden API processing for fragments with dependencies Paul Duffin
Previously, a bootclasspath_fragment that depended on classes provided by another bootclasspath_fragment did not support hidden API processing as it would not supply information about those dependencies. This change adds support for that as follows. Each fragment: 1. Exports the transitive sets of stub dex jars for each of the public, system, test and core_platform APIs (where relevant). 2. Adds dependencies onto its dependent fragments. 3. Retrieves the API stubs dex jars from its dependent fragments and passes them to the "hiddenapi list" tool which will use them to resolve dependencies but will not output them to the generated flags. Once the flags are generated the existing encoding functionality encodes the flags into the dex files of the bootclasspath_fragment's content modules which are then packaged into the apex. Bug: 179354495 Test: m com.android.sdkext - verify that this does not change the contents of the apex files Change-Id: I3e82a6dbb437f1e417e5d7e25aeb212e378603d0
2021-05-24Remove bootclasspathApiInfo Paul Duffin
Previously, the bootclasspathApiInfo was only used for tests and follow up changes will need to provide the stub dex jars. This change moves the stubJarsByKind into HiddenAPIInfo and removes bootclasspathApiInfo and the corresponding provider. Bug: 179354495 Test: m nothing Change-Id: I5459c56de561c053ed671dc9d5cb3ee4820c0ee8
2021-05-14Use java_sdk_library in bootclasspath_fragment contents as stubs Paul Duffin
A java_sdk_library specified in the bootclasspath_fragment contents must be providing APIs for the bootclasspath_fragment and so must be treated as if they were specified in the stub_libs. This avoids having to specify them in both contents and stub_libs. Bug: 179354495 Test: m nothing Change-Id: I535065ee1a79b439e2676f35e06a75d4626adcaf
2021-05-14Disallow shared libraries in bootclasspath_fragment contents Paul Duffin
Bug: 177892522 Test: m nothing Change-Id: I78c8ef8664ec1eb0fe3456a2de2cb956162ca0da
2021-04-28Add stub_libs properties to bootclasspath_fragment snapshot Paul Duffin
Bug: 177892522 Test: m nothing Change-Id: I7644122c4abed8e8bc2cc7b58f408bee3bdc91f6
2021-04-28Add support for specifying api provided by bootclasspath_fragment Paul Duffin
The hidden API processing needs access to dex stub jars for the API scopes provided by the bootclasspath_fragment so that it can mark the corresponding dex members as being part of that API. This change adds the ability to specify the modules that provide those jars, resolve the modules to dex jar stubs and make them available for other modules and tests to use. While the stubs are only needed for hidden API at the moment these were not added to the hidden_api properties section as there are other parts of the build that may need to access the stubs in future, e.g. api fingerprint and aidl generation. The stubs properties can be affected by coverage as when coverage is enabled the jacoco-stubs needs adding to the list, just like how jacocoagent is added to the contents. Bug: 177892522 Test: m nothing Change-Id: I31097d1ca45c84adeba4cbb38f693698cb289e99
2021-04-26Allow contents and image_name to be specified together Paul Duffin
Previously, only one of the contents or image_name properties could be specified at once which meant that there was no way to create a prebuilt which lists its fixed contents while at the same time allowing it to check that that the contents matched what the build configuration required. e.g. a prebuilt_bootclasspath_fragment that had image_name: "art", could not list its contents and also check that those contents matched the ART_APEX_JARS which the build configuration required. This change allows contents and image_name to be specified together and adds a check to make sure that the contents are consistent with the configuration appropriate to the image_name. The check is only performed for modules that are active so that a prebuilt_bootclasspath_fragment which was created without coverage enabled (the default) would not cause a build failure in a coverage build unless it was preferred. Bug: 177892522 Test: m nothing Change-Id: Ie601f29f707b3f6030fa7d252afa2c4826cc9f8e
2021-04-26Add coverage specific properties to bootclasspath_fragment Paul Duffin
This allows a bootclasspath_fragment (specifically the art-bootclasspath-fragment) to specify additional contents to be appended when coverage is enabled. The art-bootclasspath-fragment will use this to add jacocoagent to its contents to ensure that it is always consistent with the configuration. Bug: 177892522 Test: m nothing Change-Id: I50d05fe5e0e9b8c14bdf3dfd63bba0ac97e31d48
2021-04-23Rename BootImageModule to BootclasspathFragmentModule Paul Duffin
Also renames files, tests, module types in a similar fashion. There are still some references to image and boot image. They are kept for the following reasons: * image_name - this is the name of an ART boot image, i.e. the collection of .art/.oat/.vdex files. * BootImageInfo - again this is related to the ART boot image. * .../art_boot_images/... paths - ditto. Bug: 177892522 Test: m nothing Change-Id: Ie1f4738061d131fee75de48bc26a7601481bad4d