kopia lustrzana https://github.com/micropython/micropython
tests/misc/cexample_class: Fix timing sensitivity.
This test could occasionally fail because some operations take longer than expected. This relaxes the timing constraints and defers printing until the very end. Signed-off-by: Laurens Valk <laurens@pybricks.com>pull/10072/head
rodzic
5588647ad2
commit
3c1a2a942a
|
@ -7,14 +7,18 @@ except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
t = cexample.Timer()
|
|
||||||
|
|
||||||
print(t)
|
SLEEP_MS = 100
|
||||||
print(t.time() <= 1)
|
TOLERANCE_MS = 20
|
||||||
|
|
||||||
|
timer = cexample.Timer()
|
||||||
|
|
||||||
|
t_start = timer.time()
|
||||||
|
|
||||||
time.sleep_ms(100)
|
time.sleep_ms(100)
|
||||||
|
|
||||||
elapsed = t.time()
|
t_end = timer.time()
|
||||||
|
|
||||||
if not (99 <= elapsed <= 110):
|
print(timer)
|
||||||
print("Elapsed time should be approx. 100ms but it is", elapsed)
|
print(0 <= t_start <= TOLERANCE_MS)
|
||||||
|
print(SLEEP_MS - TOLERANCE_MS <= t_end <= SLEEP_MS + TOLERANCE_MS)
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
<Timer>
|
<Timer>
|
||||||
True
|
True
|
||||||
|
True
|
||||||
|
|
Ładowanie…
Reference in New Issue