Add system example tests
This commit is contained in:
parent
aad3b0e3a2
commit
e1dc92b60b
17 changed files with 355 additions and 22 deletions
21
examples/cxx/pthread/example_test.py
Normal file
21
examples/cxx/pthread/example_test.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from __future__ import unicode_literals
|
||||
import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_cpp_pthread(env, extra_data):
|
||||
|
||||
dut = env.get_dut('cpp_pthread', 'examples/cxx/pthread')
|
||||
dut.start_app()
|
||||
|
||||
dut.expect_all(re.compile(r'pthread: This thread \(with the default name\) may run on any core.'
|
||||
r'Core id: [01], prio: 5, minimum free stack: \d+ bytes.'),
|
||||
re.compile(r'Thread [12]: Core id: [01], prio: 5, minimum free stack: \d+ bytes.'),
|
||||
re.compile(r'Thread [12]: This is the INHERITING thread with the same parameters as our parent, '
|
||||
r'including name. Core id: [01], prio: 5, minimum free stack: \d+ bytes.'),
|
||||
re.compile(r'Thread [12]: Core id: [01], prio: 5, minimum free stack: \d+ bytes'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_cpp_pthread()
|
33
examples/system/base_mac_address/example_test.py
Normal file
33
examples/system/base_mac_address/example_test.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from __future__ import unicode_literals
|
||||
from tiny_test_fw import Utility
|
||||
import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_base_mac_address(env, extra_data):
|
||||
|
||||
dut = env.get_dut('base_mac_address', 'examples/system/base_mac_address')
|
||||
dut.start_app()
|
||||
|
||||
dut.expect('BASE_MAC: Base MAC Address read from EFUSE BLK0', timeout=30)
|
||||
hex_r = r', '.join((r'0x([0-9a-f]{1,2})',) * 6)
|
||||
mac_m = dut.expect(re.compile(r'BASE_MAC: Using "' + hex_r + r'" as base MAC address'), timeout=5)
|
||||
Utility.console_log('BASE_MAC detected: {}'.format(':'.join(mac_m)))
|
||||
|
||||
def get_expected_mac_string(increment):
|
||||
'''
|
||||
Return the string representation of the MAC address mac_m with the last octet incremented.
|
||||
mac_m is an array of strings in hexa-decimal format without the '0x' prefix.
|
||||
'''
|
||||
return ', '.join(['0x{}'.format(m) for m in mac_m[:-1]] + [hex(int(mac_m[-1], 16) + increment)])
|
||||
|
||||
dut.expect_all('WIFI_STA MAC: ' + get_expected_mac_string(0),
|
||||
'SoftAP MAC: ' + get_expected_mac_string(1),
|
||||
'BT MAC: ' + get_expected_mac_string(2),
|
||||
'Ethernet MAC: ' + get_expected_mac_string(3),
|
||||
timeout=10)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_base_mac_address()
|
|
@ -21,7 +21,7 @@ In this example, the `CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP` Kconfig opt
|
|||
|
||||
This example should be able to run on any commonly available ESP32 development board without any extra hardware if only **Timer** and **ULP** wake up sources are used. However, the following extra connections will be required for the remaining wake up sources.
|
||||
|
||||
- **EXT1:** GPIO2 and GPIO4 should be connected to LOW to avoid floating pins. When triggering a wake up, connect one or both of then pins to HIGH. Note that floating pins may trigger an wake up.
|
||||
- **EXT1:** GPIO2 and GPIO4 should be connected to LOW to avoid floating pins. When triggering a wake up, connect one or both of the pins to HIGH. Note that floating pins may trigger a wake up.
|
||||
|
||||
- **Touch:** GPIO32, GPIO33 in ESP32 or GPIO9 in ESP32-S2 should be connected to touch sensors (see [Touch Sensor Application Note](https://github.com/espressif/esp-iot-solution/blob/master/documents/touch_pad_solution/touch_sensor_design_en.md)).
|
||||
|
||||
|
|
29
examples/system/deep_sleep/example_test.py
Normal file
29
examples/system/deep_sleep/example_test.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from __future__ import unicode_literals
|
||||
import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_deep_sleep(env, extra_data):
|
||||
|
||||
dut = env.get_dut('deep_sleep', 'examples/system/deep_sleep')
|
||||
dut.start_app()
|
||||
|
||||
def expect_enable_deep_sleep():
|
||||
dut.expect_all('Enabling timer wakeup, 20s',
|
||||
re.compile(r'Touch pad #8 average: \d+, wakeup threshold set to \d+.'),
|
||||
re.compile(r'Touch pad #9 average: \d+, wakeup threshold set to \d+.'),
|
||||
'Enabling touch pad wakeup',
|
||||
'Entering deep sleep',
|
||||
timeout=10)
|
||||
|
||||
dut.expect('Not a deep sleep reset', timeout=30)
|
||||
expect_enable_deep_sleep()
|
||||
|
||||
# Check that it spent 2xxxxms in deep sleep, i.e at least 20 seconds:
|
||||
dut.expect(re.compile(r'Wake up from timer. Time spent in deep sleep: 2\d{4}ms'), timeout=30)
|
||||
expect_enable_deep_sleep()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_deep_sleep()
|
|
@ -1,13 +1,13 @@
|
|||
menu "Example Configuration"
|
||||
|
||||
config ENABLE_TOUCH_WAKEUP
|
||||
config EXAMPLE_TOUCH_WAKEUP
|
||||
bool "Enable touch wake up"
|
||||
default y
|
||||
help
|
||||
This option enables wake up from deep sleep using touch pads
|
||||
TOUCH8 and TOUCH9, which correspond to GPIO33 and GPIO32.
|
||||
|
||||
config ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
config EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
bool "Enable temperature monitoring by ULP"
|
||||
default y
|
||||
help
|
||||
|
@ -17,4 +17,12 @@ menu "Example Configuration"
|
|||
the window defined by the initial temperature and a threshold
|
||||
around it.
|
||||
|
||||
config EXAMPLE_EXT1_WAKEUP
|
||||
bool "Enable wakeup from GPIO"
|
||||
default y
|
||||
help
|
||||
This option enables wake up from deep sleep from GPIO2 and GPIO4. They should be connected to LOW to avoid
|
||||
floating pins. When triggering a wake up, connect one or both of the pins to HIGH. Note that floating
|
||||
pins may trigger a wake up.
|
||||
|
||||
endmenu
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
static RTC_DATA_ATTR struct timeval sleep_enter_time;
|
||||
|
||||
#ifdef CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
/*
|
||||
|
@ -70,9 +70,9 @@ static inline void ulp_data_write(size_t offset, uint16_t value)
|
|||
RTC_SLOW_MEM[ULP_DATA_OFFSET + offset] = value;
|
||||
}
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
#endif // CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#endif // CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
|
||||
#ifdef CONFIG_ENABLE_TOUCH_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_TOUCH_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define TOUCH_THRESH_NO_USE 0
|
||||
static void calibrate_touch_pad(touch_pad_t pad);
|
||||
|
@ -86,6 +86,7 @@ void app_main(void)
|
|||
int sleep_time_ms = (now.tv_sec - sleep_enter_time.tv_sec) * 1000 + (now.tv_usec - sleep_enter_time.tv_usec) / 1000;
|
||||
|
||||
switch (esp_sleep_get_wakeup_cause()) {
|
||||
#ifdef CONFIG_EXAMPLE_EXT1_WAKEUP
|
||||
case ESP_SLEEP_WAKEUP_EXT1: {
|
||||
uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status();
|
||||
if (wakeup_pin_mask != 0) {
|
||||
|
@ -96,17 +97,18 @@ void app_main(void)
|
|||
}
|
||||
break;
|
||||
}
|
||||
#endif // CONFIG_EXAMPLE_EXT1_WAKEUP
|
||||
case ESP_SLEEP_WAKEUP_TIMER: {
|
||||
printf("Wake up from timer. Time spent in deep sleep: %dms\n", sleep_time_ms);
|
||||
break;
|
||||
}
|
||||
#ifdef CONFIG_ENABLE_TOUCH_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_TOUCH_WAKEUP
|
||||
case ESP_SLEEP_WAKEUP_TOUCHPAD: {
|
||||
printf("Wake up from touch on pad %d\n", esp_sleep_get_touchpad_wakeup_status());
|
||||
break;
|
||||
}
|
||||
#endif // CONFIG_ENABLE_TOUCH_WAKEUP
|
||||
#ifdef CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#endif // CONFIG_EXAMPLE_TOUCH_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
case ESP_SLEEP_WAKEUP_ULP: {
|
||||
printf("Wake up from ULP\n");
|
||||
|
@ -122,20 +124,20 @@ void app_main(void)
|
|||
break;
|
||||
}
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
#endif // CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#endif // CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
case ESP_SLEEP_WAKEUP_UNDEFINED:
|
||||
default:
|
||||
printf("Not a deep sleep reset\n");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
if (esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_UNDEFINED) {
|
||||
printf("ULP did %d temperature measurements in %d ms\n", ulp_data_read(1), sleep_time_ms);
|
||||
printf("Initial T=%d, latest T=%d\n", ulp_data_read(0), ulp_data_read(2));
|
||||
}
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
#endif // CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#endif // CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
|
||||
|
@ -143,6 +145,7 @@ void app_main(void)
|
|||
printf("Enabling timer wakeup, %ds\n", wakeup_time_sec);
|
||||
esp_sleep_enable_timer_wakeup(wakeup_time_sec * 1000000);
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_EXT1_WAKEUP
|
||||
const int ext_wakeup_pin_1 = 2;
|
||||
const uint64_t ext_wakeup_pin_1_mask = 1ULL << ext_wakeup_pin_1;
|
||||
const int ext_wakeup_pin_2 = 4;
|
||||
|
@ -150,8 +153,9 @@ void app_main(void)
|
|||
|
||||
printf("Enabling EXT1 wakeup on pins GPIO%d, GPIO%d\n", ext_wakeup_pin_1, ext_wakeup_pin_2);
|
||||
esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask | ext_wakeup_pin_2_mask, ESP_EXT1_WAKEUP_ANY_HIGH);
|
||||
#endif // CONFIG_EXAMPLE_EXT1_WAKEUP
|
||||
|
||||
#ifdef CONFIG_ENABLE_TOUCH_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_TOUCH_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
// Initialize touch pad peripheral.
|
||||
// The default fsm mode is software trigger mode.
|
||||
|
@ -213,9 +217,9 @@ void app_main(void)
|
|||
printf("Enabling touch pad wakeup\n");
|
||||
esp_sleep_enable_touchpad_wakeup();
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
#endif // CONFIG_ENABLE_TOUCH_WAKEUP
|
||||
#endif // CONFIG_EXAMPLE_TOUCH_WAKEUP
|
||||
|
||||
#ifdef CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
printf("Enabling ULP wakeup\n");
|
||||
esp_sleep_enable_ulp_wakeup();
|
||||
|
@ -232,7 +236,7 @@ void app_main(void)
|
|||
printf("Entering deep sleep\n");
|
||||
gettimeofday(&sleep_enter_time, NULL);
|
||||
|
||||
#ifdef CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
start_ulp_temperature_monitoring();
|
||||
#endif
|
||||
|
@ -241,7 +245,7 @@ void app_main(void)
|
|||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENABLE_TOUCH_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_TOUCH_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
static void calibrate_touch_pad(touch_pad_t pad)
|
||||
{
|
||||
|
@ -265,9 +269,9 @@ static void calibrate_touch_pad(touch_pad_t pad)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#endif // CONFIG_ENABLE_TOUCH_WAKEUP
|
||||
#endif // CONFIG_EXAMPLE_TOUCH_WAKEUP
|
||||
|
||||
#ifdef CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#ifdef CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
static void start_ulp_temperature_monitoring(void)
|
||||
{
|
||||
|
@ -369,5 +373,5 @@ static void start_ulp_temperature_monitoring(void)
|
|||
ESP_ERROR_CHECK( ulp_run(0) );
|
||||
}
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
#endif // CONFIG_ENABLE_ULP_TEMPERATURE_WAKEUP
|
||||
#endif // CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP
|
||||
|
||||
|
|
9
examples/system/deep_sleep/sdkconfig.ci
Normal file
9
examples/system/deep_sleep/sdkconfig.ci
Normal file
|
@ -0,0 +1,9 @@
|
|||
CONFIG_ESP32_DEFAULT_CPU_FREQ_80=y
|
||||
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=80
|
||||
CONFIG_ESP32_ULP_COPROC_ENABLED=y
|
||||
CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=512
|
||||
CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y
|
||||
CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y
|
||||
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
|
||||
CONFIG_EXAMPLE_ULP_TEMPERATURE_WAKEUP=n
|
||||
CONFIG_EXAMPLE_EXT1_WAKEUP=n
|
36
examples/system/efuse/example_test.py
Normal file
36
examples/system/efuse/example_test.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
from __future__ import unicode_literals
|
||||
import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_efuse(env, extra_data):
|
||||
|
||||
dut = env.get_dut('efuse', 'examples/system/efuse')
|
||||
dut.start_app()
|
||||
|
||||
dut.expect_all(re.compile(r'example: Coding Scheme (3/4)|(NONE)|(REPEAT)|(RS \(Reed-Solomon coding\))'),
|
||||
'example: read efuse fields',
|
||||
re.compile(r'example: 1. read MAC address: {}'.format(r':'.join((r'[0-9a-f]{2}',) * 6))),
|
||||
'example: 2. read secure_version: 0',
|
||||
'example: 3. read custom fields',
|
||||
'example: module_version = 0',
|
||||
'example: device_role = None',
|
||||
'example: setting_1 = 0',
|
||||
'example: setting_2 = 0',
|
||||
'example: custom_secure_version = 0',
|
||||
'example: This example does not burn any efuse in reality only virtually',
|
||||
'example: Write operations in efuse fields are performed virtually',
|
||||
'example: write custom efuse fields',
|
||||
'efuse: Virtual efuses enabled: Not really burning eFuses',
|
||||
'example: module_version = 1',
|
||||
'example: device_role = Slave',
|
||||
'example: setting_1 = 3',
|
||||
'example: setting_2 = 4',
|
||||
'example: custom_secure_version = 5',
|
||||
'example: Done',
|
||||
timeout=30)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_efuse()
|
2
examples/system/efuse/sdkconfig.ci
Normal file
2
examples/system/efuse/sdkconfig.ci
Normal file
|
@ -0,0 +1,2 @@
|
|||
CONFIG_EFUSE_CUSTOM_TABLE=y
|
||||
CONFIG_EFUSE_VIRTUAL=y
|
22
examples/system/himem/example_test.py
Normal file
22
examples/system/himem/example_test.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from __future__ import unicode_literals
|
||||
import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_himem(env, extra_data):
|
||||
|
||||
dut = env.get_dut('himem', 'examples/system/himem')
|
||||
dut.start_app()
|
||||
|
||||
mem = dut.expect(re.compile(r'esp_himem: Initialized. Using last \d+ 32KB address blocks for bank '
|
||||
r'switching on (\d+) KB of physical memory.'), timeout=30)[0]
|
||||
|
||||
dut.expect_all(re.compile(r'Himem has {}KiB of memory, \d+KiB of which is free. '
|
||||
r'Testing the free memory...'.format(mem)),
|
||||
'Done!',
|
||||
timeout=10)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_himem()
|
19
examples/system/perfmon/example_test.py
Normal file
19
examples/system/perfmon/example_test.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from __future__ import unicode_literals
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_perfmon(env, extra_data):
|
||||
|
||||
dut = env.get_dut('perfmon', 'examples/system/perfmon')
|
||||
dut.start_app()
|
||||
|
||||
dut.expect_all('example: Start',
|
||||
'example: Start test with printing all available statistic',
|
||||
'example: Start test with user defined statistic',
|
||||
'example: The End',
|
||||
timeout=60)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_perfmon()
|
37
examples/system/select/example_test.py
Normal file
37
examples/system/select/example_test.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from __future__ import unicode_literals
|
||||
from tiny_test_fw import Utility
|
||||
import os
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
def get_socket_msgs(i):
|
||||
msg = 'Socket message S{}'.format(i)
|
||||
return ['uart_select_example: {} bytes were written to socket: {}'.format(len(msg), msg),
|
||||
'uart_select_example: {} bytes were received through socket: {}'.format(len(msg), msg)]
|
||||
|
||||
|
||||
def get_uart_msgs(i):
|
||||
msg = 'UART message U{}'.format(i)
|
||||
return ['uart_select_example: {} bytes were sent to UART1: {}'.format(len(msg), msg),
|
||||
'uart_select_example: {} bytes were received through UART1: {}'.format(len(msg), msg)]
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_select(env, extra_data):
|
||||
|
||||
dut = env.get_dut('select', 'examples/system/select')
|
||||
dut.start_app()
|
||||
|
||||
dut.expect('cpu_start: Starting scheduler', timeout=30)
|
||||
|
||||
exp_list = []
|
||||
for i in range(1, 10):
|
||||
exp_list += get_socket_msgs(i)
|
||||
exp_list += get_uart_msgs(i)
|
||||
|
||||
Utility.console_log('Expecting:{}{}'.format(os.linesep, os.linesep.join(exp_list)))
|
||||
dut.expect_all(*exp_list, timeout=60)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_select()
|
18
examples/system/task_watchdog/example_test.py
Normal file
18
examples/system/task_watchdog/example_test.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from __future__ import unicode_literals
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_task_watchdog(env, extra_data):
|
||||
|
||||
dut = env.get_dut('task_watchdog', 'examples/system/task_watchdog')
|
||||
dut.start_app()
|
||||
|
||||
dut.expect_all('Initialize TWDT',
|
||||
'Delay for 10 seconds', timeout=30)
|
||||
dut.expect_all('Unsubscribing and deleting tasks',
|
||||
'Complete', timeout=20)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_task_watchdog()
|
43
examples/system/ulp/example_test.py
Normal file
43
examples/system/ulp/example_test.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
from __future__ import unicode_literals
|
||||
from tiny_test_fw import Utility
|
||||
import re
|
||||
import time
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_ulp(env, extra_data):
|
||||
|
||||
dut = env.get_dut('ulp', 'examples/system/ulp')
|
||||
dut.start_app()
|
||||
|
||||
dut.expect_all('Not ULP wakeup, initializing ULP',
|
||||
'Entering deep sleep',
|
||||
timeout=30)
|
||||
|
||||
def generate_gpio0_events():
|
||||
for _ in range(5):
|
||||
dut.port_inst.setDTR(True) # Pulling GPIO0 low using DTR
|
||||
time.sleep(0.25)
|
||||
dut.port_inst.setDTR(False)
|
||||
time.sleep(0.25)
|
||||
|
||||
nvs_value = None
|
||||
for _ in range(5):
|
||||
generate_gpio0_events()
|
||||
dut.expect('ULP wakeup, saving pulse count', timeout=5)
|
||||
Utility.console_log('Woke up...')
|
||||
init_count = int(dut.expect(re.compile(r'Read pulse count from NVS:\s+(\d+)'), timeout=5)[0], 10)
|
||||
assert nvs_value in (init_count, None), ('Read count is {} and previously written value is {}'
|
||||
''.format(init_count, nvs_value))
|
||||
inc = int(dut.expect(re.compile(r'Pulse count from ULP:\s+(\d+)'), timeout=5)[0], 10)
|
||||
assert inc in (5, 6), 'pulse count is {}'.format(inc)
|
||||
new_count = int(dut.expect(re.compile(r'Wrote updated pulse count to NVS:\s+(\d+)'), timeout=5)[0], 10)
|
||||
assert init_count + inc == new_count, '{} + {} != {}'.format(init_count, inc, new_count)
|
||||
nvs_value = new_count
|
||||
Utility.console_log('Pulse count written to NVS: {}. Entering deep sleep...'.format(nvs_value))
|
||||
dut.expect('Entering deep sleep', timeout=5)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_ulp()
|
28
examples/system/ulp_adc/example_test.py
Normal file
28
examples/system/ulp_adc/example_test.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
from __future__ import unicode_literals
|
||||
from tiny_test_fw import Utility
|
||||
import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
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()
|
24
examples/system/unit_test/example_test.py
Normal file
24
examples/system/unit_test/example_test.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from __future__ import unicode_literals
|
||||
import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_WIFI')
|
||||
def test_examples_unit_test(env, extra_data):
|
||||
|
||||
dut = env.get_dut('unit_test', 'examples/system/unit_test')
|
||||
dut.start_app()
|
||||
|
||||
def get_reg_nums(number):
|
||||
return re.compile(r'\d{1,2}\s+' * number)
|
||||
|
||||
dut.expect_all('In main application. Collecting 32 random numbers from 1 to 100:',
|
||||
get_reg_nums(10),
|
||||
get_reg_nums(10),
|
||||
get_reg_nums(10),
|
||||
get_reg_nums(2),
|
||||
timeout=30)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_unit_test()
|
|
@ -207,7 +207,7 @@ test_weekend_network:
|
|||
|
||||
example_test_001A:
|
||||
extends: .example_test_template
|
||||
parallel: 3
|
||||
parallel: 4
|
||||
tags:
|
||||
- ESP32
|
||||
- Example_WIFI
|
||||
|
|
Loading…
Reference in a new issue