From d88d3b0b3a843d8a1961f510f1fc56eb09dd59fd Mon Sep 17 00:00:00 2001 From: Daniel Campora Date: Sun, 27 Sep 2015 20:53:56 +0200 Subject: tests/wipy: Skip the rtc_irq test. --- tests/wipy/rtc_irq.py | 89 --------------------------------------- tests/wipy/rtc_irq.py.exp | 11 ----- tests/wipy/skipped/rtc_irq.py | 89 +++++++++++++++++++++++++++++++++++++++ tests/wipy/skipped/rtc_irq.py.exp | 11 +++++ 4 files changed, 100 insertions(+), 100 deletions(-) delete mode 100644 tests/wipy/rtc_irq.py delete mode 100644 tests/wipy/rtc_irq.py.exp create mode 100644 tests/wipy/skipped/rtc_irq.py create mode 100644 tests/wipy/skipped/rtc_irq.py.exp (limited to 'tests') diff --git a/tests/wipy/rtc_irq.py b/tests/wipy/rtc_irq.py deleted file mode 100644 index ec3baa552..000000000 --- a/tests/wipy/rtc_irq.py +++ /dev/null @@ -1,89 +0,0 @@ -''' -RTC IRQ test for the CC3200 based boards. -''' - -from machine import RTC -import machine -import os -import time - -mch = os.uname().machine -if not 'LaunchPad' in mch and not 'WiPy' in mch: - raise Exception('Board not supported!') - -def rtc_ticks_ms(rtc): - timedate = rtc.now() - return (timedate[5] * 1000) + (timedate[6] // 1000) - -rtc_irq_count = 0 - -def alarm_handler (rtc_o): - global rtc_irq - global rtc_irq_count - if rtc_irq.flags() & RTC.ALARM0: - rtc_irq_count += 1 - -rtc = RTC() -rtc.alarm(time=500, repeat=True) -rtc_irq = rtc.irq(trigger=RTC.ALARM0, handler=alarm_handler) - -# active mode -time.sleep_ms(1000) -rtc.alarm_cancel() -print(rtc_irq_count == 2) -rtc_irq_count = 0 -rtc.alarm(time=200, repeat=True) -time.sleep_ms(1000) -rtc.alarm_cancel() -print(rtc_irq_count == 5) - -rtc_irq_count = 0 -rtc.alarm(time=100, repeat=True) -time.sleep_ms(1000) -rtc.alarm_cancel() -print(rtc_irq_count == 10) - -# deep sleep mode -rtc.alarm_cancel() -rtc_irq_count = 0 -rtc.alarm(time=50, repeat=True) -rtc_irq.init(trigger=RTC.ALARM0, handler=alarm_handler, wake=machine.SLEEP | machine.IDLE) -while rtc_irq_count < 3: - machine.sleep() -print(rtc_irq_count == 3) - -# no repetition -rtc.alarm_cancel() -rtc_irq_count = 0 -rtc.alarm(time=100, repeat=False) -time.sleep_ms(250) -print(rtc_irq_count == 1) - -rtc.alarm_cancel() -t0 = rtc_ticks_ms(rtc) -rtc.alarm(time=500, repeat=False) -machine.sleep() -t1 = rtc_ticks_ms(rtc) -print(abs(t1 - t0 - 500) < 20) - -# deep sleep repeated mode -rtc.alarm_cancel() -rtc_irq_count = 0 -rtc.alarm(time=500, repeat=True) -t0 = rtc_ticks_ms(rtc) -rtc_irq = rtc.irq(trigger=RTC.ALARM0, handler=alarm_handler, wake=machine.SLEEP) -while rtc_irq_count < 3: - machine.sleep() - t1 = rtc_ticks_ms(rtc) - print(abs(t1 - t0 - (500 * rtc_irq_count)) < 25) - -# next ones must raise -try: - rtc_irq = rtc.irq(trigger=10, handler=alarm_handler) -except: - print('Exception') - -try: - rtc_irq = rtc.irq(trigger=RTC.ALARM0, wake=1789456) -except: - print('Exception') diff --git a/tests/wipy/rtc_irq.py.exp b/tests/wipy/rtc_irq.py.exp deleted file mode 100644 index a3eebc2d1..000000000 --- a/tests/wipy/rtc_irq.py.exp +++ /dev/null @@ -1,11 +0,0 @@ -True -True -True -True -True -True -True -True -True -Exception -Exception diff --git a/tests/wipy/skipped/rtc_irq.py b/tests/wipy/skipped/rtc_irq.py new file mode 100644 index 000000000..ec3baa552 --- /dev/null +++ b/tests/wipy/skipped/rtc_irq.py @@ -0,0 +1,89 @@ +''' +RTC IRQ test for the CC3200 based boards. +''' + +from machine import RTC +import machine +import os +import time + +mch = os.uname().machine +if not 'LaunchPad' in mch and not 'WiPy' in mch: + raise Exception('Board not supported!') + +def rtc_ticks_ms(rtc): + timedate = rtc.now() + return (timedate[5] * 1000) + (timedate[6] // 1000) + +rtc_irq_count = 0 + +def alarm_handler (rtc_o): + global rtc_irq + global rtc_irq_count + if rtc_irq.flags() & RTC.ALARM0: + rtc_irq_count += 1 + +rtc = RTC() +rtc.alarm(time=500, repeat=True) +rtc_irq = rtc.irq(trigger=RTC.ALARM0, handler=alarm_handler) + +# active mode +time.sleep_ms(1000) +rtc.alarm_cancel() +print(rtc_irq_count == 2) +rtc_irq_count = 0 +rtc.alarm(time=200, repeat=True) +time.sleep_ms(1000) +rtc.alarm_cancel() +print(rtc_irq_count == 5) + +rtc_irq_count = 0 +rtc.alarm(time=100, repeat=True) +time.sleep_ms(1000) +rtc.alarm_cancel() +print(rtc_irq_count == 10) + +# deep sleep mode +rtc.alarm_cancel() +rtc_irq_count = 0 +rtc.alarm(time=50, repeat=True) +rtc_irq.init(trigger=RTC.ALARM0, handler=alarm_handler, wake=machine.SLEEP | machine.IDLE) +while rtc_irq_count < 3: + machine.sleep() +print(rtc_irq_count == 3) + +# no repetition +rtc.alarm_cancel() +rtc_irq_count = 0 +rtc.alarm(time=100, repeat=False) +time.sleep_ms(250) +print(rtc_irq_count == 1) + +rtc.alarm_cancel() +t0 = rtc_ticks_ms(rtc) +rtc.alarm(time=500, repeat=False) +machine.sleep() +t1 = rtc_ticks_ms(rtc) +print(abs(t1 - t0 - 500) < 20) + +# deep sleep repeated mode +rtc.alarm_cancel() +rtc_irq_count = 0 +rtc.alarm(time=500, repeat=True) +t0 = rtc_ticks_ms(rtc) +rtc_irq = rtc.irq(trigger=RTC.ALARM0, handler=alarm_handler, wake=machine.SLEEP) +while rtc_irq_count < 3: + machine.sleep() + t1 = rtc_ticks_ms(rtc) + print(abs(t1 - t0 - (500 * rtc_irq_count)) < 25) + +# next ones must raise +try: + rtc_irq = rtc.irq(trigger=10, handler=alarm_handler) +except: + print('Exception') + +try: + rtc_irq = rtc.irq(trigger=RTC.ALARM0, wake=1789456) +except: + print('Exception') diff --git a/tests/wipy/skipped/rtc_irq.py.exp b/tests/wipy/skipped/rtc_irq.py.exp new file mode 100644 index 000000000..a3eebc2d1 --- /dev/null +++ b/tests/wipy/skipped/rtc_irq.py.exp @@ -0,0 +1,11 @@ +True +True +True +True +True +True +True +True +True +Exception +Exception -- cgit v1.2.3