From 6fc80d6348df26178aef6e2092b32b90fde6a272 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Mon, 1 Feb 2021 13:23:23 -0800 Subject: Do not test panic capture in Rust. We have switched panic strategy to abort rather than unwind. This prevents the previously tested behavior from working correctly. Bug: 178577888 Test: atest rustBinderSerializationTest Change-Id: I0ab1ed86ed1264054f43a9655185496d9c8b6328 --- libs/binder/rust/tests/serialization.rs | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/libs/binder/rust/tests/serialization.rs b/libs/binder/rust/tests/serialization.rs index 2ae13f4dd8..2bf3d03a4b 100644 --- a/libs/binder/rust/tests/serialization.rs +++ b/libs/binder/rust/tests/serialization.rs @@ -25,7 +25,6 @@ use binder::{ use binder::parcel::ParcelFileDescriptor; use std::ffi::{c_void, CStr, CString}; -use std::panic::{self, AssertUnwindSafe}; use std::sync::Once; #[allow( @@ -73,22 +72,9 @@ impl ReadParcelTest for BpReadParcelTest {} impl ReadParcelTest for () {} -fn on_transact( - _service: &dyn ReadParcelTest, - code: TransactionCode, - parcel: &Parcel, - reply: &mut Parcel, -) -> Result<()> { - panic::catch_unwind(AssertUnwindSafe(|| transact_inner(code, parcel, reply))).unwrap_or_else( - |e| { - eprintln!("Failure in Rust: {:?}", e.downcast_ref::()); - Err(StatusCode::FAILED_TRANSACTION) - }, - ) -} - #[allow(clippy::float_cmp)] -fn transact_inner(code: TransactionCode, parcel: &Parcel, reply: &mut Parcel) -> Result<()> { +fn on_transact(_service: &dyn ReadParcelTest, code: TransactionCode, + parcel: &Parcel, reply: &mut Parcel) -> Result<()> { match code { bindings::Transaction_TEST_BOOL => { assert_eq!(parcel.read::()?, true); @@ -296,7 +282,7 @@ fn transact_inner(code: TransactionCode, parcel: &Parcel, reply: &mut Parcel) -> ))?; } bindings::Transaction_TEST_FAIL => { - panic!("Testing expected failure"); + return Err(StatusCode::FAILED_TRANSACTION) } _ => return Err(StatusCode::UNKNOWN_TRANSACTION), } -- cgit v1.2.3-59-g8ed1b