summaryrefslogtreecommitdiff
path: root/rust/testing.go
AgeCommit message (Collapse)Author
2021-11-02rust: Remove libtest from stdlibs listIvan 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. Merged-In: I536be8754da0987e09340744d9ebf668b8e734d0 Change-Id: I536be8754da0987e09340744d9ebf668b8e734d0
2021-04-15Merge changes I59439b77,I7dbaf8beThiébaud Weksteen
* changes: bloaty: measure stripped Rust binaries rust: do not strip static library
2021-04-15bloaty: measure stripped Rust binariesThiébaud Weksteen
Modify bloaty's MeasureSizeForPath to allow a module to provide multiple paths. This is used to measure both unstripped and stripped libraries/binaries. Add unit test to ensure correct measurements are generated for Rust. Test: m out/soong/binary_sizes.pb.gz Change-Id: I59439b77dbf1cf5ad71e1c02996a6a90938536b4
2021-04-14Merge changes from topic "rust_vendor_support"Ivan Lozano
* changes: Add more Rust vendor image support. rust: Use new common image mutator interface.
2021-04-13Add more Rust vendor image support.Ivan Lozano
This adds Rust vendor image support for all module types except Rust prebuilts. Bug: 184042776 Test: New Soong tests. Test: Example cc_library vendor module can depend on rust_ffi_shared. Test: Example rust_library vendor-only module compiles. Change-Id: Iaa30ad51fdaedcbf14687da5472581f6af62ff59
2021-04-13rust: Use new common image mutator interface.Ivan Lozano
Refactor rust to use and implement the new common image mutator interface to handle future image mutations. Bug: 184042776 Test: m nothing Change-Id: If6a85e2b8c6a1969d62264eaea6c6b53cae9c039
2021-04-06Add rust_benchmark module to soong.Jakub Kotur
This commit adds rust_benchmark and rust_benchmark_host commands to soong. Respectively running rust benchmarks on device and host. Currently only criterion based benchmarks are supported and criterion library is automatically linked. Test: atest <module with rust_benchmark defined> Bug: 155309706 Change-Id: I6edfc2b4bf30b1163fe59b8c2ecdcd4e7125e7b9
2021-03-30Convert remaining rust tests to use test fixturesPaul Duffin
Removes now unused CreateTestContext and stops exporting the RegisterRequiredBuildComponentsForTest() method as it is only used locally. Bug: 181070625 Test: m nothing Change-Id: Ia2fd3e090f975ee4c807da2c6c162ef3cf7ac446
2021-03-11Add text fixture preparers for rust packagePaul Duffin
Needed to decouple the integration of test fixtures into apex from the support of test fixtures in rust tests. Bug: 181070625 Test: m nothing Change-Id: I26bdfde58dd75713ece89e631edabf041d40596a
2021-03-05Clean up cc.RegisterRequiredBuildComponentsForTest()Paul Duffin
Changes this function so it only registers components from the cc package by pushing the call to genrule.RegisterGenruleBuildComponents() down into those packages whose tests need it. This will make it easier to migrate cc package tests to test fixtures as the RegisterRequiredBuildComponentsForTest() no longer overlaps with preparers from the genrule packages. Bug: 181070625 Test: m nothing Change-Id: Ic00c7e480dc738d7a88d038aca6ab95a1502a24a
2021-02-09rust: Use prebuilts for x86 host target.Ivan Lozano
Use prebuilts for x86 host targets to make both x86 and x86_64 builds more consistent with one another. This fixes building x86 binaries. Bug: 162063992 Bug: 169347277 Test: Build 32-bit host module. Change-Id: Id11eb0f3b949439cec090060a33b755af94b5883
2021-02-08rust: Add rust_ffi_static vendor ramdisk SupportIvan Lozano
Similar to our vendor support, this adds support for linking rust static libraries to vendor ramdisk cc modules. A bug fix is also included where a restriction against setting rust_ffi vendor-specific was not being enforced. Bug: 179397942 Test: Example modules link, Soong tests pass. Change-Id: I737cdf0c2f49ab349bcea2a0429e6298ebc1313e
2021-01-25Add Rust fuzzing support.Ivan Lozano
Add a rust_fuzz module which builds a libfuzzer binary that enabes asan+sancov. This relies on the libfuzzer-sys crate. Bug: 147140513 Test: Local rust_fuzz example builds, fuzzes with asan+sancov. Change-Id: I57db3b8d25869791824ccfab768d13b0bb9d42fa
2020-12-11Merge rust_protobuf and rust_grpcio module types.Ivan Lozano
To allow grpc protobufs to include non-grpc protos in a singular library, we need to allow them to be defined as part of the same module. This CL merges the two previously distinct module types into rust_protobuf, and adds a new property for declaring which protos contain grpc definitions. Bug: 172952239 Test: rust_grpcio modules converted to rust_protobuf modules and build. Test: Example rust_protobuf module with both proto types builds. Change-Id: I0e627fd97bc6f74de89d309e3344694a1e76586d
2020-12-11Merge "Rust: Vendor support for Rust static libraries."Ivan Lozano
2020-12-10Rust: Vendor support for Rust static libraries.Ivan Lozano
We don't have Rust VNDK support yet, but static linkage can be supported in the interim. This adds support for making rust_ffi_static libraries available to CC vendor modules. Since rust_ffi_static modules will link against rlibs, we allow rlib linkage into vendor as well, but only for the variants which use the rlib libstd. Bug: 172525289 Test: New Soong tests pass Test: Example vendor cc_binary links against rust_ffi_static module. Change-Id: Idf3aeb51e32293866f1ad965e329aa6b9e0bf2ef
2020-12-09Add min_sdk_version to Rust modules.Ivan Lozano
Add the min_sdk_version property to Rust modules so they can declare a minimum SDK version they support for use with APEX modules. Test: New Soong test passes. Bug: 174862583 Change-Id: I2829053a320f50c218783dee5adbeff9cef81e8e
2020-11-30rust modules can be included in apexJiyong Park
We will have some APEXes having rust binaries and libraries. So, adding the support for the types of modules. rust.Module now inherits from android.ApexModuleBase and implements the android.ApexModule interface. Bug: 172414324 Test: m Exempt-From-Owner-Approval: rebased after +2 from the owner Change-Id: I356ef4c45f782a6460f001e83af96d1710642d80
2020-11-23Annotate dependency tags for dependencies of installed filesColin Cross
Relands Ic22603a5c0718b5a21686672a7471f952b4d1017 with a minor change to track libc++ dependencies for python hosts and after a fix to an internal genrule that depended on transitively installed java libraries (ag/13068670). Soong currently assumes that installed files should depend on installed files of all transitive dependencies, which results in extra installed file dependencies through genrules, static libs, etc. Annotate dependency tags for dependencies for which the installed files are necessary such as shared libraries and JNI libraries. This avoids extra installed files, and is also a first step towards genrules using their own copy of tools instead of the installed copy. Bug: 124313442 Test: m checkbuild Test: java.TestBinary Test: cc.TestInstallSharedLibs Test: deptag_test.go Change-Id: I725871249d561428e6f67bba6a7c65b580012b72
2020-11-17Revert "Annotate dependency tags for dependencies of installed files"Colin Cross
This reverts commit 62a0cfd05460d0e760ce9133690e48861bb57eee. Reason for revert: b/173475545 Change-Id: I4e834200c8e68dfa1b8144dfd1fa95ca68554980
2020-11-14Annotate dependency tags for dependencies of installed filesColin Cross
Soong currently assumes that installed files should depend on installed files of all transitive dependencies, which results in extra installed file dependencies through genrules, static libs, etc. Annotate dependency tags for dependencies for which the installed files are necessary such as shared libraries and JNI libraries. This avoids extra installed files, and is also a first step towards genrules using their own copy of tools instead of the installed copy. Bug: 124313442 Test: m checkbuild Test: java.TestBinary Test: cc.TestInstallSharedLibs Test: deptag_test.go Change-Id: Ic22603a5c0718b5a21686672a7471f952b4d1017
2020-11-12Pass Config to NewTestContext instead of ctx.RegisterColin Cross
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
2020-11-11rust_grpcio well known types support, default depsZach Johnson
The usage of the well known type Empty requires a hack in the module above the grpc implementation, this is now the generated stem_mod.rs This also adds additional implicit dependencies that are required by the grpc protobuf generated code. This includes the addition of a 'header_libs' property for library dependencies which export include paths required by protos. We also now include both the protos and the grpcio in the library variant via the mod_stem.rs. Bug: 172592789 Bug: 171504899 Test: m nothing Test: Example rust_grpcio module build command includes dependencies, include paths. Change-Id: I187a13cd5cdea991828a1020314de16727e4f74e
2020-11-05Add rust_grpcio module type.Ivan Lozano
Adds a new SourceProvider type to generate grpcio code from protos. Since it's so similar to protobuf, it's basically just a different type of rust_protobuf. Bug: 171504899 Test: Example module compiles. Change-Id: I9882f3ac4d4aeaae0191f2b557e9612b5c7a9ac9
2020-09-29rust: Add ref to generated sources (aidl, bindgen)Thiébaud Weksteen
Test: SOONG_GEN_RUST_PROJECT=1 m nothing; Edit system/security/keystore2/selinux/src/lib.rs; Check name resolution in IDE. Bug: 168263887 Change-Id: Icbbf176c4355c3043807ce3fe0c3967c4a1374e2
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-31Add rust_protobuf module.Treehugger Robot
This adds a new SourceProvider module type to handle protobuf code generation. See the new test for an example of how to call this. Bug: 143953733 Test: New soong tests pass. Test: Replacing genrules in crosvm with rust_protobuf modules. Change-Id: Ie3117129cde37b8736bc18ee09bf5cde27c01c34
2020-08-11Stop using prebuilt NDK CRT objects.Dan Albert
We don't need the prebuilt versions. The NDK CRT objects are (now) built from the platform sources and the only difference is that the NDK CRT objects also include an ELF note that identifies the NDK version, which isn't helpful for anything built by the platform. Add a `crt` property to cc_object that allows CRT objects to identify themselves. CRT objects, unlike other modules, will have a variant built per-API level they support, rather than just an SDK variant and a platform variant. This is needed because new CRT objects will rely on APIs not available in old libcs and old CRT objects will not support all the features of a modern one. Test: treehugger Bug: http://b/159925977 Change-Id: I6595485fa1bfe0ad4945193d344b863f64eec654
2020-08-06rust: validate existence of library sourceThiébaud Weksteen
While rust_bindgen modules may be interpreted as libraries, they do not have a reference to the generated source until bindgen has been executed. For now, ignore these modules. Update the unit tests to cover the rust_bindgen case. Test: SOONG_GEN_RUST_PROJECT=1 m nothing Bug: 162881856 Change-Id: I329d0fe3d94b77d395c3684f55ab01544ff7c18f
2020-07-31Fix prebuilt mutator ordering in testsPaul Duffin
Previously, the prebuilt mutators were added by the cc.RegisterRequiredBuildComponentsForTest() function as a convenience but unfortunately it lead to some of the mutators being in a different order in the tests than in the normal build. This change: * Extracts the RegisterPrebuiltMutators() call from cc.RegisterRequiredBuildComponentsForTest() * Makes sure that the prebuilt mutators are registered before the visibility gatherer and enforcer mutators. Bug: 162505935 Test: m nothing Change-Id: I7d959b558200b502f0a5e4653c41ea01414e142a
2020-07-20Add SourceProviders and a rust_bindgen module typeIvan Lozano
Add SourceProvider modules which provides a base interface for more complex code generation usecases such as bindgen. Also adds the rust_bindgen module type which calls bindgen to generate Rust FFI bindings to C. Bug: 159064919 Test: Local test module generates bindings. Test: New Soong tests pass. Change-Id: Ie31467bbbe423497666ad837cf5fe1acd1e76bd8
2020-07-08Specify module dependency in the srcs listChih-Hung Hsieh
* "srcs" list contains one main Rust source file, followed by optional dependent modules. * A dependent module included in the "srcs" list is the module name prefixed with ":". * Add a simple test. Bug: 160331255 Test: make and manual test build dependencies on genrule modules Change-Id: I4f079138c2599158810b6412fce81b612a3f64a4
2020-07-01rust: Mutate prebuilt modules dylib/rlibMatthew Maurer
This change makes it possible to use a single module to provide both dylib and rlib varieties of a library. This allows the use of libstd and libtest from a rustlibs property, allowing linkage type to change for different variants. Bug: 159718669 Test: cd external crates; mma; m crosvm.experimental Change-Id: I477c4d2faec63703fdc6dd42ba020747d6a50714
2020-07-01rust: Change default variantsMatthew Maurer
rust_library now produces only rlib and dylib variants. rust_library_foreign now produces static and shared variants. This change was made because both are common cases, but all four together essentially never happens. This allows us to have fewer repeat module definitions. Bug: 143217452 Test: cd external/rust; mma Change-Id: Iaf69e8da38f7c12710331c51464699cf7cbbb656
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-11Add rust-project.json generatorThiébaud Weksteen
Because we are not relying on Cargo.toml for our crate dependencies, we need to provide a structured file to rust-analyzer which describes the locations of the crates. Add a generator for that purpose, similarly to cc/compdb and cc/ccdeps. Bug: 156395307 Test: SOONG_GEN_RUST_PROJECT=1 m nothing && \ cat ${ANDROID_BUILD_TOP}/out/soong/rust-project.json Change-Id: I46efe0adeddae281eaf86707504c3aa15b5e80b8
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
2020-04-29Provide 32-bit and 64-bit Rust libs by default.Ivan Lozano
CC libraries which depend on Rust libraries get missing dependency errors when building 32-bit variants dependent on Rust modules which don't explicitly have "multilib: both" declared. Because CC libraries use MultilibBoth by default, Rust should do the same. This also fixes a bug where the ARM32 toolchain incorrectly embedded toolchain64Bit instead of toolchain32Bit. Bug: 154730212 Test: Rust libraries provide both variants by default. Change-Id: Ia545fe069d3c6b77c3d18f4f10267e2c72ee0bab
2020-04-23Clean up rust tests.Ivan Lozano
The list of required deps for testing is a lot shorter as we no longer include as many prebuilt libraries and our list of stdlibs is much shorter. Remove the libraries we no longer need, and add the non-prebuilt libstd and libtest to the deps generated for every test. Bug: 153463188 Test: Soong tests pass. Change-Id: I94f7b514797ab8d6aedb543ea6afdb07611b7293
2019-12-19Dedup registration for cc default test configPaul Duffin
The cc.GatherRequiredDepsForTest() method returns some default module definitions that are required when using cc module types like cc_library. Previously, the registration of the module types and mutators needed to process those default definitions was duplicated in the test config initialization. This change removes that duplicated code and replaces it with calls to cc.RegisterRequiredBuildComponentsForTest(ctx) which registers all the required build components. Test: m checkbuild Bug: 146540677 Change-Id: I80b6913c5691ff164ce9d308b9e1da24940f2d42
2019-12-18Move filesystem into ConfigColin Cross
The filesystem object was available through ModuleContext.Fs(), but gives too much access to the filesystem without enforicing correct dependencies. In order to support sandboxing the soong_build process move the filesystem into the Config. The next change will make it private. Bug: 146437378 Test: all Soong tests Change-Id: I5d3ae9108f120fd335b21efd612aefa078378813
2019-12-06Move ImageMutator after archMutatorColin Cross
Move the ImageMutator to be registered just after the archMutator in preparation for moving it between osMutator and archMutator. Requries updating variants in a few tests that now run the ImageMutator. Bug: 142286466 Test: no change to build.ninja Test: all soong tests Change-Id: Ia9d2a7bc0e225bedec3c9a83ea04f471a931bf47
2019-11-25Merge changes I0dcc9c7b,I9bc40642Colin Cross
* changes: Move cc.imageMutator into the android package Make CreateVariations return []android.Module
2019-11-25Make TestContext.RegisterModuleType take an android.ModuleFactoryColin Cross
Avoid having to pass ModuleFactoryAdaptor to every call to RegisterModuleType in a test by wrapping RegisterModuleType. Test: all soong tests Change-Id: If8847d16487de0479cc3020b728256922b3cadba
2019-11-20Move cc.imageMutator into the android packageColin Cross
Prepare for making the image mutator available to all modules and moving it between the os and arch mutators by moving it into the android package and using an interface implemented by the module types to control it. Bug: 142286466 Test: No unexpected changes to out/soong/build.ninja Change-Id: I0dcc9c7b5ec80edffade340c367f6ae4da34151b
2019-10-29Add rust_test and rust_test_host.Chih-Hung Hsieh
* Rust tests are like binary files compiled with --test. New test.go follows binary.go code patterns and reuses some code in binary.go. * Generate one test per source file as testPerSrc in cc/test.go. The "all tests" variation feature of cc/test.go is not copied yet. Fix some Stem and SubName settings to make testPerSrc work. * Move cc.CheckDuplicate to android.CheckDuplicate, which is now shared by cc and rust. * Refactor tests in binary_test.go and add new test_test.go. Bug: 140938178 Test: mm in rust projects, added rust_test and rust_test_host Change-Id: Ia6fec8b4cf2572fd352ab1938a1f3c7b5cca2212
2019-10-28Add support for Rust C libraries.Ivan Lozano
Adds the ability for rust modules to be compiled as C libraries, and allows cc modules to depend on these rust-generated modules. This also means that soong-rust should not have any dependencies on soong-cc aside from what's required for testing. There's a couple small fixes included as well: - A bug in libNameFromFilePath that caused issues when library's had "lib" in their name. - VariantName is removed from rust library MutatedProperties since this was unused. Bug: 140726209 Test: Soong tests pass. Test: Example cc_binary can include a rust shared library as a dep. Test: m crosvm.experimental Change-Id: Ia7deed1345d2423001089014cc65ce7934123da4
2019-09-25Add Soong test for device proc-macro deps.Ivan Lozano
Ensure that devices can include proc_macros, which are host-only and may include host-only dependencies. Bug: 141491501 Test: Soong tests pass. Test: Test fails as expected when removing CL 1126496 Change-Id: I3ae7ab80283cd1fd4b800a533cb3205b3c108d45
2019-08-28Add Rust support to Soong.Ivan Lozano
Adds support to Soong for building rust modules. This currently only supports x86_64 device and x86 linux host targets. The functionality is sufficient to build crosvm. Bug: 136189233 Test: Test module builds. Test: crosvm builds. Change-Id: I6ea04615834a6d673578ab10ea1a2eb04259fe09