tests/xtimer_usleep: fail with negative offset
- xtimer_usleep(timeout) should sleep for at least timeout us. Negative offset, i.e. sleeping less than the specified time is incorrect.
This commit is contained in:
parent
cd0ab4a193
commit
a687a26f42
@ -84,3 +84,20 @@ Invalid timeout 1464 ,expected 1172 < 1234 < 1295
|
|||||||
Host max error 61
|
Host max error 61
|
||||||
error 291
|
error 291
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Test also fails with negative offset as xtimer_usleep must sleep for at least
|
||||||
|
the expected time.
|
||||||
|
|
||||||
|
```
|
||||||
|
XXXX-XX-XX XX:XX:XX,XXX - INFO # Connect to serial port /dev/ttyACM0
|
||||||
|
Welcome to pyterm!
|
||||||
|
Type '/exit' to exit.
|
||||||
|
XXXX-XX-XX XX:XX:XX,XXX - INFO # main(): This is RIOT! (XXX)
|
||||||
|
XXXX-XX-XX XX:XX:XX,XXX - INFO # Running test 5 times with 7 distinct sleep times
|
||||||
|
XXXX-XX-XX XX:XX:XX,XXX - INFO # Please hit any key and then ENTER to continue
|
||||||
|
a
|
||||||
|
XXXX-XX-XX XX:XX:XX,XXX - INFO # Slept for 9979 us (expected: 10000 us) Offset: -21 us
|
||||||
|
Invalid timeout 9979 ,expected 10000 < 10500
|
||||||
|
Host max error 500
|
||||||
|
error -21
|
||||||
|
```
|
||||||
@ -33,17 +33,17 @@ def testfunc(child):
|
|||||||
start_test = time.time()
|
start_test = time.time()
|
||||||
for m in range(RUNS):
|
for m in range(RUNS):
|
||||||
for n in range(SLEEP_TIMES_NUMOF):
|
for n in range(SLEEP_TIMES_NUMOF):
|
||||||
child.expect(u"Slept for (\\d+) us \\(expected: (\\d+) us\\) Offset: (\\d+) us")
|
child.expect(u"Slept for (\\d+) us \\(expected: (\\d+) us\\) Offset: (-?\\d+) us")
|
||||||
sleep_time = int(child.match.group(1))
|
sleep_time = int(child.match.group(1))
|
||||||
exp = int(child.match.group(2))
|
exp = int(child.match.group(2))
|
||||||
lower_bound = exp - (exp * INTERNAL_JITTER)
|
|
||||||
upper_bound = exp + (exp * INTERNAL_JITTER)
|
upper_bound = exp + (exp * INTERNAL_JITTER)
|
||||||
if not (lower_bound < sleep_time < upper_bound):
|
if not (exp < sleep_time < upper_bound):
|
||||||
delta = (upper_bound-lower_bound)/2
|
delta = (upper_bound-exp)
|
||||||
raise InvalidTimeout("Invalid timeout %d ,expected %d < %d < %d"
|
error = min(upper_bound-sleep_time, sleep_time-exp)
|
||||||
|
raise InvalidTimeout("Invalid timeout %d, expected %d < timeout < %d"
|
||||||
"\nHost max error\t%d\nerror\t\t%d" %
|
"\nHost max error\t%d\nerror\t\t%d" %
|
||||||
(sleep_time, lower_bound, exp, upper_bound,
|
(sleep_time, exp, upper_bound,
|
||||||
delta, sleep_time-lower_bound))
|
delta, error))
|
||||||
testtime = (time.time() - start_test) * US_PER_SEC
|
testtime = (time.time() - start_test) * US_PER_SEC
|
||||||
child.expect(u"Test ran for (\\d+) us")
|
child.expect(u"Test ran for (\\d+) us")
|
||||||
exp = int(child.match.group(1))
|
exp = int(child.match.group(1))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user