From 4643301d30aeef2238f6b32ee5646385f60de173 Mon Sep 17 00:00:00 2001 From: Ante Date: Mon, 3 Oct 2022 23:13:23 +0000 Subject: Fix flaky test_deinitialize in uwb_uci_rust_tests This fixes a race condition where multiple UwbEvents CLOSE_CPLT were sent to hal at the same time. In cases where the wrong call got executed first, the list of expected events in mock_adaptation object weren't properly cleared. This caused assert!(self.expected_calls.lock().unwrap().is_empty()) implemented on Drop to fail. This fix removes the second unnecessary call to hal with CLOSE_CPLT since the same call will be made by calling dispatcher.send_jni_command(JNICommand::Disable(true).. after properly clearing the expected calls list. Bug: 250003544 Test: atest libuwb_uci_rust_tests --retry-until-failure 20 Change-Id: I675519deb74b930d65f68c77a6e079cfa3c3f06c --- src/rust/uci/mod.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/rust/uci/mod.rs') diff --git a/src/rust/uci/mod.rs b/src/rust/uci/mod.rs index 116d03e..3458fc5 100644 --- a/src/rust/uci/mod.rs +++ b/src/rust/uci/mod.rs @@ -674,19 +674,13 @@ mod tests { #[test] fn test_deinitialize() { - let (mut dispatcher, hal_sender) = + let (mut dispatcher, _hal_sender) = setup_dispatcher_and_return_hal_cb_sender(|mock_adaptation, _mock_event_manager| { mock_adaptation.expect_hal_close(Ok(())); }); let chip_id = String::from("chip_id"); - dispatcher.send_jni_command(JNICommand::Disable(true), chip_id.clone()).unwrap(); - hal_sender - .send(( - HalCallback::Event { event: UwbEvent::CLOSE_CPLT, event_status: UwbStatus::OK }, - chip_id, - )) - .unwrap(); + dispatcher.send_jni_command(JNICommand::Disable(true), chip_id).unwrap(); dispatcher.wait_for_exit().unwrap(); } -- cgit v1.2.3