diff options
author | Jakub Kotur <qtr@google.com> | 2021-03-18 15:00:41 +0100 |
---|---|---|
committer | Jakub Kotur <qtr@google.com> | 2021-04-16 17:14:50 +0200 |
commit | 3276f603fd08b3f66d8187945ebf50b117ad1aa0 (patch) | |
tree | daaf08af737e70ccff84d0af339162a544fead0a | |
parent | 2e9962829e53f12a4abaf17fe77715bd9858ae7c (diff) | |
download | crossbeam-utils-3276f603fd08b3f66d8187945ebf50b117ad1aa0.tar.gz |
Enable tests for corssbeam-utils.android-s-beta-2android-s-beta-1
This commit enable tests for both host and device. However, because
some tests are depending on the stack unwinding on panic we're disabling
those on Android. Android always aborts on panic.
Test: atest
Bug: 155309706
Change-Id: Id72bc131efbc555c6ffa4732e6ce242ac9036025
-rw-r--r-- | Android.bp | 171 | ||||
-rw-r--r-- | TEST_MAPPING | 24 | ||||
-rw-r--r-- | patches/disable_panic_tests_on_android.patch | 103 | ||||
-rw-r--r-- | tests/sharded_lock.rs | 14 | ||||
-rw-r--r-- | tests/thread.rs | 8 |
5 files changed, 314 insertions, 6 deletions
@@ -1,4 +1,4 @@ -// This file is generated by cargo2android.py --run --device --dependencies. +// This file is generated by cargo2android.py --run --device --dependencies --tests. // Do not modify this file as changes will be overridden on upgrade. package { @@ -39,6 +39,159 @@ license { ], } +rust_defaults { + name: "crossbeam-utils_defaults", + crate_name: "crossbeam_utils", + srcs: ["src/lib.rs"], + test_suites: ["general-tests"], + auto_gen_config: true, + edition: "2018", + features: [ + "default", + "lazy_static", + "std", + ], + cfgs: [ + "has_atomic_u16", + "has_atomic_u32", + "has_atomic_u64", + "has_atomic_u8", + ], + rustlibs: [ + "libcfg_if", + "liblazy_static", + "librand", + ], +} + +rust_test_host { + name: "crossbeam-utils_host_test_src_lib", + defaults: ["crossbeam-utils_defaults"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "crossbeam-utils_device_test_src_lib", + defaults: ["crossbeam-utils_defaults"], +} + +rust_defaults { + name: "crossbeam-utils_defaults_crossbeam_utils", + crate_name: "crossbeam_utils", + test_suites: ["general-tests"], + auto_gen_config: true, + edition: "2018", + features: [ + "default", + "lazy_static", + "std", + ], + cfgs: [ + "has_atomic_u16", + "has_atomic_u32", + "has_atomic_u64", + "has_atomic_u8", + ], + rustlibs: [ + "libcfg_if", + "libcrossbeam_utils", + "liblazy_static", + "librand", + ], +} + +rust_test_host { + name: "crossbeam-utils_host_test_tests_atomic_cell", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/atomic_cell.rs"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "crossbeam-utils_device_test_tests_atomic_cell", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/atomic_cell.rs"], +} + +rust_test_host { + name: "crossbeam-utils_host_test_tests_cache_padded", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/cache_padded.rs"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "crossbeam-utils_device_test_tests_cache_padded", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/cache_padded.rs"], +} + +rust_test_host { + name: "crossbeam-utils_host_test_tests_parker", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/parker.rs"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "crossbeam-utils_device_test_tests_parker", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/parker.rs"], +} + +rust_test_host { + name: "crossbeam-utils_host_test_tests_sharded_lock", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/sharded_lock.rs"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "crossbeam-utils_device_test_tests_sharded_lock", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/sharded_lock.rs"], +} + +rust_test_host { + name: "crossbeam-utils_host_test_tests_thread", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/thread.rs"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "crossbeam-utils_device_test_tests_thread", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/thread.rs"], +} + +rust_test_host { + name: "crossbeam-utils_host_test_tests_wait_group", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/wait_group.rs"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "crossbeam-utils_device_test_tests_wait_group", + defaults: ["crossbeam-utils_defaults_crossbeam_utils"], + srcs: ["tests/wait_group.rs"], +} + rust_library { name: "libcrossbeam_utils", host_supported: true, @@ -50,11 +203,11 @@ rust_library { "lazy_static", "std", ], - flags: [ - "--cfg has_atomic_u16", - "--cfg has_atomic_u32", - "--cfg has_atomic_u64", - "--cfg has_atomic_u8", + cfgs: [ + "has_atomic_u16", + "has_atomic_u32", + "has_atomic_u64", + "has_atomic_u8", ], rustlibs: [ "libcfg_if", @@ -65,4 +218,10 @@ rust_library { // dependent_library ["feature_list"] // autocfg-1.0.1 // cfg-if-1.0.0 +// getrandom-0.2.2 "std" // lazy_static-1.4.0 +// libc-0.2.93 +// ppv-lite86-0.2.10 "simd,std" +// rand-0.8.3 "alloc,default,getrandom,libc,rand_chacha,rand_hc,std,std_rng" +// rand_chacha-0.3.0 "std" +// rand_core-0.6.2 "alloc,getrandom,std" diff --git a/TEST_MAPPING b/TEST_MAPPING index 25a9cdc..a68b776 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -3,6 +3,30 @@ "presubmit": [ { "name": "crossbeam-epoch_device_test_src_lib" + }, + { + "name": "crossbeam-epoch_device_test_tests_loom" + }, + { + "name": "crossbeam-utils_device_test_src_lib" + }, + { + "name": "crossbeam-utils_device_test_tests_atomic_cell" + }, + { + "name": "crossbeam-utils_device_test_tests_cache_padded" + }, + { + "name": "crossbeam-utils_device_test_tests_parker" + }, + { + "name": "crossbeam-utils_device_test_tests_sharded_lock" + }, + { + "name": "crossbeam-utils_device_test_tests_thread" + }, + { + "name": "crossbeam-utils_device_test_tests_wait_group" } ] } diff --git a/patches/disable_panic_tests_on_android.patch b/patches/disable_panic_tests_on_android.patch new file mode 100644 index 0000000..49e4758 --- /dev/null +++ b/patches/disable_panic_tests_on_android.patch @@ -0,0 +1,103 @@ +--- tests/sharded_lock.rs ++++ tests/sharded_lock.rs +@@ -46,6 +46,8 @@ fn frob() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn arc_poison_wr() { + let arc = Arc::new(ShardedLock::new(1)); + let arc2 = arc.clone(); +@@ -58,6 +60,8 @@ fn arc_poison_wr() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn arc_poison_ww() { + let arc = Arc::new(ShardedLock::new(1)); + assert!(!arc.is_poisoned()); +@@ -72,6 +76,8 @@ fn arc_poison_ww() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn arc_no_poison_rr() { + let arc = Arc::new(ShardedLock::new(1)); + let arc2 = arc.clone(); +@@ -84,6 +90,8 @@ fn arc_no_poison_rr() { + assert_eq!(*lock, 1); + } + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn arc_no_poison_sl() { + let arc = Arc::new(ShardedLock::new(1)); + let arc2 = arc.clone(); +@@ -135,6 +143,8 @@ fn arc() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn arc_access_in_unwind() { + let arc = Arc::new(ShardedLock::new(1)); + let arc2 = arc.clone(); +@@ -211,6 +221,8 @@ fn test_into_inner_drop() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn test_into_inner_poison() { + let m = Arc::new(ShardedLock::new(NonCopy(10))); + let m2 = m.clone(); +@@ -235,6 +247,8 @@ fn test_get_mut() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn test_get_mut_poison() { + let m = Arc::new(ShardedLock::new(NonCopy(10))); + let m2 = m.clone(); +--- tests/thread.rs ++++ tests/thread.rs +@@ -9,6 +9,8 @@ const THREADS: usize = 10; + const SMALL_STACK_SIZE: usize = 20; + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn join() { + let counter = AtomicUsize::new(0); + thread::scope(|scope| { +@@ -64,6 +66,8 @@ fn counter_builder() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn counter_panic() { + let counter = AtomicUsize::new(0); + let result = thread::scope(|scope| { +@@ -84,6 +88,8 @@ fn counter_panic() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn panic_twice() { + let result = thread::scope(|scope| { + scope.spawn(|_| { +@@ -108,6 +114,8 @@ fn panic_twice() { + } + + #[test] ++// Android aborts on panic and this test relies on stack unwinding. ++#[cfg(not(target_os = "android"))] + fn panic_many() { + let result = thread::scope(|scope| { + scope.spawn(|_| panic!("deliberate panic #1")); diff --git a/tests/sharded_lock.rs b/tests/sharded_lock.rs index c362154..b4b8565 100644 --- a/tests/sharded_lock.rs +++ b/tests/sharded_lock.rs @@ -46,6 +46,8 @@ fn frob() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn arc_poison_wr() { let arc = Arc::new(ShardedLock::new(1)); let arc2 = arc.clone(); @@ -58,6 +60,8 @@ fn arc_poison_wr() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn arc_poison_ww() { let arc = Arc::new(ShardedLock::new(1)); assert!(!arc.is_poisoned()); @@ -72,6 +76,8 @@ fn arc_poison_ww() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn arc_no_poison_rr() { let arc = Arc::new(ShardedLock::new(1)); let arc2 = arc.clone(); @@ -84,6 +90,8 @@ fn arc_no_poison_rr() { assert_eq!(*lock, 1); } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn arc_no_poison_sl() { let arc = Arc::new(ShardedLock::new(1)); let arc2 = arc.clone(); @@ -135,6 +143,8 @@ fn arc() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn arc_access_in_unwind() { let arc = Arc::new(ShardedLock::new(1)); let arc2 = arc.clone(); @@ -208,6 +218,8 @@ fn test_into_inner_drop() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn test_into_inner_poison() { let m = Arc::new(ShardedLock::new(NonCopy(10))); let m2 = m.clone(); @@ -232,6 +244,8 @@ fn test_get_mut() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn test_get_mut_poison() { let m = Arc::new(ShardedLock::new(NonCopy(10))); let m2 = m.clone(); diff --git a/tests/thread.rs b/tests/thread.rs index 0dfad90..280b73f 100644 --- a/tests/thread.rs +++ b/tests/thread.rs @@ -9,6 +9,8 @@ const THREADS: usize = 10; const SMALL_STACK_SIZE: usize = 20; #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn join() { let counter = AtomicUsize::new(0); thread::scope(|scope| { @@ -64,6 +66,8 @@ fn counter_builder() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn counter_panic() { let counter = AtomicUsize::new(0); let result = thread::scope(|scope| { @@ -84,6 +88,8 @@ fn counter_panic() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn panic_twice() { let result = thread::scope(|scope| { scope.spawn(|_| { @@ -108,6 +114,8 @@ fn panic_twice() { } #[test] +// Android aborts on panic and this test relies on stack unwinding. +#[cfg(not(target_os = "android"))] fn panic_many() { let result = thread::scope(|scope| { scope.spawn(|_| panic!("deliberate panic #1")); |