diff options
| author | 2021-02-25 03:28:06 +0000 | |
|---|---|---|
| committer | 2021-02-25 03:28:06 +0000 | |
| commit | 43354f9f2c221860700e3769e99c69dffc0bca7c (patch) | |
| tree | 601df071d0494eeea4d4a350932e31391170201a | |
| parent | e55301f472ab67a7ad50bcdcd53298ce399abae2 (diff) | |
| parent | 91d42e487df16e1ff6ca309d28f65d3fc392e1ae (diff) | |
Merge "libbinder_rs: Modify asserts to propagate failure to C++" am: f867ed2f2a am: 4fb0f92512 am: 91d42e487d
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1588098
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I6f1cbd371ea0aa50db884024e42cb3c3497512f4
| -rw-r--r-- | libs/binder/rust/tests/serialization.rs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/libs/binder/rust/tests/serialization.rs b/libs/binder/rust/tests/serialization.rs index 2bf3d03a4b..f1b068ee43 100644 --- a/libs/binder/rust/tests/serialization.rs +++ b/libs/binder/rust/tests/serialization.rs @@ -40,6 +40,41 @@ mod bindings { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); } +macro_rules! assert_eq { + ($left:expr, $right:expr $(,)?) => { + match (&$left, &$right) { + (left, right) => { + if *left != *right { + eprintln!( + "assertion failed: `{:?}` == `{:?}`, {}:{}:{}", + &*left, + &*right, + file!(), + line!(), + column!() + ); + return Err(StatusCode::FAILED_TRANSACTION); + } + } + } + }; +} + +macro_rules! assert { + ($expr:expr) => { + if !$expr { + eprintln!( + "assertion failed: `{:?}`, {}:{}:{}", + $expr, + file!(), + line!(), + column!() + ); + return Err(StatusCode::FAILED_TRANSACTION); + } + }; +} + static SERVICE_ONCE: Once = Once::new(); static mut SERVICE: Option<SpIBinder> = None; @@ -282,7 +317,7 @@ fn on_transact(_service: &dyn ReadParcelTest, code: TransactionCode, ))?; } bindings::Transaction_TEST_FAIL => { - return Err(StatusCode::FAILED_TRANSACTION) + assert!(false); } _ => return Err(StatusCode::UNKNOWN_TRANSACTION), } |