aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Vander Stoep <jeffv@google.com>2021-10-20 15:55:12 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-10-20 15:55:12 +0000
commitfc1cd6abed6c4840028565832ff515d1de180dab (patch)
treeb75fbd456f6f536b23f0c01d551e17d53b6c0859
parente26adbdb2cf86945c4131c66240c1df727e6cee7 (diff)
parent9836ee9ab7a51a7f126b093a176d6df1623992a3 (diff)
downloadonce_cell-fc1cd6abed6c4840028565832ff515d1de180dab.tar.gz
Enable tests am: 467ba80bf0 am: 734411c3a5 am: ebbeb81485 am: 9836ee9ab7
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/once_cell/+/1863717 Change-Id: I36224391409d6e49ea9baafc81faf2604f9a3a4e
-rw-r--r--Android.bp73
-rw-r--r--TEST_MAPPING17
-rw-r--r--cargo2android.json3
-rw-r--r--patches/imp_std.rs.patch20
-rw-r--r--patches/it.rs.patch36
-rw-r--r--src/imp_std.rs2
-rw-r--r--tests/it.rs4
7 files changed, 141 insertions, 14 deletions
diff --git a/Android.bp b/Android.bp
index 61ba14a..9073812 100644
--- a/Android.bp
+++ b/Android.bp
@@ -41,6 +41,8 @@ rust_library {
name: "libonce_cell",
host_supported: true,
crate_name: "once_cell",
+ cargo_env_compat: true,
+ cargo_pkg_version: "1.8.0",
srcs: ["src/lib.rs"],
edition: "2018",
features: [
@@ -57,3 +59,74 @@ rust_library {
],
min_sdk_version: "29",
}
+
+rust_defaults {
+ name: "once_cell_test_defaults",
+ crate_name: "once_cell",
+ srcs: ["src/lib.rs"],
+ cargo_env_compat: true,
+ cargo_pkg_version: "1.8.0",
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ edition: "2018",
+ features: [
+ "alloc",
+ "default",
+ "race",
+ "std",
+ ],
+ rustlibs: [
+ "libcrossbeam_utils",
+ "liblazy_static",
+ "libregex",
+ ],
+}
+
+rust_test_host {
+ name: "once_cell_host_test_src_lib",
+ defaults: ["once_cell_test_defaults"],
+ test_options: {
+ unit_test: true,
+ },
+}
+
+rust_test {
+ name: "once_cell_device_test_src_lib",
+ defaults: ["once_cell_test_defaults"],
+}
+
+rust_defaults {
+ name: "once_cell_test_defaults_it",
+ crate_name: "it",
+ srcs: ["tests/it.rs"],
+ cargo_env_compat: true,
+ cargo_pkg_version: "1.8.0",
+ test_suites: ["general-tests"],
+ auto_gen_config: true,
+ edition: "2018",
+ features: [
+ "alloc",
+ "default",
+ "race",
+ "std",
+ ],
+ rustlibs: [
+ "libcrossbeam_utils",
+ "liblazy_static",
+ "libonce_cell",
+ "libregex",
+ ],
+}
+
+rust_test_host {
+ name: "once_cell_host_test_tests_it",
+ defaults: ["once_cell_test_defaults_it"],
+ test_options: {
+ unit_test: true,
+ },
+}
+
+rust_test {
+ name: "once_cell_device_test_tests_it",
+ defaults: ["once_cell_test_defaults_it"],
+}
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 1e2fb88..8f658a8 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -2,15 +2,6 @@
{
"presubmit": [
{
- "name": "ZipFuseTest"
- },
- {
- "name": "apkdmverity.test"
- },
- {
- "name": "authfs_device_test_src_lib"
- },
- {
"name": "doh_unit_test"
},
{
@@ -29,7 +20,10 @@
"name": "libidsig.test"
},
{
- "name": "microdroid_manager_test"
+ "name": "once_cell_device_test_src_lib"
+ },
+ {
+ "name": "once_cell_device_test_tests_it"
},
{
"name": "quiche_device_test_src_lib"
@@ -90,9 +84,6 @@
"name": "thread_local_device_test_src_lib"
},
{
- "name": "virtualizationservice_device_test"
- },
- {
"name": "webpki_device_test_src_lib"
},
{
diff --git a/cargo2android.json b/cargo2android.json
index 4a1ad88..646ac59 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -8,5 +8,6 @@
"dependencies": true,
"device": true,
"min-sdk-version": "29",
- "run": true
+ "run": true,
+ "tests": true
}
diff --git a/patches/imp_std.rs.patch b/patches/imp_std.rs.patch
new file mode 100644
index 0000000..556297f
--- /dev/null
+++ b/patches/imp_std.rs.patch
@@ -0,0 +1,20 @@
+diff --git a/src/imp_std.rs b/src/imp_std.rs
+index d7dda96..f461c3d 100644
+--- a/src/imp_std.rs
++++ b/src/imp_std.rs
+@@ -299,6 +299,7 @@ mod tests {
+ }
+
+ #[test]
++ #[cfg(not(target_os = "android"))]
+ fn poison_bad() {
+ static O: OnceCell<()> = OnceCell::new();
+
+@@ -320,6 +321,7 @@ mod tests {
+ }
+
+ #[test]
++ #[cfg(not(target_os = "android"))]
+ fn wait_for_force_to_finish() {
+ static O: OnceCell<()> = OnceCell::new();
+
diff --git a/patches/it.rs.patch b/patches/it.rs.patch
new file mode 100644
index 0000000..8491db5
--- /dev/null
+++ b/patches/it.rs.patch
@@ -0,0 +1,36 @@
+diff --git a/tests/it.rs b/tests/it.rs
+index 81faaff..c769487 100644
+--- a/tests/it.rs
++++ b/tests/it.rs
+@@ -166,6 +166,7 @@ mod unsync {
+
+ #[test]
+ #[cfg(feature = "std")]
++ #[cfg(not(target_os = "android"))]
+ fn lazy_poisoning() {
+ let x: Lazy<String> = Lazy::new(|| panic!("kaboom"));
+ for _ in 0..2 {
+@@ -288,6 +289,7 @@ mod sync {
+ }
+
+ #[test]
++ #[cfg(not(target_os = "android"))]
+ fn get_or_try_init() {
+ let cell: OnceCell<String> = OnceCell::new();
+ assert!(cell.get().is_none());
+@@ -348,6 +350,7 @@ mod sync {
+
+ #[test]
+ #[cfg_attr(miri, ignore)] // miri doesn't support processes
++ #[ignore = "Android: ignore for now. Need to compile these binaries separately."]
+ fn reentrant_init() {
+ let examples_dir = {
+ let mut exe = std::env::current_exe().unwrap();
+@@ -486,6 +489,7 @@ mod sync {
+ }
+
+ #[test]
++ #[cfg(not(target_os = "android"))]
+ fn lazy_poisoning() {
+ let x: Lazy<String> = Lazy::new(|| panic!("kaboom"));
+ for _ in 0..2 {
diff --git a/src/imp_std.rs b/src/imp_std.rs
index d7dda96..f461c3d 100644
--- a/src/imp_std.rs
+++ b/src/imp_std.rs
@@ -299,6 +299,7 @@ mod tests {
}
#[test]
+ #[cfg(not(target_os = "android"))]
fn poison_bad() {
static O: OnceCell<()> = OnceCell::new();
@@ -320,6 +321,7 @@ mod tests {
}
#[test]
+ #[cfg(not(target_os = "android"))]
fn wait_for_force_to_finish() {
static O: OnceCell<()> = OnceCell::new();
diff --git a/tests/it.rs b/tests/it.rs
index 81faaff..c769487 100644
--- a/tests/it.rs
+++ b/tests/it.rs
@@ -166,6 +166,7 @@ mod unsync {
#[test]
#[cfg(feature = "std")]
+ #[cfg(not(target_os = "android"))]
fn lazy_poisoning() {
let x: Lazy<String> = Lazy::new(|| panic!("kaboom"));
for _ in 0..2 {
@@ -288,6 +289,7 @@ mod sync {
}
#[test]
+ #[cfg(not(target_os = "android"))]
fn get_or_try_init() {
let cell: OnceCell<String> = OnceCell::new();
assert!(cell.get().is_none());
@@ -348,6 +350,7 @@ mod sync {
#[test]
#[cfg_attr(miri, ignore)] // miri doesn't support processes
+ #[ignore = "Android: ignore for now. Need to compile these binaries separately."]
fn reentrant_init() {
let examples_dir = {
let mut exe = std::env::current_exe().unwrap();
@@ -486,6 +489,7 @@ mod sync {
}
#[test]
+ #[cfg(not(target_os = "android"))]
fn lazy_poisoning() {
let x: Lazy<String> = Lazy::new(|| panic!("kaboom"));
for _ in 0..2 {