diff options
author | Ante <cante@google.com> | 2022-10-07 20:26:02 +0000 |
---|---|---|
committer | Ante <cante@google.com> | 2022-10-07 20:26:02 +0000 |
commit | e97cea612728df25b8ba0b2d2f3ef7bd9e396faa (patch) | |
tree | fe2808453c989572e7d07d2e1a090eb5a7411003 /src/rust/uci/mod.rs | |
parent | 9761f8086c31407bc4c6f3f1dff529c00e82275a (diff) | |
download | uwb-e97cea612728df25b8ba0b2d2f3ef7bd9e396faa.tar.gz |
Fix flaky test test_hal_error_event
This test would fail on average every 2nd run when ran on a device. This
was due to a race condition between UwbEvent::ERROR event and the test method
dropping and thus invoking
assert!(self.expected_calls.lock().unwrap().is_empty()) from
mock_adaptation Drop too early.
To fix it I sent another event UwbEvent::CLOSE_CPLT at the end which is
processed only after the ERROR event, and since sending CLOSE_CPLT event
exits the dispatcher this enables calling
dispatcher.wait_for_exit() which then makes sure the test method doesn't
drop before both events get processed.
Bug: 251879446
Test: atest libuwb_uci_rust_tests --rerun-until-failure 20
Change-Id: If30794d6cff3c0130b4675af0eead27777803df8
Diffstat (limited to 'src/rust/uci/mod.rs')
-rw-r--r-- | src/rust/uci/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rust/uci/mod.rs b/src/rust/uci/mod.rs index 3458fc5..b9a8b23 100644 --- a/src/rust/uci/mod.rs +++ b/src/rust/uci/mod.rs @@ -655,7 +655,7 @@ mod tests { #[test] fn test_hal_error_event() { - let (dispatcher, hal_sender) = + let (mut dispatcher, hal_sender) = setup_dispatcher_and_return_hal_cb_sender(|mock_adaptation, mock_event_manager| { mock_adaptation.expect_hal_open(Ok(())); mock_adaptation.expect_core_initialization(Ok(())); @@ -667,9 +667,16 @@ mod tests { hal_sender .send(( HalCallback::Event { event: UwbEvent::ERROR, event_status: UwbStatus::FAILED }, + chip_id.clone(), + )) + .unwrap(); + hal_sender + .send(( + HalCallback::Event { event: UwbEvent::CLOSE_CPLT, event_status: UwbStatus::OK }, chip_id, )) .unwrap(); + dispatcher.wait_for_exit().unwrap(); } #[test] |