mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			ROTS: SysTimer: Fix test timing issues
Use a busy loop with non-blocking Semaphore::wait(0) calls instead of a single Semaphore::wait(osWaitForever) to improve time measurement accuracy. Looping in Semaphore::wait(0) prevents the board from entering sleep or deepsleep modes while waiting for the semaphore. By skipping the overhead wakeup time, we get more accurate timings.pull/9416/head
							parent
							
								
									284781a565
								
							
						
					
					
						commit
						5840281682
					
				| 
						 | 
				
			
			@ -245,7 +245,10 @@ void test_handler_called_once(void)
 | 
			
		|||
    int32_t sem_slots = st.sem_wait(0);
 | 
			
		||||
    TEST_ASSERT_EQUAL_INT32(0, sem_slots);
 | 
			
		||||
 | 
			
		||||
    sem_slots = st.sem_wait(osWaitForever);
 | 
			
		||||
    // Wait in a busy loop to prevent entering sleep or deepsleep modes.
 | 
			
		||||
    while (sem_slots != 1) {
 | 
			
		||||
        sem_slots = st.sem_wait(0);
 | 
			
		||||
    }
 | 
			
		||||
    us_timestamp_t t2 = st.get_time();
 | 
			
		||||
    TEST_ASSERT_EQUAL_INT32(1, sem_slots);
 | 
			
		||||
    TEST_ASSERT_EQUAL_UINT32(1, st.get_tick());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue