summaryrefslogtreecommitdiff
path: root/sdk/sdk_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-02-06Add t.Parallel() to SDK tests Colin Cross
Reduces time to run go test ./sdk from 44 seconds to 22.5 seconds. Requires moving snapshotTestCustomizations from a map to a struct with individual fields to avoid concurrent map accesses between subtests. Test: go test ./sdk Change-Id: Id6f451ba9cbace8bc7ea915033a795456b85cf3f
2024-09-11Remove `prebuilt_visibility` from `sdk` Spandan Das
This property was introduced for inter module dependencies in the prebuilt module sdk. https://r.android.com/3252814 changed the visibilty of all prebuilts in module sdk to //visibility:public. This property is a noop now, and can be removed. Test: go test ./sdk Bug: 365111645 Change-Id: I186a201895fc2b33a65bbedae8a8326e087feb2b
2024-09-04Change visibility of module sdk prebuilts to //visibility:public Spandan Das
To reduce pains introduced by visiblity skew between source and prebuilts, mark them with //visibility:public Bug: 239189932 Test: go test ./sdk Change-Id: I47dd63bd03337bc9ec6fa364bbdcdfdfcd70b0d9
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-06-10Remove exportable modules when generating snapshots targeting older platform Jihoon Kang
This change modifies the contents of the generated Android.bp files so that when generating a snapshot on a older platform, the "exportable" modules are removed from the bp files, as the "exportable" modules are first introduced in V and do not exist in older platforms. Bug: 345162614 Test: ABTD Change-Id: I2dba51b98deec7805bd796647a66981f237c55a9
2024-03-20Add an apex_contributions_defaults module to module sdk Spandan Das
This metadata module will contain a flattened list of all the soong modules contributed by this module to the rest of the build. This is supported in V and above. Bug: 326246905 Test: m art-module-host-exports Test: unzip -p out/soong/mainline-sdks/art-module-host-exports-current.zip Android.bp | grep -A 15 apex_contributions_defaults apex_contributions_defaults { name: "art-module-host-exports.contributions", contents: [ "prebuilt_art.module.api.annotations", "prebuilt_dex2oat", "prebuilt_dex2oatd", "prebuilt_dexdump", "prebuilt_hiddenapi", "prebuilt_oatdump", "prebuilt_profman", "prebuilt_veridex", "prebuilt_libartpalette", "prebuilt_libartbase", ], } Change-Id: Iba43a9da5430adfc0a5fd9b5dc27b5d89c5eacb8
2024-01-12Copy exportable artifacts to module sdk snapshot Jihoon Kang
This change modifies the copy rules of the sdk_library when generating the module sdk snapshots so that the exportable artifacts (annotations zip, api file, removed api file, srcjar file) are copied instead of the everything artifacts. In order to satisfy the prebuilts compatibility, this feature is flag guarded by the build flag "RELEASE_HIDDEN_API_EXPORTABLE_STUBS" Test: m --no-skip-soong-tests Bug: 315027929 Change-Id: I8bf5bb1f196aa9b5db78ba4677caa5f4337e3021
2024-01-08Generate "exportable" stubs in droidstubs Jihoon Kang
This change generates rules for "exportable" stubs in the droidstubs module. Given that there are a lot of overlap between the currently existing "everything" stubs rule and the newly introducing "exportable" stubs rule, the currently existing metalava rule commands are modularized to be utilized in the "exportable" stubs rule commands. The currently existing build actions are modularized in the followings: - commonMetalavaStubCmd(...): metalava commands that are required for generation of both "everything", "exportable", and potentially "runtime" stubs - everythingOptionalCmd(...): metalava commands that are dependent on "everything" stubs and not dependent on flagged apis annotations, such as api lint, released api check Based on this modularization, the "everything" stubs are now generated in everythingStubCmd(...), which calls commonMetalavaStubCmd(...) and everythingOptionalCmd(...). Similarly, the "exportable" stubs are generated in optionalStubCmd(stubsType=Exportable, ...), which calls commonMetalavaStubCmd(...) and appends additional flags. Runtime stubs can be generated similarly in the future with optionalStubCmd(stubsType=Runtime, ...). "everything"-related artifacts will now be created in `everything/` subdirectory, and "exportable"-related artifacts will be created in `exportable/` subdirectory. For example, the outdir of a droidstubs module "foo" would look like below: ``` foo |-- everything | |-- foo_api.txt | |-- foo-stubs.srcjar | |-- exportable |-- foo_api.txt |-- foo-stubs.srcjar ``` The module generates the build rules for the "exportable" stubs regardless of whether the module defines the `aconfig_declarations` property or not. All APIs marked with `@FlaggedApis` annotations are stripped out for the "exportable" stubs when the `aconfig_declarations` property is not defined. On the other hand, only the `@FlaggedApis` that are specified in the aconfig_declarations module and are enabled will be included (and all others are stripped) when the `aconfig_declarations` propety is defined. Test: go test ./java && BUILD_FROM_SOURCE_STUBS=true m Bug: 315490657 Change-Id: I300273cd2a62fa978b046c0268e3a67c35e22b08
2023-06-15Dynamically link static libs for sdk_library created java_library Jihoon Kang
Rename java_library created inside sdk_library with the ".from-source" suffix, and set it as static lib of the top level java_library, which gets java_api_library instead as static lib during from-text stub build. Test: m nothing && m nothing --build-from-text-stub Bug: 286446015 Change-Id: I32e8ea264987e9f9df05e462292bd54e45074912
2022-11-14Remove support for unused env vars from sdk snapshot generation Paul Duffin
The following environment variables are no longer used when generating sdk snapshots: * SOONG_SDK_SNAPSHOT_PREFER - we can control the modules that are preferred at build time now. * SOONG_SDK_SNAPSHOT_USE_SOURCE_CONFIG_VAR - this is done as a post-processing step by the mainline_module_sdks.sh script to avoid having to regenerate the ninja files for every module. * SOONG_SDK_SNAPSHOT_VERSION - support for this was removed a long time ago but was still referenced from dumpvars.go. Bug: 259095197 Test: m nothing # Searched for uses of these variables but could not find any # outside the build. Change-Id: Id2b32b29ff6f09faffea43292f549ba13acd956d
2022-09-26Add sdk:"keep" tag support Paul Duffin
Fields tagged with `sdk:"keep"` will keep the value even if it would normally be cleared because it was common across a number of structs. This will allow a module type to specify the same value across all structs populated directly from variants and have it be copied into all common property structs without clearing it from the variant specific structs. Bug: 248258460 Test: m nothing Change-Id: I147d946b11fd8766a7d875d9206e8f5034f585d6
2022-09-26Rename sdk field tag "keep" to "ignore" Paul Duffin
"ignore" is a better description of the effect that this tag has on the optimization that is done as part of the sdk snapshot generation. "keep" implies that something special is done with the field during the optimization process but actually the optimization process completely ignores the property, just as it does with unexported fields. Bug: 248258460 Test: m nothing Change-Id: Idfdfd87f927d641d4d301cbbde72b463c89155bf
2022-09-14Exclude unsupported libraries from sdk snapshot Paul Duffin
When an sdk snapshot is targeted at release X then it cannot include bootclasspath fragment libraries which are not present in that build as otherwise it causes build failures. It should also not include any unsupported libraries, i.e. libraries that cannot work on that release. This change causes sdk snapshot to exclude libraries that have a min_sdk_version > target build release It also ensures that hidden API flags do not include any information from excluded libraries. Bug: 240406019 Test: BUILD_NUMBER=fixed packages/modules/common/build/mainline_modules_sdks.sh # Ran the previous command with and without this change to make # sure that this change excludes framework-connectivity-t library from the # tethering sdk snapshot for S, including from the hidden API flag files. Change-Id: I57969b85a12e9e5a3fc76c055b260cec5d5f7d7f
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-24Remove support for generating versioned snapshots Paul Duffin
Previously, the code for selecting specific versions of sdk snapshots was removed (along with the uses_sdks property). That makes versioned snapshots useless so this change removes all the code and tests that generated those versioned snapshots. Bug: 232546567 Test: m nothing packages/modules/common/build/mainline_modules_sdks.sh Change-Id: Ib6d1b72bc8399fbb39075494ae37da92f4b28d03
2022-05-06For each sdk built generate a JSON file describing its contents Paul Duffin
Some build scripts need to know information about the contents of an sdk, such as what APIs it provides (via java_sdk_library). Rather than duplicate that information in the scripts or attempt to access that information (where available) by looking at the contents of the snapshot this change generates a JSON file that sits alongside the snapshot itself. The info file can be generated without generating the snapshot zip file but whenever a snapshot zip file is generated the info is generated too. The info file sits alongside the zip file in out/mainline-sdks. Bug: 204763318 Test: m art-module-sdk m dist Change-Id: I289530bb21693dc6443826c24c17c9b5d85d2d8b
2022-04-21Remove unused uses_sdks property for apexes Liz Kammer
Test: m nothing & compare build.ninja before/after Change-Id: I3f1199af338e1d2e48ec29cf9f59b6b36236c4cc
2021-10-05Retry: Separate hidden API flags needed in sdk snapshots for S and T Paul Duffin
Previous change that was reverted: https://r.android.com/1835222 An additional test was added that revealed a bug in the previous change which has been fixed here. Previously, the behavior of the stub_flags and all_flags properties was different between S and T. In S they contained paths for the complete set of stub flags and all the encoded flags. However, in T they contained filtered sets of flags which if used in S would prevent build checks from detecting possible inconsistencies. Also, a new signature_patterns property was added in T that is not supported in S. This change creates separate properties/files for T and reverts the behavior of the properties/files that were added in S back to how they behaved in S. The new properties are called filtered_stub_flags and filtered_flags. The S and T properties are tagged with the appropriate supported_build_releases tag to ensure that they are only output when specifically targeted. Bug: 197842263 Test: m nothing Change-Id: I1ce0a3d6623dabf73e32af1a7457b9b444fc3b7c
2021-10-04Retry: Support generating sdk snapshot for specific build release Paul Duffin
This was reverted unnecessarily along with the change that actually broke the build. Previously, the sdk snapshot was assumed to be generated for the current build system. This change adds support for the SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE environment variable which can be used to select the target build release in which the generated snapshot will be used. At the moment this will only affect the properties that are output but if/when it becomes necessary it can also be used to control more aspects of the snapshots such as supported member types or even members. This change does not modify any properties that are build release specific. That will come in following changes. However, it does add a test that targets build release S which defines a baseline for properties that will be affected in following changes. That baseline makes it easier to see the effect of those follow up changes. Bug: 197842263 Test: m nothing Change-Id: If4b452237f105382550d2842c8010249afbc7432
2021-10-04Revert "Support generating sdk snapshot for specific build release" Salmax Chang
This reverts commit ef2df587be53a1a58fc35f195a4226170df17dbb. Reason for revert: suspect to cause build break in b/201948713 Change-Id: If46219746913bec87ca2030ba51a6094246a0211
2021-10-04Revert "Separate hidden API flags needed in sdk snapshots for S and T" Salmax Chang
This reverts commit ba68c936305eeec354ad62192173a147eb3e6348. Reason for revert: suspect to cause build break in b/201948713 Change-Id: Ide3693ac1f8e24bd2f7c12857361885cb6b787ef
2021-10-01Separate hidden API flags needed in sdk snapshots for S and T Paul Duffin
Previously, the behavior of the stub_flags and all_flags properties was different between S and T. In S they contained paths for the complete set of stub flags and all the encoded flags. However, in T they contained filtered sets of flags which if used in S would prevent build checks from detecting possible inconsistencies. Also, a new signature_patterns property was added in T that is not supported in S. This change creates separate properties/files for T and reverts the behavior of the properties/files that were added in S back to how they behaved in S. The new properties are called filtered_stub_flags and filtered_flags. The S and T properties are tagged with the appropriate supported_build_releases tag to ensure that they are only output when specifically targeted. Bug: 197842263 Test: m nothing Change-Id: Iec8b9c539796c507245b69c0aed980fde6d8694f
2021-10-01Support generating sdk snapshot for specific build release Paul Duffin
Previously, the sdk snapshot was assumed to be generated for the current build system. This change adds support for the SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE environment variable which can be used to select the target build release in which the generated snapshot will be used. At the moment this will only affect the properties that are output but if/when it becomes necessary it can also be used to control more aspects of the snapshots such as supported member types or even members. This change does not modify any properties that are build release specific. That will come in following changes. However, it does add a test that targets build release S which defines a baseline for properties that will be affected in following changes. That baseline makes it easier to see the effect of those follow up changes. Bug: 197842263 Test: m nothing Change-Id: I5cfde5e9e86af522b0d5030d301e116b0233fd62
2021-07-20Replace android.BuildOs with Config.BuildOS Colin Cross
Replace the android.BuildOs constant with Config.BuildOS so that it can vary based on the product config. Bug: 190084016 Test: all Soong tests Change-Id: Ia67f872d8b2ab788747a22e3a9659dc21c9775cd
2021-07-14Support generating sdk snapshots that can be selected by Soong config vars Paul Duffin
Allows the builder of an sdk snapshot to specify a Soong config variable that can be used to control whether the snapshot's prebuilts are used or not. Bug: 193523070 Test: m nothing Change-Id: Ib09500ba61befc1202dff61dc06847c730ba9253
2021-07-07Revert "Flag to control if generated SDK prebuilts are preferred." Mathew Inwood
This reverts commit d0b99cea0ac389e831dfddbd3cb10fa09a040d2c. Reason for revert: Not needed anymore. We will simple exclude the gernated Android.bp files from prebuilt drops instead, it keeps things simpler. Change-Id: I5b01b2e01197f9fceb4630c8ade95f0d1d0f33f4
2021-06-29Flag to control if generated SDK prebuilts are preferred. Mathew Inwood
This is needed because: - the SDK prebuilt drop is being automated, including the Android.bp - We want to control the prefer flag on a per-module level It augments the existing SOONG_SDK_SNAPSHOT_PREFER which now overrides this new flag when set to true. Bug: 188427719 Test: m nothing Change-Id: Ieb5ab9fab53a34c615345b7a9d19cadf713eec26
2021-05-12Add SOONG_SDK_SNAPSHOT_VERSION support Paul Duffin
SOONG_SDK_SNAPSHOT_VERSION=current will generate unversioned and versioned prebuilts and a versioned snapshot module. This is the default behavior. The zip file containing the generated snapshot will be <sdk name>-current.zip. SOONG_SDK_SNAPSHOT_VERSION=unversioned will generate unversioned prebuilts only and the zip file containing the generated snapshot will be <sdk name>.zip. SOONG_SDK_SNAPSHOT_VERSION=<number> will generate versioned prebuilts and a versioned snapshot module only. The zip file containing the generated snapshot will be <sdk name>-<number>.zip. Bug: 157884619 Test: m nothing m SOONG_SDK_SNAPSHOT_VERSION=current art-module-sdk - check that the generated Android.bp file has not changed from the default. m SOONG_SDK_SNAPSHOT_VERSION=none art-module-sdk - check that the generated Android.bp file does not contain versioned modules. m SOONG_SDK_SNAPSHOT_VERSION=2 art-module-sdk - check that the generated Android.bp file only contains version 2 of each module. Change-Id: I087e9d7d3ad110508a3d6a39bca50cbb46b3ce82
2021-05-07Add SOONG_SDK_SNAPSHOT_PREFER support Paul Duffin
By default the generated snapshot has prefer: false. Building it with SOONG_SDK_SNAPSHOT_PREFER=true will force it to generate prefer: true. Bug: 157884619 Test: m nothing m SOONG_SDK_SNAPSHOT_PREFER=true art-module-sdk - check the generated Android.bp file to make sure it contains prefer: true Change-Id: Ied297b32d9bd4822a140fa99016f38e234c50f64
2021-05-06Add baseline test for sdk snapshot env variables Paul Duffin
Bug: 157884619 Test: m nothing Change-Id: I56c14ddfec1c33b60fe70f56e4d59b90639657fe
2021-03-18Migrate sdk package to a per test build directory Paul Duffin
Bug: 182885307 Test: m nothing Change-Id: I051f2572ce5e94e2a3a66cf7663797178b7d1506
2021-03-13Stop sdk package depending on testing.T being embedded in TestResult Paul Duffin
This change is in preparation for removing testing.T from TestResult. Bug: 181070625 Test: m nothing Change-Id: I67535aff0d894e6e3d8456b75540f340af853355
2021-03-11Switch CheckSnapshot from a testSdkResult method to a function Paul Duffin
This will allow the testSdkResult to be replaced with the TestResult when switching sdk package to use test fixtures. Bug: 181070625 Test: m nothing Change-Id: Ieca63f4c189f5e804102aeb4073289ea03143b6e
2021-03-10Merge "Remove duplicate sdk.TestHelper" Paul Duffin
2021-03-10Remove duplicate sdk.TestHelper Paul Duffin
As part of the work on the new fixture mechanism some of the TestHelper functionality was moved into the android/fixture.go package. This moves the rest and removes the now duplicated TestHelper from the sdk package. Also removed some unnecessary & operators. Bug: 181070625 Test: m nothing Change-Id: Ia09a5d05e4fab3a4e28cf44b2d947a33541e3925
2021-03-09Simplify TestSdkInstall Paul Duffin
Test: m nothing Change-Id: Iff59c8c331402b8d53323072213579ed9956cd90
2020-11-04Always set apex_available in SDK snapshots. Martin Stjernholm
Also fix //apex_available:platform that could get lost in the generated apex_available properties. It only happened if a module didn't specify an apex_available setting and then got extra entries from apex.BaselineApexAvailable. Test: Build ART SDK with libnativeloader_lazy in the SDK, and check that the generated prebuilt module has //apex_available:platform (before https://r.android.com/1480559). Change-Id: I9df20aee63455932a7e558993f0f26769cb02792
2020-10-09Revert "Make lots of tests run in parallel" Colin Cross
This reverts commit 323dc60712491c71ccdc5363c42df61f0a192487. Reason for revert: Possible cause of test instability Bug: 170513220 Test: soong tests Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
2020-10-06Make lots of tests run in parallel Colin Cross
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
2020-10-02Add prebuilt_visibility property Paul Duffin
Some mainline modules provide an `sdk` and one or more set of module_exports. When the snapshots are unpacked into separate prebuilts directories (one per snapshot) then any dependencies from a member of one snapshot to a member of another may require the latter to have additional visibility rules. Previously, these rules had to be added to each source module. This change allows additional visibility rules to be specified on the sdk/module_exports that are added to all the prebuilts in its snapshot. Bug: 155921753 Bug: 168301990 Test: m nothing Change-Id: Ia3eacb5749981f04770ae9872a8013e43c5c6ef1
2020-07-15Disable all SDK snapshot generation tests on mac. Martin Stjernholm
We frequently miss putting in the per-test skip condition, and since mac isn't tested in presubmit this leads to build breakages and time consuming reverts. To avoid that this blanket disables all the SDK tests on mac. It's not used there and we got test coverage in many linux-based builds. Bug: 145598135 Bug: 161315642 Test: `go test -v ./sdk` in build/soong on mac and linux Change-Id: I2aea92fef2c0f8c2742396fe36610501dc5a6f0f
2020-05-14Fix special case when appending a visibility rule to //visibility:private. Martin Stjernholm
Test: m nothing Bug: 151303681 Change-Id: Ibe7e953219e4660c653063e87cb08407a2cb513d
2020-05-14Add explicit visibility on the self package in EffectiveVisibilityRules. Martin Stjernholm
Modules in a package is implicitly visible within the same package. When making effective visibility rules which work from another location that visibility needs to be mentioned explicitly. In practice this allows prebuilts to remain visible to other modules in the source package when the prebuilts are preferred. Test: m nothing Test: m conscrypt-module-sdk, check that the snapshot Soong modules give visibility to //external/conscrypt Bug: 151303681 Change-Id: I404f6e5ca7021974a8c7be5e4d6b4982c050b8a5
2020-05-14Don't print :__pkg__ for package rules, since that's the default. Martin Stjernholm
To reduce clutter a little. Test: m nothing Change-Id: I0d2d86f00c3d38e603d6f58c4b1dd9a4170bf819
2020-05-08Retry: Adds support for 'ignored-on-host' Paul Duffin
Adds a filter mechanism that can exclude property values from being included in the common value extraction. That is needed to prevent the snapshot mechanism from generating invalid output for properties that are ignored on host (and have their values cleared) and which are not tagged with `android:"arch_variant"`. Changes: * Updates the documentation of SdkMemberType to explain what effect the 'ignored-on-host' tag has. * Adds some tests for this new mechanism. Bug: 155628860 Test: m nothing Change-Id: Ibafdb6e921ba5abe505bd8a91ca5a1d9c9b5d0cb
2020-05-08Retry: Detect invalid arch specific properties in snapshot Paul Duffin
Previously, the snapshot code did not know whether a specific property could be arch specific or not and assumed that they all were which meant that it could generate snapshots containing arch specific values for properties that are not arch specific and so would fail when unpacked. This change requires arch specific fields in SdkMemberProperties to be tagged as such using `android:"arch_variant"` (just as in module input property structures). Any property without that must have properties that are common across all variants. Bug: 155628860 Test: m nothing Change-Id: I3df60f0b53ba02ec2c55a80c7da058eac5909d26
2020-05-08Revert "Detect invalid arch specific properties in snapshot" Greg Kaiser
Revert submission 1302576 Bug: 156054601 Reason for revert: Presumed root cause of build break. Reverted Changes: Ifc8116e11:Detect invalid arch specific properties in snapsho... I7ebd33307:Adds support for 'ignored-on-host' I167b47a13:Fix snapshot of a host/device cc_library with stub... Change-Id: Id7eba0bdde5c579e10e9b42d94a7cfab5f34995f
2020-05-08Revert "Adds support for 'ignored-on-host'" Greg Kaiser
Revert submission 1302576 Bug: 156054601 Reason for revert: Presumed root cause of build break. Reverted Changes: Ifc8116e11:Detect invalid arch specific properties in snapsho... I7ebd33307:Adds support for 'ignored-on-host' I167b47a13:Fix snapshot of a host/device cc_library with stub... Change-Id: I2a7ac0ef0232177eefc26542c11dc675d6f4cab2
2020-05-07Adds support for 'ignored-on-host' Paul Duffin
Adds a filter mechanism that can exclude property values from being included in the common value extraction. That is needed to prevent the snapshot mechanism from generating invalid output for properties that are ignored on host (and have their values cleared) and which are not tagged with `android:"arch_variant"`. Changes: * Updates the documentation of SdkMemberType to explain what effect the 'ignored-on-host' tag has. * Adds some tests for this new mechanism. Bug: 155628860 Test: m nothing Change-Id: I7ebd333079619dba546bc8c4911d567e0287b676