aboutsummaryrefslogtreecommitdiff
path: root/java/hiddenapi_singleton_test.go
Commit message (Collapse)AuthorAgeFilesLines
* Enable hiddenapi check for exportable stubsJihoon Kang2024-01-121-5/+8
| | | | | | | | | | | | | | | | | | | | 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
* Replace panic with ModuleErrorfSpandan Das2024-01-091-1/+2
| | | | | | | | | | | | | | | | | | This is a followup cleanup for aosp/2876754 and replaces panic with ctx.ModuleErrorf. The latter creates a more expressive build error. Implementation details - export moduleErrorf interface from build/soong/android. This minimal interface will be used as a parameter for `DexJarBuildPath` - Add ModuleErrorf to the function signature of DexJarBuildPath. This parameter only gets used for Import and SdkLibraryImport structs. These two can have duplicate deapexer definitions, and ModuleErrorf will be used to report that error - Create a minimal implementation of `ModuleErrorf` in tests of java and apex Test: m nothing --no-skip-soong-tests Change-Id: I0febec651f40c3f04deb957e64133c94b80fbd78
* Prepare tests for dexpreopt changes.Jiakai Zhang2023-05-111-1/+3
| | | | | | | | | | | | After this change, there is a clear separation between tests that are related to dexpreopt and tests that are not. The former uses PrepareForTestWithDexpreopt, while the latter uses PrepareForTestWithJavaDefaultModules. The benefit is that the latter will no longer affected by any dexpreopt changes. Bug: 280776428 Test: m nothing Change-Id: Ib957765b9287d51c082e0a33cee17a6bb56daeef
* Propagate the dex jar path as an OptionalPath which is either valid orMartin Stjernholm2021-09-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | invalid with a message. This will allow propagating any error from the deapexer module for prebuilt APEXes to the location where the dex jars get used. It's only at those points that we can raise errors about not being able to extract files from the deapexer modules if they are invalid, and this way we avoid encoding knowledge there about why they may be invalid. To keep the refactoring limited it intentionally does not change any of the existing logic for when dexJarFiles are set or not (non-nil vs nil prior to this change), although there may be opportunity to use this for more conditions when dex jars aren't available. The refactoring is also not extended to dexpreopt.ClassLoaderContextMap. Test: m nothing Bug: 192006406 Change-Id: I68986dccd9a9b3fee4d24caa1947ea17a36caedc
* Add a test for hidden API encoding of java_sdk_libraryPaul Duffin2021-05-171-0/+53
| | | | | | | | | | | | Fill a hole in the testing of hidden API encoding. Some comments in the code indicate that the child implementation java_library of a java_sdk_library should have hidden API flags encoded in its dex jar just like the embedded java_library. However, this test proves that it is not working. This will be fixed in a follow up change. Bug: 179354495 Test: m nothing Change-Id: Ia581a17f1e48dff252d17f16bf76adf039f46b60
* Refactor special handling of hidden API encoding for master-artPaul Duffin2021-05-141-4/+1
| | | | | | | | | | | | | Instead of encoding the hidden API with an empty set of flags when the monolithic flags are not available this simply disables encoding altogether which should have the same behavior at runtime. This change also removes the unused flags field in hiddenAPISingleton which was set but never read. Bug: 179354495 Test: m nothing Change-Id: I32d5825e5271829993dd4e5be4d4ee1b22fa7b22
* Move monolithic stub flags generation to platform_bootclasspathPaul Duffin2021-04-221-10/+24
| | | | | | | | | | | | | | | | As part of that this change: * Moves code that will be common to platform_bootclasspath and bootclasspath_fragment from hiddenapi_singleton.go into hiddenapi_modular.go. * Fixes the tests in hiddenapi_singleton_test.go but intentionally does not rename them or move them into a more appropriate place so as to make it easier to see the differences. A TODO has been added and these will be cleaned up in a follow up change. Bug: 179354495 Test: verified that the monolithic out/soong/hiddenapi/... files are unchanged by this change Change-Id: I680e4dab2e6bdf4a655fa9f255c195175904667e
* Move hidden API index file rule to platform_bootclasspathPaul Duffin2021-04-141-55/+0
| | | | | | | | | | | | This change moves the monolithic hidden API index file creation rule from the hiddenAPIIndexSingleton into the platform_bootclasspath. It also moves the corresponding test from java/hiddenapi_singleton_test.go to java/platform_bootclasspath_test.go. Bug: 179354495 Test: verified that the out/soong/hiddenapi/... files are unchanged by this change Change-Id: Ia295d0f7ae9b51ea816f16921aa42339ed91704e
* Improve realism of boot jar testsPaul Duffin2021-04-131-13/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Boot jars, updatable boot jars and art apex jars are part of two separate but related configuration objects, the main Config struct (actually the nested productVariables struct) and the dexpreopt specific GlobalConfig. The fields in both are initialized from the same data in the make config files but handled separately. Previously each test that used one of the configuration objects would generally just initialize the one it used. That would make the test sensitive to the specific configuration object that was used. A refactoring that change the code from using one configuration object to the other would cause the test to fail. Also, some tests would inadvertently create invalid configurations by setting ArtApexJars without also setting BootJars. While the ability to create invalid configurations is useful (and there are some tests that exist to verify the behavior in that case) most tests should not be using them. This change simplifies the configuration of the tests and improves their realism by: 1. Providing a new FixtureConfigureBootJars method that takes a set of boot jars and sets ArtApexJars, and BootJars in the dexpreopt.GlobalConfig and BootJars in the product variables too. 2. Providing a new FixtureConfigureUpdatableBootJars method that takes a set of boot jars and sets UpdatableBootJars in both the dexpreopt.GlobalConfig and productVariables. 3. Migrating existing tests to use these new methods. Some tests still use the dexpreopt.FixtureSet...Jars() methods directly, generally to create invalid configurations. Bug: 177892522 Test: m nothing Change-Id: I4d8f0b9762cfcc7ae6383bef08563d7c3fa13955
* Remove FixturePreparer.Extend()Paul Duffin2021-04-011-8/+16
| | | | | | | | Use GroupFixturePreparers instead. Bug: 182885307 Test: m nothing Change-Id: Idc01d3cc5a57576a4cf417e9105d1ab851126e10
* Remove extraneous calls to TestingBuildParams.RelativeToTop()Paul Duffin2021-03-301-6/+6
| | | | | | | | Deprecated the method to try and prevent any other uses being added. Bug: 183650682 Test: m nothing Change-Id: Ia6f43851e5a00c9d96af780e3bd21e03175e1a2f
* Remove javaFixtureFactoryPaul Duffin2021-03-241-1/+2
| | | | | | | | | Replaces uses of javaFixtureFactory with prepareForJavaTest and removes the unused javaFixtureFactory. Bug: 182885307 Test: m nothing Change-Id: I809772d14af2af211b9e15ad676fbdc06b07cd46
* Remove uses of buildDir in java/hiddenapi_singleton_test.goPaul Duffin2021-03-241-17/+17
| | | | | | | | | | Remove any uses, either direct (or indirect via testJavaConfig or similar methods), of the package level buildDir variable from this file. Bug: 182885307 Test: m nothing Change-Id: I664465808cd4edf1fef611c07ae05a32683dc976
* Fix hiddenapi tests to work without javaMockFS()Paul Duffin2021-03-161-0/+8
| | | | | | Bug: 182638834 Test: m nothing Change-Id: I32e0173f3c2e97b6d6d831c6cfa51cc500f8d2b1
* Convert hiddenapi tests to use test fixturesPaul Duffin2021-03-161-107/+77
| | | | | | | | | | These tests rely on files provided by javaMockFS() so have been converted to test fixtures to allow them to remove that dependency which will allow javaMockFS() to be removed. Bug: 182638834 Test: m nothing Change-Id: Ifd4069a74fcf67e555f998ddbc4de3fde26b2aae
* Avoid hiddenapi ignoring prebuilt with missing dex implementation jarPaul Duffin2021-03-011-0/+23
| | | | | | | | | | | | | | | Previously, when a prebuilt was preferred but did not provide a suitable boot dex jar both the source and the prebuilt were silently ignored which meant that the "hiddenapi list" command was not given a complete set of boot dex jars. That could either lead to incorrect hiddenapi flags being set or the "hiddenapi list" command failing if it could not find a class. Debugging the cause of either of those cases can be very time consuming so this change fails early and makes the cause very explicit. Bug: 181267622 Test: m nothing Change-Id: I6763ddb9ba90ed2e501d0cf7984f6655237e905d
* Remove implicit dependency from <x> -> <x>-hiddenapiPaul Duffin2021-02-161-7/+0
| | | | | | | | | | It can be removed as all implicit dependencies have been replaced with explicit ones so it is no longer needed. Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Change-Id: I3da5fcb3b244a295502f2cacc94a504250d4d616
* Allow explicitly specified additional annotations for hiddenapiPaul Duffin2021-02-161-0/+19
| | | | | | | | | | | | | | | | Adds the hiddenapi_additional_annotations to allow a library to list the libraries that provided additional hiddenapi related annotations for a library. Modifies merge_csv.py so it can process multiple zip files at the same time and uses that to merge the embedded .uau files from a module and those it depends upon. Bug: 180102243 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Change-Id: I796520021c7357398a9e2a09f1029e4a578b05b3
* Ensure that <x>-hiddenapi modules are included in hiddenapi-index.csvPaul Duffin2021-02-111-0/+7
| | | | | | | | | | Adds a test that makes sure that <x>-hiddenapi modules that provide additional annotations for the <x> boot jar module are included when generating the hiddenapi-index.csv file. Bug: 178361284 Test: m nothing Change-Id: I866916c9275af17954e0634347d183228d4ddc17
* Refactor the hiddenAPI() method for reusabilityPaul Duffin2021-02-081-9/+1
| | | | | | | | | | | | | | A follow up change needs to be able to contribute to the information the hiddenapi process collates without having a dex file encoded. This change pushes all the functionality related to information gathering into the hiddenAPIGenerateCSV() method and then renames it and the hiddenAPI() method to make it clearer what they do. Bug: 178361284 Test: m droid Verified that hiddenapi files (both aggregated ones and for the individual modules) are not affected by this change. Change-Id: I04417720216a0fbadcd88e6185e7de6570af6216
* Remove duplicate entries from hiddenapi filesPaul Duffin2021-02-071-2/+0
| | | | | | | | | | | | Prevents the hiddenapi files index and metadata files from including duplicate entries. Bug: 178361284 Test: m droid Compared hiddenapi files before and after change Verified that the only differences were due to the removal of duplicates Used sort -u to remove duplicates from before file and compared with after file Change-Id: I0b9e420aec42cdcf4584099a7ffd2ed9c3715d6d
* Add test for hiddenAPI index file generationPaul Duffin2021-02-071-7/+49
| | | | | | | | | | | | | | | | | | The index file and the metadata file both currently include duplicate entries due to them including both the <x> and <x>.impl libraries created by java_sdk_library in their inputs, plus including both source and prebuilt versions of the same named module. This change adds a test to illustrate that behavior. A follow up change will correct the problem and update the test accordingly. This change only adds a test for the index file because the metadata file depends on files from frameworks/base which makes it difficult to test. Bug 177317659 will fix that and allow the metadata file generation to be tested too. Bug: 178361284 Test: m nothing Change-Id: I33921d7267c9f4bb42726343d73f8a396d536aaa
* Detect empty apex in ConfiguredJarListPaul Duffin2021-02-041-5/+5
| | | | | | | | | | | | | | | | Previously, ConfiguredJarList would accept an empty apex name, e.g. ":jar" which makes no sense as every apex has to have a non-empty name. This change makes an empty apex invalid. In order to improve the test coverage of the TestConfiguredJarList test this change also changes the implementation of CreateTestConfiguredJarList([]string) to marshal the supplied strings into a json list and then unmarshal into a ConfiguredJarList which more closely matches how it is used at runtime. Bug: 178361284 Test: m nothing Change-Id: I7dfec6b4cc1923aa99746e976da0393922ef0791
* Enable prebuilt hiddenapi CSV files.Bill Peckham2021-01-191-7/+53
| | | | | | | | | | | | | | By enabling these hiddenapi CSV files to be prebuilt, it becomes possible to create a split build that supports the hiddenapi encode dex step, but doesn't contain all of the java sources needed to generate the CSV files. Bug: 175048716 Test: m nothing Test: new TestHiddenAPISingletonWithPrebuiltCsvFile Test: local build without prebuilt hiddenapi Test: local build with prebuilt hiddenapi Change-Id: I805ea3ec05860d2df211a3985ec025bf36f0d775
* Automatically set uncompress_dex for java_import.Bill Peckham2020-12-231-1/+1
| | | | | | | | | | | Setting uncompress_dex for java_import in the same way as java_library enables using a java_import as an art jar or a boot jar. Bug: 175619567 Test: m nothing Test: TestHiddenAPISingletonWithPrebuilt Change-Id: I0b552a11d1630a014cf978520ccc5977fdf74066
* Pass Config to NewTestContext instead of ctx.RegisterColin Cross2020-11-121-3/+3
| | | | | | | | | | | Prepare for using Config when adding singletons by passing Config to NewTestContext and NewContext instead of to ctx.Register. This will enable a followup change to store SingletonMakeVarsProviders registered on the Context in the Config, which is necessary to run multiple tests in parallel without data races. Test: all soong tests Change-Id: Id229629a4e42ff4487d317241673837726c075fc
* Cleanup usages of CreateConfiguredJarListPaul Duffin2020-10-271-1/+1
| | | | | | | | | | | | After previous refactorings the CreateConfiguredJarList function is now only used in tests and are supplied with a PathContext that will cause ReportPathErrorf() to panic. So, this change removes the ctx parameter, calls panic directly on any error and renames the method to make it clear that it is for testing only. Bug: 171479578 Test: m nothing Change-Id: Icfb4bdfe720afa855b64ecf0e74a0b030882d029
* Switch BootJars/UpdatableBootJars to ConfiguredJarListPaul Duffin2020-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | This change: * Switches BootJars/UpdatableBootJars fields of config.productVariables from []string to ConfiguredJarList. * Updates BootJars() method to simply concatenate the jars list from the BootJars/UpdatableBootJars fields. * Adds an UnmarshalJSON(..) method to ConfiguredJarList to support unmarshalling from a single string array to avoid having to change the format of the JSON file from which the configuration is loaded. * Adds some additional calls to ConfiguredJarList(..) in tests to convert from []string to ConfiguredJarList. They pass nil as the ctx argument as there is no suitable PathContext which will cause any errors to be thrown using panic. That is reasonable for hard coded values in tests. A follow up change will clean up the calls to ConfiguredJarList(..). Bug: 171479578 Test: m nothing Change-Id: I59b94dafb479ccd8f0471ed802be175af57be271
* Revert "Make lots of tests run in parallel"Colin Cross2020-10-091-5/+0
| | | | | | | | | | This reverts commit 323dc60712491c71ccdc5363c42df61f0a192487. Reason for revert: Possible cause of test instability Bug: 170513220 Test: soong tests Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
* Make lots of tests run in parallelColin Cross2020-10-061-0/+5
| | | | | | | | | | Putting t.Parallel() in each test makes them run in parallel. Additional t.Parallel() could be added to each subtest, although that requires making a local copy of the loop variable for table driven tests. Test: m checkbuild Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
* Make hiddenapi use prebuilt stubs when it shouldAnton Hansson2020-09-181-7/+90
| | | | | | | Bug: 160455085 Test: build_unbundled_mainline_module.sh (with disabled source-stubs) Test: hiddenapi_singleton_test.go Change-Id: Id93c974351b3f8efdf8e4efe4192d3809f4fcaa5
* Add hidden_api for java_importLiz Kammer2020-09-101-0/+136
Test: go java tests Test: m Bug: 160455085 Change-Id: Ib6e826e32ca73ceea0799b26145ad06b1e62a1bf