Separate host and device tests
* To enable multilib for rust_test on device,
but not for rust_test_host yet.
Host tests depend on proc-macro2 library,
which does not build for multilib on host yet.
* On device tests must link in static libraries
since their .so versions are not installed
in system/lib* yet.
Bug: 158677299
Test: mm in external/rust/crates
Test: atest -c --include-subdirs external/rust/crates
Change-Id: I017dfd2f56b1b9fa0e213c04fa8eadf738bfecae
diff --git a/Android.bp b/Android.bp
index 4259231..fa70099 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,6 @@
// This file is generated by cargo2android.py --run --device --test.
+// Manually split host and device tests,
+// and link in static libraries for device tests.
rust_library_rlib {
name: "libpin_utils",
@@ -10,7 +12,6 @@
rust_defaults {
name: "pin-utils_tests",
- host_supported: true,
crate_name: "pin_utils",
test_suites: ["general-tests"],
auto_gen_config: true,
@@ -20,8 +21,8 @@
],
}
-rust_test {
- name: "pin-utils_tests_stack_pin",
+rust_test_host {
+ name: "pin-utils_host_tests_stack_pin",
defaults: ["pin-utils_tests"],
srcs: [
"tests/stack_pin.rs",
@@ -29,7 +30,20 @@
}
rust_test {
- name: "pin-utils_tests_projection",
+ name: "pin-utils_device_tests_stack_pin",
+ defaults: ["pin-utils_tests"],
+ srcs: [
+ "tests/stack_pin.rs",
+ ],
+ rlibs: [
+ "libstd.static",
+ "libtest.static",
+ "libterm.static",
+ ],
+}
+
+rust_test_host {
+ name: "pin-utils_host_tests_projection",
defaults: ["pin-utils_tests"],
srcs: [
"tests/projection.rs",
@@ -37,11 +51,37 @@
}
rust_test {
- name: "pin-utils_tests_pin_utils",
- host_supported: true,
+ name: "pin-utils_device_tests_projection",
+ defaults: ["pin-utils_tests"],
+ srcs: [
+ "tests/projection.rs",
+ ],
+ rlibs: [
+ "libstd.static",
+ "libtest.static",
+ "libterm.static",
+ ],
+}
+
+rust_test_host {
+ name: "pin-utils_host_tests_pin_utils",
crate_name: "pin_utils",
srcs: ["src/lib.rs"],
test_suites: ["general-tests"],
auto_gen_config: true,
edition: "2018",
}
+
+rust_test {
+ name: "pin-utils_device_tests_pin_utils",
+ crate_name: "pin_utils",
+ srcs: ["src/lib.rs"],
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ edition: "2018",
+ rlibs: [
+ "libstd.static",
+ "libtest.static",
+ "libterm.static",
+ ],
+}
diff --git a/TEST_MAPPING b/TEST_MAPPING
index a30a86c..dc91f3a 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,24 +1,24 @@
{
"presubmit": [
{
- "name": "pin-utils_tests_projection"
+ "name": "pin-utils_device_tests_projection"
},
{
- "name": "pin-utils_tests_projection",
+ "name": "pin-utils_host_tests_projection",
"host": true
},
{
- "name": "pin-utils_tests_stack_pin"
+ "name": "pin-utils_device_tests_stack_pin"
},
{
- "name": "pin-utils_tests_stack_pin",
+ "name": "pin-utils_host_tests_stack_pin",
"host": true
},
{
- "name": "pin-utils_tests_pin_utils"
+ "name": "pin-utils_device_tests_pin_utils"
},
{
- "name": "pin-utils_tests_pin_utils",
+ "name": "pin-utils_host_tests_pin_utils",
"host": true
}
]