from __future__ import unicode_literals
from tiny_test_fw import Utility
import re
import ttfw_idf


@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
def test_examples_ulp_adc(env, extra_data):

    dut = env.get_dut('ulp_adc', 'examples/system/ulp_adc')
    dut.start_app()

    dut.expect_all('Not ULP wakeup',
                   'Entering deep sleep',
                   timeout=30)

    for _ in range(5):
        dut.expect('Deep sleep wakeup', timeout=60)
        measurements = int(dut.expect(re.compile(r'ULP did (\d+) measurements'), timeout=5)[0], 10)
        Utility.console_log('ULP did {} measurements'.format(measurements))
        dut.expect('Thresholds:  low=1500  high=2000', timeout=5)
        value = int(dut.expect(re.compile(r'Value=(\d+) was (?:below)|(?:above) threshold'), timeout=5)[0], 10)
        Utility.console_log('Value {} was outside the boundaries'.format(value))
        dut.expect('Entering deep sleep', timeout=60)


if __name__ == '__main__':
    test_examples_ulp_adc()

@@ -480,23 +480,23 @@
 urements
- = int(
+_str = 
 dut.expe
@@ -546,36 +546,120 @@
 ), timeout=5)%5B0%5D
-, 10
+%0A        assert measurements_str is not None%0A        measurements = int(measurements_str
 )%0A        Utilit
@@ -799,23 +799,23 @@
    value
- = int(
+_str = 
 dut.expe
@@ -851,25 +851,19 @@
 as (
-?:below)%7C(?:above
+above%7Cbelow
 ) th
@@ -890,12 +890,75 @@
 )%5B0%5D
-, 10
+%0A        assert value_str is not None%0A        value = int(value_str
 )%0A  

Fix regex in ulp_adc example test