Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6fc80d63 authored by Matthew Maurer's avatar Matthew Maurer
Browse files

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
parent bcb89efe
Loading
Loading
Loading
Loading
+3 −17
Original line number Diff line number Diff line
@@ -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::<String>());
            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::<bool>()?, 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),
    }