diff options
author | Ante <cante@google.com> | 2022-10-03 23:13:23 +0000 |
---|---|---|
committer | Ante Culo <cante@google.com> | 2022-10-03 23:26:54 +0000 |
commit | 4643301d30aeef2238f6b32ee5646385f60de173 (patch) | |
tree | 747cbf1226cef9b2e5ed830ece58964893f18cc0 /src/rust/uci/mod.rs | |
parent | ea9d9d1e423d36d54500e1b2c05ce952c8b99bbe (diff) | |
download | uwb-4643301d30aeef2238f6b32ee5646385f60de173.tar.gz |
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
Diffstat (limited to 'src/rust/uci/mod.rs')
-rw-r--r-- | src/rust/uci/mod.rs | 10 |
1 files changed, 2 insertions, 8 deletions
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(); } |