mirror of https://github.com/ARMmbed/mbed-os.git
Fixing issue in timing host test and wait_us case
The timing host tests reported success even if the total drift was negative. This adds a check for this now. The wait_us test now does not use a timer and just waits for 100000 us between prints. This adds inherent drift, but it should still be well under the limit.pull/2588/head
parent
4f4112b18e
commit
1473240637
|
|
@ -88,7 +88,7 @@ class TimingDriftTest(BaseHostTest):
|
|||
self.average_drift_max))
|
||||
|
||||
|
||||
if self.total_drift > self.total_drift_max:
|
||||
if abs(self.total_drift) > self.total_drift_max:
|
||||
if print_stats:
|
||||
self.log("FAIL: Total drift exceeded max total drift")
|
||||
self.__result = False
|
||||
|
|
|
|||
|
|
@ -18,31 +18,25 @@
|
|||
#include "greentea-client/test_env.h"
|
||||
#include "utest/utest.h"
|
||||
|
||||
/**
|
||||
NOTE: This test will have a bit of inherent drift due to it being
|
||||
single-threaded, so having a drift that is non-zero should be ok. However,
|
||||
it should still be well under the limit.
|
||||
**/
|
||||
|
||||
|
||||
using namespace utest::v1;
|
||||
|
||||
DigitalOut led(LED1);
|
||||
Timer timer;
|
||||
volatile bool print_tick = false;
|
||||
const int ONE_SECOND_US = 1000000;
|
||||
const int total_ticks = 10;
|
||||
|
||||
void test_case_ticker() {
|
||||
int start_time;
|
||||
int after_print_us;
|
||||
int wait_time_us = ONE_SECOND_US;
|
||||
|
||||
timer.start();
|
||||
start_time = timer.read();
|
||||
int i = 0;
|
||||
while (i <= total_ticks) {
|
||||
wait_us(wait_time_us);
|
||||
void test_case_ticker() {
|
||||
for (int i = 0; i <= total_ticks; i++) {
|
||||
wait_us(ONE_SECOND_US);
|
||||
greentea_send_kv("tick", i);
|
||||
after_print_us = timer.read();
|
||||
|
||||
// This won't be 100% exact, but it should be very close
|
||||
wait_time_us = after_print_us - start_time - ((++i) * ONE_SECOND_US);
|
||||
}
|
||||
timer.stop();
|
||||
}
|
||||
|
||||
// Test cases
|
||||
|
|
|
|||
Loading…
Reference in New Issue