Commit graph

123 commits

Author SHA1 Message Date
Kiyoung Kim
aa39480d21 Split usage of UseVndk
UseVndk is a function to check if the module can use VNDK libraries, but
this function was also used to check if the module is installed in the
treblelized partition (vendor or product). As of VNDK deprecation,
UseVndk funtion will return false even when the module is installed in
vendor / product partition, so we need a separated function to check
this. This change introduces a new function 'InVendorOrProduct' which
replaces UseVndk based on its usage.

Bug: 316829758
Test: m nothing --no-skip-soong-tests passed
Change-Id: Ic61fcd16c4554c355f6005894a4519b044b27fe5
2024-01-09 11:37:14 +09:00
Colin Cross
4a9e6ec903 Use ModuleInfoJSONProvider for cc modules
LOCAL_STATIC_LIBRARIES, LOCAL_WHOLE_STATIC_LIBRARIES,
and LOCAL_HEADER_LIBRARIES are only  exported to Make
so that it can generate module-info.json.  Export
ModuleInfoJSONProvider from cc modules so that Soong can
generate the module-info.json entries, and remove the
properties from the generated Android.mk.  This will prevent
Kati reanalysis when making some Android.bp changes.

Bug: 309006256
Test: Compare module-info.json
Test: Compare Kati's build.ninja
Change-Id: I6660f6802b9cea46eed553cac12f09a373eeb019
2024-01-02 16:06:09 -08:00
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
Colin Cross
5c1d5fb21b Move test data installation to Soong
To generate module-info.json in Soong for b/309006256 Soong needs to
know the test data paths. Moving test data installation into Soong will
also help later for test suite packaging.

Add ModuleContext.InstallTestData that installs the files listed in a
[]DataPath alongside the test.  The files will also be passed to Make
to allow it to continue packaging them into the test suites for now.

Update the module types that are producing LOCAL_TEST_DATA entries
in their Android.mk files to go through InstallTestData instead.

Bug: 311428265
Test: atest --host toybox-gtests --test-timeout=120000
Change-Id: Ia8b964f86e584ea464667fd86a48d754d118bead
2023-11-30 13:38:49 -08:00
Aditya Choudhary
4b6eaf4bd1 Set testModule to true in cc.NewTest().
This Cl sets testModule field to True in cc.NewTest(). This will cover "cc_test", "cc_test_host" and "art_cc_test".

Change-Id: I4a8db86835b195db34fd9f86560e7bf9321fbd7d
2023-11-21 15:49:19 +00:00
Aditya Choudhary
87b2ab28a8 Add test spec provider to test modules.
Provider added for the following test modules in this change: art_cc_test, cc_benchmark, cc_fuzz, cc_test, cc_test_host, rust_test,and rust_test_host.

Bug: 296873595
Test: Manual test
Change-Id: I815680529bcbecacb3a2bdb8f3746053afdee48c
2023-11-20 21:52:56 +00:00
Jingwen Chen
6e119745b8 Revert "Do not convert non-unit tests."
This reverts commit 80b54d2502.

Reason for revert: caused hello_world_test to not be converted, but it's a test that builds/passes

Bug: 300117121

Change-Id: I805cfb336b7f58a5a1e295cade16be4c471e2ed5
2023-10-09 23:21:54 +00:00
Chris Parsons
5f1b3c7ad8 create, but dont register, bp2build_deps mutator
This is the bulk of the "allowlist v2" feature. It will disable bp2build
generation for modules which have transitive dependencies without a
bazel build definition.

This CL includes this mutator, but doesn't register it as a bp2build
mutator (outside of a few unit tests). This allows us to easily iterate
on completion of this feature and ensure there are no launch blockers
before we finalize the change in AOSP.

Bug: 285631638
Test: Unit tests
Change-Id: Ifb0a079c409ca19b02cafa3fab2efa0d3deebc50
2023-10-03 00:16:30 +00:00
Liz Kammer
80b54d2502 Do not convert non-unit tests.
Test: CI
Change-Id: Iab9c134718351187859f34a26bd3a2aa66e009d5
2023-09-21 14:27:42 -04:00
Chris Parsons
637458d326 Have ConvertWBp2build use Bp2buildMutatorContext
This no-op refactoring facilitates some upcoming functional changes for
"bp2build allowlist v2". The work requires that the bp2build conversion
mutator be changed from a TopDown mutator to a BottomUp mutator.
Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext
makes it easier to make this functional change without touching tens of
files and multiple projects.

Bug: 285631638
Test: m bp2build
Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
2023-09-20 14:49:35 +00:00
Treehugger Robot
e56803d74d Merge "Skip device test only configs for auto gen test config" into main 2023-09-02 08:46:56 +00:00
Yu Liu
7ece4aae36 Support memtag sanitizer.
Bug: 295173102
Test: local unit tests
Change-Id: Ib8cd82cd3989d9c120255e149473d8ec00f100f5
2023-08-28 17:14:58 -07:00
yike
fdca7fe03b Give cc_test rule information to determine the test types
There are three types of tests, deviceless tests, device-driven tests
and host-driven device tests. But currently we don't have information
to get the type of a test and can't generate test targets on desired
types.

Test: b test //platform_testing/tests/example/native:hello_world_test
Test: b test //packages/modules/adb:adbd_test
Bug: 296312548
Change-Id: I3f022ef769636d508e055477623a4d1a6a1d9044
2023-08-17 21:28:47 +00:00
Dan Shi
ad04250dd1 Skip device test only configs for auto gen test config
Bug: 286659776
Test: m some host test module
Change-Id: I2abe9cc1474691ef5aed17ca51b6f948728d01be
2023-08-02 13:53:00 -07:00
Spandan Das
e50fd111f3 Emit gtest in BUILD files only if Android.bp sets it
cc_test bazel macro will default `gtest` to True (similar to Soong). So
we can skip explicitly setting this in the generated BUILD files. The
benefit will be that it will make the generated files less verbose,
without loss of information.

This will be implemented by changing its datatype to *bool from bool.

Test: go test ./bp2build
Test: TH
Change-Id: I284e10f1d58c8e7893b170209827f7d5084ca95e
2023-07-26 17:42:21 +00:00
Spandan Das
d1cd3518a8 Support cc_test.isolated in bp2build
This property implicitly adds `libgtest_isolated_main` to the static
libs of the test. bp2build will make this and `liblog` explicit in BUILD
files

Since the deps are made explicit in BUILD files, `isolated` becomes a
no-op for cc_test. Remove this property from cc_test.

Test: unit tests
Bug: 244432609
Change-Id: I189a7b6b62d9064f4b2abad49ac4975468046498
2023-07-26 17:06:27 +00:00
Spandan Das
f5a8655cd8 Fix difference in default cc_test.isolated in soong and bp2build
Soong defaults to false, while bp2build defaults to true. This CL fixes
bp2build's default to false to match Soong.

To prevent future differences, bp2build now uses the `isolated()`
function used by Soong. The type of the context object has been changed
to EarlyModuleContext so that the ctx object does not depend on
mutations that might not run in bp2build.

Test: TH
Bug: 244432609
Change-Id: I15346107896312961e8d12270cf2f9a2a48827e1
2023-07-26 17:06:27 +00:00
Treehugger Robot
35448be862 Merge "Make libtest_* deps explicit in BUILD files" into main 2023-07-25 18:46:39 +00:00
Jingwen Chen
6ee23ad2f7 cc_test mixed builds: suffix bazel label with __tf_internal.
To support `b test //path/to:my_test` command line, the actual
executable in the cc_test macro now has the __tf_internal suffix in its
name, so that the top level test suite target can be named without any suffixes.

See other CLs in this topic for more info.

Test: presubmits
Fixes: 292159775
Change-Id: I2d0bfc4276717ae881f6f3eb6aefa88bb47f25da
2023-07-25 08:02:11 +00:00
Spandan Das
651203de35 Make libtest_* deps explicit in BUILD files
This is currently implicitly added by the cc_test macro. This can cause
duplicate issues if users write a BUILD file as
```
cc_test (
  name = "mytest",
  deps = ["libgtest"],
)
```
Making this dep explicit in BUILD files prevents this issue.

The property `gtest` will not be removed as part of this CL. cc_test
macro will use this property to add some gtest specific copts

Test: unit tests
Bug: 249374572
Change-Id: Ife931e26367fd4aab302bedc709cf907e2c01245
2023-07-21 23:04:32 +00:00
Dan Shi
ec7314336a Support test runnner option in auto generated test configs
Bug: 284179405
Bug: 236980335
Test: unittest
Change-Id: Ifae3d556ff79153ca6c3067347fc259b665fb2e1
2023-05-26 21:34:22 +00:00
Sam Delmerico
4ed95e263f mixed build targets need transitive tidy files
Previously in mixed builds, only the tidy files for the boundary module
were built, whereas all of its transitive dependencies' tidy files were
not being built. Instead we should export the list of transitive tidy
files for a module so that we can run clang-tidy for the boundary module
as well as its dependencies.

Bug: 195029134
Test: WITH_TIDY=1 DISABLE_ARTIFACT_PATH_REQUIREMENTS=true mss tidy-packages-modules-NeuralNetworks --bazel-mode-dev
Change-Id: I463646d2ae1fc4aa075a54c264e1c34571c3fd5c
2023-02-07 16:50:30 -05:00
Sam Delmerico
5fb794ae37 clean up CL for androidmk variables
Change-Id: If14d1925bea78f467740f8395f1d529db00b618c
2023-01-27 16:01:37 -05:00
Colin Cross
225a37a7f0 Use the same rpaths for tests and binaries and cc and rust
Rust and cc binaries currently use $ORIGIN/lib64:$ORIGIN/../lib64 as the
rpath, and cc tests add $ORIGIN/../../lib64:$ORIGIN/../../../$ORIGIN:$ORIGIN.
This causes problems when a binary is included as test data in
out/host/linux-x86/testcases/<test dir>/<CPU>/<test>, as the
binaries can't find the libraries in out/host/linux-x86/lib64.

Use the same rpath for test and binaries, and for cc and rust.

Bug: 264604160
Test: m USE_HOST_MUSL=true out/host/linux-x86/testcases/acpi_tables_test_src_lib/x86_64/acpi_tables_test_src_lib && out/host/linux-x86/testcases/acpi_tables_test_src_lib/x86_64/acpi_tables_test_src_lib
Test: m USE_HOST_MUSL=true out/host/linux-x86/testcases/gen_sdk_test/x86_64/gen_sdk_test && out/host/linux-x86/testcases/gen_sdk_test/x86_64/toybox
Change-Id: I10fe5dc0de01d1f3c6aea8dbabbf60edab5989c3
2023-01-11 16:04:19 -08:00
Cole Faust
216805457c Allow adding extra tradefed options in the Android.bp file
Some tests need to add custom tradefed options, but still want to
keep most of the soong autogenerated tradefed xml file.

Expose a test_options: { tradefed_options: [...] } property that
will allow tests to add more options to the autogenerated xml file.

Fixes: 184895128
Test: go test, and verified that the ninja files did not change for aosp_arm64
Change-Id: I50d4ad139322e9e207202f1e1a50f5bbb424aa6f
2023-01-03 12:47:11 -08:00
Jigar Thakkar
1d174b185f Merge "Revert "Allow adding extra tradefed options in the Android.bp file"" 2022-12-20 16:24:20 +00:00
Treehugger Robot
597894279d Merge "mixed builds: add cc_test bazel handler, and add adbd_test to staging allowlist." 2022-12-20 03:12:53 +00:00
Tahsin Loqman
77dc7d0839 Revert "Allow adding extra tradefed options in the Android.bp file"
This reverts commit 8ec823cba1.

Reason for revert: DroidMonitor: Potential culprit for Bug b/262965953 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: I236cc36981d8b30527ca286632727f8ca267e969
2022-12-19 16:27:25 +00:00
Kevin Dagostino
32edd1a608 Add tradefed attributes to cc_test bazel macro
The BUILD file will now have the needed attributes to run the tradefed
test rules.

Test: b test //packages/modules/adb:adbd_test --platforms=//build/bazel/platforms:android_target
Change-Id: I5cb84ccdde27a7fadbef479269df594344a29187
2022-12-18 04:38:16 +00:00
Jingwen Chen
3952a9039e mixed builds: add cc_test bazel handler, and add adbd_test to staging allowlist.
This will allow the test_suites_{arm64, x86_64} CI targets on
git_master-bazel to build adbd_test with bazel in `m`.

This is currently implemented similar to the cc_binary handler to
hydrate the output path field.

The tradefed config is still currently handled by Soong in
testBinary#install, which is called from both ProcessBazelQueryResponse
and GenerateAndroidBuildActions. We'll move the tradefed config path to
a mixed builds handler when it's ready on the cc_test bazel rule side.

Tested with `atest` with cuttlefish. Since `atest` doesn't have a way to pass
--bazel-mode-staging to its internal call to Soong, so I manually tested
this by adding adbt_test to the prod allowlist, and confirmed that the
installed adbd_test is the same binary as the one in bazel-out.

Test: $ showcommands adbd_test | grep bazel-out | tail -n1

