From f5d74d4e9cb8cd40ae7b5a1b834b69f8347d0e02 Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Tue, 30 Aug 2022 14:37:43 +0530 Subject: [PATCH] gpio: Update test's while loop to avoid test failure The "test_gpio_process_events_multi_success" test currently hangs with an update to a newer version of Rust. The code here tries to read the value, locked, for each GPIO one by one. The values are updated in another thread with the help of write lock. More discussion around this issue can be found here. https://github.com/rust-lang/rust/issues/101194 Taking the lock only once fixes it for now. Signed-off-by: Viresh Kumar --- gpio/src/vhu_gpio.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gpio/src/vhu_gpio.rs b/gpio/src/vhu_gpio.rs index ae09ef0..f9f206b 100644 --- a/gpio/src/vhu_gpio.rs +++ b/gpio/src/vhu_gpio.rs @@ -929,10 +929,13 @@ mod tests { backend.process_events(desc_chains.clone(), &vring).unwrap(); - while backend.handles.read().unwrap()[GPIO as usize].is_some() - || backend.handles.read().unwrap()[(GPIO + 1) as usize].is_some() - || backend.handles.read().unwrap()[(GPIO + 2) as usize].is_some() - {} + while { + let h = backend.handles.read().unwrap(); + + h[GPIO as usize].is_some() + || h[(GPIO + 1) as usize].is_some() + || h[(GPIO + 2) as usize].is_some() + } {} validate_desc_chains(desc_chains, VIRTIO_GPIO_IRQ_STATUS_VALID, None); }