mirror of https://github.com/ARMmbed/mbed-os.git
Added us Timer proper host test automation
parent
3e809741f7
commit
d07ed138b2
|
@ -18,12 +18,22 @@ DigitalOut out(p5);
|
||||||
|
|
||||||
DigitalOut led(LED1);
|
DigitalOut led(LED1);
|
||||||
|
|
||||||
int main() {
|
#define MS_INTERVALS 1000
|
||||||
printf("Hello World\n");
|
|
||||||
|
|
||||||
|
void print_char(char c = '*')
|
||||||
|
{
|
||||||
|
printf("%c", c);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
while (true) {
|
while (true) {
|
||||||
wait_us(1000);
|
for (int i = 0; i < MS_INTERVALS; i++)
|
||||||
out = !out;
|
{
|
||||||
|
wait_us(1000);
|
||||||
|
out = !out;
|
||||||
|
}
|
||||||
led = !led;
|
led = !led;
|
||||||
|
print_char();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,17 +34,17 @@ class WaitusTest(DefaultTest):
|
||||||
c = self.mbed.serial.read(1)
|
c = self.mbed.serial.read(1)
|
||||||
if i > 2: # we will ignore first few measurements
|
if i > 2: # we will ignore first few measurements
|
||||||
delta = time() - start
|
delta = time() - start
|
||||||
deviation = abs(delta - 1)
|
deviation = abs(delta - 1)
|
||||||
deviation_ok = True if delta > 0 and deviation <= 0.5 else False # +/-5%
|
deviation_ok = True if delta > 0 and deviation <= 0.5 else False # +/-5%
|
||||||
test_result = test_result and deviation_ok
|
test_result = test_result and deviation_ok
|
||||||
msg = "OK" if deviation_ok else "FAIL"
|
msg = "OK" if deviation_ok else "FAIL"
|
||||||
print ". in %.2f sec (%.2f) [%s]" % (delta, abs(delta - 0.95), msg)
|
print ". in %.2f sec (%.2f) [%s]" % (delta, deviation, msg)
|
||||||
else:
|
else:
|
||||||
print "."
|
print ". skipped"
|
||||||
start = time();
|
start = time();
|
||||||
measurement_time = time() - start_serial_pool
|
measurement_time = time() - start_serial_pool
|
||||||
print "Completed in %.2f sec" % (measurement_time)
|
print "Completed in %.2f sec" % (measurement_time)
|
||||||
|
|
||||||
if test_result: # All numbers are the same
|
if test_result: # All numbers are the same
|
||||||
self.print_result('success')
|
self.print_result('success')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -391,6 +391,9 @@ TESTS = [
|
||||||
"id": "MBED_25", "description": "Time us",
|
"id": "MBED_25", "description": "Time us",
|
||||||
"source_dir": join(TEST_DIR, "mbed", "time_us"),
|
"source_dir": join(TEST_DIR, "mbed", "time_us"),
|
||||||
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
|
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
|
||||||
|
"duration": 15,
|
||||||
|
"automated": True,
|
||||||
|
"host_test": "wait_us_auto"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "MBED_26", "description": "Integer constant division",
|
"id": "MBED_26", "description": "Integer constant division",
|
||||||
|
|
Loading…
Reference in New Issue