```
/bin/bash -c "rm -f
out/target/product/vsoc_x86_64/data/nativetest64/adbd_test/adbd_test &&
cp -f -d
out/bazel/output/execroot/__main__/bazel-out/android_x86_64_silvermont-opt-ST-59d4124ca041/bin/packages/modules/adb/adbd_test
out/target/product/vsoc_x86_64/data/nativetest64/adbd_test/adbd_test"
```

Test: Add adbd_test to prod allowlist and run 'lunch aosp_cf_x86_64_phone-userdebug; atest adbd_test', all tests pass.
Bug: 258426425
Bug: 261692372
Change-Id: I6be329f39d607af8daa1dc772b23e8dd0247418c
2022-12-15 08:01:44 +00:00
Cole Faust
8ec823cba1 Allow adding extra tradefed options in the Android.bp file
Some tests need to add custom tradefed options, but still want to
keep most of the soong autogenerated tradefed xml file.

Expose a test_options: { tradefed_options: [...] } property that
will allow tests to add more options to the autogenerated xml file.

Fixes: 184895128
Test: go test, and verified that the ninja files did not change for aosp_arm64
Change-Id: I75f7eb002c8325ce7cdc76e12e76e16195320620
2022-12-09 15:23:26 -08:00
Sam Delmerico
c9b8fbdda0 bp2build for tidy_disabled_srcs
Bug: 195029134
Test: m bp2build
Change-Id: I9591439213dbf0ef68cd33151b3e32f6f6c68551
2022-11-08 17:17:52 -05:00
Sam Delmerico
fb3bb32bff add clang_tidy properties to bp2build
Bug: 195029134
Test: m bp2build
Change-Id: I9ca2436ef792911be72788b6640287726a609e2f
2022-10-25 15:55:06 -04:00
Jingwen Chen
fbff97a84d bp2build: Convert cc_test.test_options.tags to cc_test.tags
zeek@ has been tagging unit tests that cannot run on RBE with
"no-remote". While we don't yet have RBE support with standalone `b
test` yet, we can make sure to propagate the tags now.

Bug: 236973602

Test: new unit test
Change-Id: I6d0648f184626bb01c657068804f99ffb82907a3
2022-09-16 02:32:03 +00:00
Jingwen Chen
ebdc20f571 Use CommonAttributes.Data for cc_test.data.
data is a common attr like name, so avoid redefining it in testBinaryAttrs.

Test: presubmits
Change-Id: Ia694b94620dfad6b8411e5a1b6c530843983ca01
2022-09-01 18:54:50 +00:00
Jingwen Chen
537242c6f1 Convert cc_test targets with bp2build.
Starting with libutils_test, adb_test, libcutils_test, (and ~47 other host_supported tests).

Test: $ b build --config=android_x86_64 //system/core/libutils:libutils_test && adb push bazel-bin/system/core/libutils/. /data/tmp/libutils_test_files/ && adb shell /data/tmp/libutils_test_files/libutils_test
Test: presubmits with newly converted cc_test targets
Test: $ b test //system/... --config=linux_x86_64 --verbose_failures --test_output=errors --keep_going --build_tests_only

Fixes: 242038415

Change-Id: I10051aadb880c3aabeba6d7fb079523e6fb4ac43
2022-09-01 14:59:15 +00:00
Zhenhuang Wang
0ac5a431a9 Move common test_options properties into the android package
Multiple modules (e.g. java, cc, python, rust) define the `test_options`
field. Extract the common properties in test_options to share across
different test rules.

Bug: 240928948
Test: `refreshmod` and diff with original module-info.json
Change-Id: I404a7a157b4ccaa53d800ee2217559ff695bd825
2022-08-17 01:19:15 +08:00
Md Shahriar Hossain Sajib
d8b58663ff Revert "Turn gtest isolated true by default"
This reverts commit d2a9d88410.

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_master&target=aosp_bramble-userdebug&lkgb=8618360&lkbb=8620137&fkbb=8618374, bug b/233280626

Bug: 233280626
Change-Id: If56b36ea1c883415b90bd2153707cb69df29776e
2022-05-20 08:02:50 +00:00
Julien Desprez
d2a9d88410 Turn gtest isolated true by default
Test: presubmit
Bug: 178498003
Change-Id: Ica5584e8b20b5acc92759b384a9263dbd1d4096d
2022-05-09 11:16:54 -07:00
Trevor Radcliffe
cd8fd67753 Make isolated true by default for gtest
This change sets everything up to do this, but does not actually
enable it. jdesprez will follow up by making a one line change
that actually turns the default to true when he does test
debugging/verification.

Bug: 178498003
Test: build. Relying on @jdesprez for the rest of the verification
Change-Id: I3b1b6b57279dd4f9f7fc559e2d3ad76911b045e8
2022-05-03 14:51:16 +00:00
Trevor Radcliffe
f389cb4e35 Add support for test_suites to cc_test_library
Some cc_test_library modules will need to be installed for
compatibility test. This CL adds the capacity to use the
test_suites property to enable this behavior.

Fixes: 226402757
Test: Wrote unit tests, confirmed installation to proper dirs,
      and verified conversion that necessitated this change
Change-Id: I7313d4927d28aacad9e444962fd2a7efc6c3bc1f
2022-04-04 19:10:13 +00:00
Liz Kammer
be46fccc40 Use one mutator for all bp2build conversion.
Each conversion required defining a separate mutator, which will each
operate on _all_ modules and requires each to repeat checks whether the
mutator should operator. Instead, we introduce a single mutator and
modules can define a ConvertWithBp2build to implement bp2build
conversion for that module.

Test: bp2build.sh
Bug: 183079158
Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
2021-12-14 09:37:45 -05:00
Justin Yun
d396515482 Remove test_min_api_level property
Replace the test_min_api_level property with
test_options.min_shipping_api_level.

Bug: 187258404
Test: build
Change-Id: Ifbac62f389226ed690f0ec03b9cc0845132ae885
2021-12-09 00:16:41 +00:00
Ivan Lozano
4e5f07d27b rust: Add data_libs and data_bins to rust_test
Allows defining data binaries and libraries that should be installed
alongside a rust_test module, similar to cc_test.

This refactors cc_test as well so it can define rust_ffi_shared and
rust_binary modules as data.

Bug: 171710847
Test: New Soong tests pass.
Test: Example module installs data appropriately.
Change-Id: I0b56098fb475ec54f9b7a761220d260fe68cbee1
2021-11-15 17:18:42 -05:00
Colin Cross
c8caa06a36 Add data_bins property
data_bins is similar to data_libs but copies helper binaries alongside
the test.

Bug: 200872604
Test: atest CtsBionicTestCases
Change-Id: I4f9df5f82816cfd30a0a19808fda220cf77c50a7
2021-09-27 15:56:26 -07:00
Colin Cross
cfb0f5e102 Support per-testcase directories in all test suites
There are cases where two modules try to install the same test data
into CTS, which results in collisions when CTS puts the data for all
tests in the same directory.  Add a flag that allows enabling a
per-testcase directory for an individual test for all test suites.

Bug: 193168159
Test: cts-tradefed run commandAndExit CtsBionicTestCases
Change-Id: If034723e8fe937ca71d3e2d39b7d46702e41bc8c
2021-09-27 15:56:26 -07:00
Guang Zhu
5c97bc698f Revert "update build rules to use /data/local/tests/unrestricted"
Revert submission 1826231-native-test-path

Reason for revert: b/199996863

Bug: 199996863

Reverted Changes:
Ic106011a7:update build rules to use /data/local/tests/unrest...
Id727355ec:update build rules to use /data/local/tests/unrest...

Change-Id: Id53334a6169e58964ef86e78de738f29b32dd491
2021-09-22 04:20:22 +00:00
Guang Zhu
83150667ae update build rules to use /data/local/tests/unrestricted
... for native tests. This new location has the appropriate
settings for debuggerd to generate valid backtraces in case
of test binary crash.

Bug: 167308193
Bug: 199904562
Test: compile
Change-Id: Ic106011a79f0aec86896b305616cf5590ab2eb2d
2021-09-14 10:56:47 -07:00
Justin Yun
a364cfb69d Define vsr_min_shipping_api_level to cc_test
test_options in cc_test can have vsr_min_shipping_api_level to define
the minimum shipping api level that checks vendor api level in
addition to the device shipping api level. It can be used for the
tests that have dependency on the vendor api level.
vsr stands for the vendor software requirements.

Bug: 181284704
Test: manual test
Change-Id: I7f2cecd2818d35d86f7c08cb220e0c9db71fe0a8
2021-05-14 12:47:18 +09:00
Justin Yun
46f66059e9 Define test_min_vndk_version for cc_test
If a cc_test module defines test_options.test_min_vndk_version, the
test runs only if the ro.vndk.version of the device is defined as a
version code name or an integer value that is higher than or equal to
the value in the test_min_vndk_version proprety.

Also, move the existing test_min_api_level property to test_options
struct.

Bug: 186786268
Bug: 187258404
Test: manual test
Change-Id: I43f1cca5b60f102298726332d374e4b14c425948
2021-05-05 18:47:23 +09:00