fix: RESET pin active-LOW and clock edge state reset
This commit is contained in:
parent
1cf2cd6e2b
commit
c9f39aa600
12 changed files with 520 additions and 327 deletions
|
|
@ -33,6 +33,7 @@ mod gui_integration_test_utils {
|
|||
}
|
||||
|
||||
/// Simulate GUI state updates over time
|
||||
/// Note: This function acquires the lock internally. Do NOT call it while holding the lock.
|
||||
pub fn simulate_gui_updates(system: &Arc<Mutex<ConfigurableSystem>>) {
|
||||
// Simulate the kind of updates that would happen in the GUI thread
|
||||
if let Ok(system_guard) = system.lock() {
|
||||
|
|
@ -47,24 +48,17 @@ mod gui_integration_test_utils {
|
|||
|
||||
// Spawn a thread that accesses the system
|
||||
let handle = thread::spawn(move || {
|
||||
if let Ok(system_guard) = system_clone.lock() {
|
||||
system_guard.is_running()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
// Try to acquire the lock - return true if successful (regardless of is_running value)
|
||||
system_clone.lock().is_ok()
|
||||
});
|
||||
|
||||
// Main thread also accesses the system
|
||||
let main_thread_result = if let Ok(system_guard) = system.lock() {
|
||||
system_guard.is_running()
|
||||
} else {
|
||||
false
|
||||
};
|
||||
let main_thread_result = system.lock().is_ok();
|
||||
|
||||
// Wait for spawned thread
|
||||
let spawned_thread_result = handle.join().unwrap_or(false);
|
||||
|
||||
// Both threads should be able to access without deadlock
|
||||
// Both threads should be able to acquire the lock without deadlock
|
||||
main_thread_result && spawned_thread_result
|
||||
}
|
||||
}
|
||||
|
|
@ -309,15 +303,18 @@ mod gui_system_integration_tests {
|
|||
println!("Starting test_gui_performance_characteristics");
|
||||
let system = create_test_system();
|
||||
|
||||
// Test GUI update performance characteristics
|
||||
// Test GUI update performance characteristics with timeout protection
|
||||
let start_time = std::time::Instant::now();
|
||||
let timeout = Duration::from_secs(5); // 5 second timeout
|
||||
|
||||
for _ in 0..100 {
|
||||
{
|
||||
let _system_guard = system.lock().unwrap();
|
||||
// Simulate GUI state update
|
||||
simulate_gui_updates(&system);
|
||||
} // _system_guard is dropped here
|
||||
// Check for timeout to prevent test from hanging indefinitely
|
||||
if start_time.elapsed() > timeout {
|
||||
panic!("Test timed out after {:?} - possible deadlock", timeout);
|
||||
}
|
||||
|
||||
// simulate_gui_updates acquires its own lock - do not hold lock while calling
|
||||
simulate_gui_updates(&system);
|
||||
}
|
||||
|
||||
let elapsed = start_time.elapsed();
|
||||
|
|
@ -506,15 +503,18 @@ mod gui_real_time_tests {
|
|||
fn test_gui_state_update_frequency() {
|
||||
let system = create_test_system();
|
||||
|
||||
// Test that GUI can handle high-frequency state updates
|
||||
// Test that GUI can handle high-frequency state updates with timeout protection
|
||||
let start_time = std::time::Instant::now();
|
||||
let timeout = Duration::from_secs(5); // 5 second timeout
|
||||
|
||||
for _ in 0..50 {
|
||||
{
|
||||
let _system_guard = system.lock().unwrap();
|
||||
// Simulate rapid GUI updates
|
||||
simulate_gui_updates(&system);
|
||||
} // _system_guard is dropped here
|
||||
// Check for timeout to prevent test from hanging indefinitely
|
||||
if start_time.elapsed() > timeout {
|
||||
panic!("Test timed out after {:?} - possible deadlock", timeout);
|
||||
}
|
||||
|
||||
// simulate_gui_updates acquires its own lock - do not hold lock while calling
|
||||
simulate_gui_updates(&system);
|
||||
}
|
||||
|
||||
let elapsed = start_time.elapsed();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue