summaryrefslogtreecommitdiff
path: root/rust/test.go
AgeCommit message (Collapse)Author
2025-03-13Change CommonModuleInfoProvider to a pointer. Yu Liu
Bug: 358427516 Test: Manually verified genereated ninja and mk files, unit tests. Change-Id: I53a6dd718232735decbeb93febfd269dd9449e86
2025-03-11Expand TestSuiteInfoProvider to all test modules Cole Faust
Test suites have been historically only defined in the AndroidMk functions. But in soong-only builds, we don't run AndroidMk. It appears Colin already started making a TestSuiteInfo provider, but hadn't set it on all test modules yet. Expand it to all the test modules, and add export it to make so that make can check that it matches LOCAL_COMPATIBILITY_SUITES. Bug: 388850000 Test: m nothing Change-Id: Iee8959742117604fd560c95be60f3cb7cf3d9ae4
2025-03-11Merge "rust: Set the rpath for rust_test modules" into main Ivan Lozano
2025-03-07Rename CommonModuleInfoKey to be consistent with others. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I1ce8bc782666586633ded9cfaf1b9590e3c0efde
2025-03-06rust: Set the rpath for rust_test modules Ivan Lozano
Set the rpath for rust_test modules to allow the runtime linker to find libraries defined in data_libs. Bug: 171710847 Test: m Change-Id: I1b67f0256826a3161a4c3193076e2ee4aef8c093
2025-02-21Merge "Implement host_common_data property for cc, java, rust and sh test ↵ Colin Cross
modules" into main
2025-02-18Implement host_common_data property for cc, java, rust and sh test modules Colin Cross
Implement the host_common_data property that will copy a host common module into the test data directory. This property can be used to copy a custom Tradefed test runner jar alongside the test. Bug: 262397555 Test: TestHostCommonData Change-Id: Iacef0778254a3dda400c9e221f442c47d8db7b02
2025-02-18Install tradefed dynamic config file in soong-only builds Cole Faust
Make has this behavior where it will find a DynamicConfig.xml file in the same directory in the module and install it next to the main tradefed config file. Recreate that behavior in soong-only builds. https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/base_rules.mk;l=859;drc=6a8fff595ba4cbb87b7e124fd630f548c5c4e2cb Bug: 396761822 Test: SOONG_ONLY=true atest -m -c CtsNetTestCases -- --test-arg com.android.testutils.ConnectivityTestTargetPreparer:ignore-mobile-data-check:true Change-Id: I69f1c262200d62cc0d3c590b6adbeb401af63ab9
2025-01-29Merge "Install rust test and deps in testcases/ in soong-only" into main Treehugger Robot
2025-01-29Convert rust module-info.json to soong Cole Faust
This leads to idendical results as before, with the exception of the "required" field in module-info.json. Make has more complicated logic to fill out the required field than soong, and it leads to make-specific names such as ones suffixed with :32 and don't make sense in soong. I'm don't think there are critical users of that field though, so I'll try removing it. Everything else should be identical to the make-generated information though. Bug: 389720048 Test: diff'd module-info.json before and after this cl in soong+make mode Change-Id: I74aefe578287f07474c15e5f92a0c2780a679047
2025-01-29Install rust test and deps in testcases/ in soong-only Spandan Das
For use in atest Bug: 391924360 Test: Set PRODUCT_SOONG_ONLY Test: Copied mk build module-info.json to $PRODUCT_OUT/module-info.json Test: atest libmmd_unit_tests Change-Id: Iebf5dec44356152877f96da95914edd653f16967
2025-01-28Add new flags for Rust 1.83 update Chris Wailes
This CL adds the `-A missing-docs` flag when building Rust test binaries and the `-A clippy::empty_line_after_doc_comments` flag for Clippy targets. The first flag is required because the 1.83 update exposes previously hidden functions that do not necessarily need documentation. Test: m rust Bug: 384401387 Change-Id: Ic6bee1bd827db7b6cec1f83870108d164d02888a
2025-01-23Convert rust to use ModuleProxy. Yu Liu
Bug: 377723687 Test: Unit tests and compare the ninja and mk files generated. Change-Id: I2eb0134bb727f5875d579dae1fff5b70658bd2bb
2024-12-13rust: Alias rust_ffi_rlib to rust_library_rlib Ivan Lozano
With the new transition mutators, the distinctions between rust_ffi_rlib and rust_library_rlib are not necessary. This CL removes the remaining distinctions to allow an unusual use case where a rust_library and a rust_ffi_rlib would otherwise be created from the same source. This would allow defining a single rust_library_rlib that works for both rust modules and cc modules. One key change is that rust_ffi_rlibs only produced an rlib-std variant previously, and now produce dylib-std variants as well.This surfaced an issue where a libstd linkage mismatch would cause rustc to throw a consufing missing crate error. We instead add logic to catch this in Soong and provide a more useful error message. Bug: 383552450 Test: m rust Test: m blueprint_tests Change-Id: I611ca46934059735d06229952cfd8e0ab7050486
2024-10-21Add new properties to aid in removing the 1-variant fallback Cole Faust
These new properties are essentially methods to specify "outgoing transitions" in blueprint files. There are lots of host tests that want to include apps built for device in their data, so they need a property that adds dependencies based on the device variants instead of copying the same host variants. After this cl is submitted, I'll do an LSC to update all the usages that are relying on the 1-variant fallback to use these properties instead. Bug: 372091092 Test: m nothing --no-skip-soong-tests Change-Id: I45b8fb024da120ad61606e3a21de86e4392be2a4
2024-07-16Switch rust test install base to /data/local/tmp for consistency with cc Nikita Putikhin
Previously this code was not doing anything because the template used for rust did not use the template string that gets replaced with the folder coming from this code. So all tests were getting deployed into /data/local/tmp regardless of being vendor tests. The other change in the chain adds the template string, so this code starts working and system and vendor tests start being deployed into different folders. We want to keep the system test folder as before to avoid potential problems with tests (see b/350479879#comment9). Bug: 347370677 Test: presubmit Change-Id: I93d5a8db3470d1603e26f9cf5d12249f29141a19
2024-06-28Remove test_per_src Colin Cross
Remove test_per_src, it never worked well and is incompatible with all of the test infrastructure. Uses in the platform have been removed, generally by replacing them with individual cc_test modules. Test: builds Flag: TEST_ONLY Change-Id: I257c035da35ca8358ae9423b46453878f54efeb1
2024-01-09Split usage of UseVndk Kiyoung Kim
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
2023-11-30Move test data installation to Soong Colin Cross
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-20Add test spec provider to test modules. Aditya Choudhary
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-01-11Use the same rpaths for tests and binaries and cc and rust Colin Cross
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-03Allow adding extra tradefed options in the Android.bp file Cole Faust
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
2022-12-19Revert "Allow adding extra tradefed options in the Android.bp file" Tahsin Loqman
This reverts commit 8ec823cba166a41eb0e9e5ff8fe679e691fec678. 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-09Allow adding extra tradefed options in the Android.bp file Cole Faust
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-08-17Move common test_options properties into the android package Zhenhuang Wang
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-04-28Put rust_test.data_libs under lib[64] Jooyung Han
Rust test binary depending on native libraries would require them under lib[64] directory so that the test binary can open them with default rpath values. Bug: 204562227 Test: presubmit Change-Id: I029bb32c4c98fba21bd28e579a9df9f184a7f045
2021-12-07rust: Fix Host multilib prop for rust_test modules. Ivan Lozano
NewRustTest will set MultilibBoth true for modules which target devices, however modules which target both device and host incorrectly sets MultilibBoth for the host variant. Host tests can only produce the primary arch target. Therefore, add the rustTestHostMultilib load hook to set MultilibFirst for the host variant. Test: m rust_test module with host_supported: true, check if x86 test produced. Change-Id: I5b04b2a2d898823bcf326336d1d28c46945d47f5
2021-11-16Merge "rust: Add data_libs and data_bins to rust_test" Ivan Lozano
2021-11-15rust: Add data_libs and data_bins to rust_test Ivan Lozano
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-04rust: Support MTE memtag_heap sanitizer Ivan Lozano
This CL adds support for the MTE memtag_heap sanitizer. This is controlled via inclusion of an ELF note. Bug: 170672854 Test: Heap MTE-enabled Rust test binary triggers MTE Change-Id: I2619818785e86a94667d02b30d102c83456b7925
2021-09-21rust: Add require_root and vendor install base Ivan Lozano
Adds the require_root property to rust_test modules so that tests can run as root. Also adds an install base to allow vendor tests to install to a different path, otherwise installs to 'unrestricted' like cc_test. Bug: 200602232 Test: test with require_root: true runs as root Test: test installed to new base directory Change-Id: Ifa716871ff87471f0c0caff7af558d47db85ccd1
2021-07-15rust: Remove libtest from stdlibs list Ivan Lozano
libtest does not need to be linked for every module type, so remove it from the stdlibs list. Instead, link it only when building benchmarks or tests. Bug: 193782599 Test: cd external/rust/crates/; mma Test: Rust tests still run correctly. Change-Id: I536be8754da0987e09340744d9ebf668b8e734d0
2021-02-10Merge "Changing default of rust_test_host to unit_tests:true" Julien Desprez
2021-02-05Changing default of rust_test_host to unit_tests:true Julien Desprez
Switch all rust_test_host to unit_tests = true by default. Test: presubmit trigger Bug: 177689340 Change-Id: Ie6059f874d8805049d5f6e5de18574050ae431d7
2021-02-04bp2build: convert paths/module refs to Bazel label Liz Kammer
This currently expands all globs, still need to support converting glob syntax. Test: go build_conversion_test Test: GENERATE_BAZEL_FILES=true m nothing Test: m nothing Bug: 165114590 Change-Id: If7b26e8e663d17566fad9614ca87a8da1f095284
2021-01-29rust: Allow rust_tests to include data files. Ivan Lozano
Adds the ability to define data files that should be installed alongside the test. This also fixes a bug wherein rust_test properties were duplicated. Bug: 171710847 Test: rust_test module with "data" property installs files to device. Change-Id: I091489afaf7e76b751a33a28049590d9fb39fe5f
2021-01-26Rust: abort on panic Jeff Vander Stoep
Test: build (test included in build) Bug: 162266455 Change-Id: I7f53956d3a35f923d0282d511d6360051f945a88
2020-11-16Add unit_test test option in test configs Dan Shi
This change allows a test (native, java, rust or python) to be included in host-unit-tests suite when test option `unit_test` is set to true. Bug: 172006742 Test: m host-unit-tests Change-Id: I69d3eb5b51198c549e2e6914ceac3a4fc33c3cf2
2020-09-28rust: Refactor staticStd to stdLinkage Ivan Lozano
Instead of returning a boolean, return an enum value to improve readability and provide greater flexibility for future modifications. Bug: 168729404 Test: Soong tests pass Change-Id: Iddcdae8c34be09e476404382e43d1ea5935bae65
2020-09-18rust: Add libstd linkage mutator for rlibs. Ivan Lozano
The current state of linkage is that device targets always link libstd dynamically except for rust_ffi_static which requires a static libstd linkage. However this prevents producing rust_ffi_static modules which depend on other Rust libraries as those dependencies will link libstd dynamically and cause a collision. We also want our rust_test modules to statically link in libstd as well. This adds a linkage mutator for rlibs that creates a variant for each libstd linkage. Dependent modules can then select the variant that matches their linkage of libstd. Also fixes an issue where installation paths were being generated for rlibs and static libs even though they weren't being installed. This broke when adding the linkage mutator as Make would complain about multiple targets producing the same output. Bug: 168729404 Test: rust_ffi_static module with other rustlib dependency can be built. Change-Id: I955b484bf5809e8fc5517750c7f8df82d3ca8895
2020-08-28rust: strip libraries and binaries Thiébaud Weksteen
Reuses the cc.Stripper logic. Abstracts Stripper to avoid the spreading of references to the cc package. rustc requires unstripped libraries (precisely, with the `.rustc` section) when building dependent targets. Contrary to cc, the output of a compiler module will remain unstripped and only an extra build rule will be added. This rule will be referenced at install time (in baseCompiler.install or androidmk). This change drastically reduces the size of the installed libraries: (unstripped, from out/target/product/crosshatch/system) $ find . -name \*.dylib.so -print0 | du -c --files0-from=- 149996 total (stripped, with this change) $ find . -name \*.dylib.so -print0 | du -c --files0-from=- 42380 total Bug: 153430439 Test: cd external/rust; mma Change-Id: I94fd8bbcec97e0610aa325d3db4460be84d01734
2020-08-25Link device binaries dynamically by default. Ivan Lozano
Device binaries currently are linked statically by default. Instead we should be linking these dynamic by default. To avoid conflicts when manually specifying rlib dependencies on modules, we always link libstd dynamically for all device modules except static libraries. This removes the "prefer_dynamic" property entirely to avoid confusion. Bug: 165161105 Test: m profcollectd is built dynamically. Test: cd external/rust/; mma Test: cd external/crosvm/; mma Change-Id: I25ac897040acbcc2d97c791a33e8e01610632272
2020-08-04Make Rust test harness optional for test binaries Stephen Crane
Adds a test_harness field to Rust test blueprint properties. If this field is explicitly set to false, do not build the test binary with `--test`. This is necessary for Rust tests which cannot use the standard test harness. Test: atest rustBinderTest Test: atest --host proc-macro2_tests_test Change-Id: Icbcb54422cc716348feae56b2d71f013516b0ac0
2020-07-01rust: Add rustlibs auto dependency selection Matthew Maurer
Adds the rustlibs dependency type which will automatically select between rlib and dylib based on the type of the library. Bug: 143217452 Test: cd external/rust; mma Change-Id: I97faadae98bf957090a32939cfb2d3a10f74a057
2020-06-17Generate multilib for rust_test Chih-Hung Hsieh
* Cannot generate multilib for host tests yet. Bug: 158677299 Test: atest -c -m --include-subdirs external/rust/crates Change-Id: I7071c1ea30865a8cf268dfe270f2a586eb7710d9
2020-06-11Make rust_test file output more similar to cc_test. Ivan Lozano
This changes the way the output filename is calculated for rust_test binaries to be more similar to cc_test. This also removes the option to define multiple test binaries in a single rust_test module via the TestPerSrc mutator. Now each rust_test module corresponds to a single test binary. Bug: 158500462 Test: m -j pin-utils_tests_pin_utils Test: m -j unicode-xid_device_tests_unicode_xid Change-Id: I6e0f79dcb4e49fa49d6ebb36abeef67a9eb180a0
2020-06-10Fix using generated test configs for sh_test, python_test and rust_test modules Colin Cross
Annotate the test config properties with android:"path", and always use LOCAL_FULL_TEST_CONFIG to pass the path to Make. Bug: 157621988 Test: manual Change-Id: I1c020e642f83d994d63c9e9cb56e686086d5acaa
2020-05-05Add gcov coverage support to Rust modules. Ivan Lozano
This adds gcov coverage support for Rust device library and binary modules (including test modules). Support is provided to pass Rust static library gcno files to CC modules and visa versa. Additional changes: * Begin mutator added for Rust modules. * SuffixInList added to android package. * CoverageEnabled added to Coverage interface. * CoverageFiles added to LinkableLibrary interface. * Fix in coverage mutator for non-CC modules which marked the wrong variant as the coverage variant. * Added coverage libraries to the cc.GatherRequiredDepsForTest. Bug: 146448203 Test: NATIVE_COVERAGE=true COVERAGE_PATHS='*' m -j <rust_module> Change-Id: If20728bdde42a1dd544a35a40f0d981b80a5835f
2019-12-13Install rust tests under nativetest(64) Chih-Hung Hsieh
* Now the installation directories match those for C/C++ tests: * The relative_install_path refers to path under nativetest(64). * Device test files are installed in data/nativetest(64). * Automatically generated configuration files and copied test binaries are still in the "testcases" directory. * Change host test configuration to run test binary files in testcases/<mutated_module_name>/<arch_type>/<stem_name> Bug: 140938178 Test: atest --include-subdirs under external/rust/crates Change-Id: I4b29afb897f4ba8749e87f79857c5b1a959bb2b0
2019-12-02Generate tradefed config for rust device tests. Chih-Hung Hsieh
* The RustBinaryTest runner and device test config template are derived from GTest. Device tests are pushed to /data/local/tmp. Bug: 140938178 Test: make unicode-xid projects; run atest Change-Id: Idb4cab7872b48c6e25bc59b85aa6d9dece4383ec