Chapter 4. API Guides
(continued from previous page)
gpio_config(&slave_config);
unity_wait_for_signal("output high level");
TEST_ASSERT(gpio_get_level(MASTER_GPIO_PIN) == 1);
}
void gpio_slave_test()
{
gpio_config_t master_config = {
.pin_bit_mask = 1 << SLAVE_GPIO_PIN,
.mode = GPIO_MODE_OUTPUT,
};
gpio_config(&master_config);
gpio_set_level(SLAVE_GPIO_PIN, 1);
unity_send_signal("output high level");
}
TEST_CASE_MULTIPLE_DEVICES("gpio multiple devices test example", "[driver]", gpio_
,→master_test, gpio_slave_test);
The macro TEST_CASE_MULTIPLE_DEVICES is used to declare a multi-device test case.
• The first argument is test case name.
• The second argument is test case description.
• From the third argument, up to 5 test functions can be defined, each function will be the entry point of tests
running on each DUT.
Running test cases from different DUTs could require synchronizing between DUTs. We provide
unity_wait_for_signal and unity_send_signal to support synchronizing with UART. As the sce-
nario in the above example, the slave should get GPIO level after master set level. DUT UART console will prompt
and user interaction is required:
DUT1 (master) console:
Waiting for signal: [output high level]!
Please press "Enter" key to once any board send this signal.
DUT2 (slave) console:
Send signal: [output high level]!
Once the signal is sent from DUT2, you need to press “Enter”on DUT1, then DUT1 unblocks from
unity_wait_for_signal and starts to change GPIO level.
4.30.3 Multi-stage Test Cases
The normal test cases are expected to finish without reset (or only need to check if reset happens). Sometimes we
expect to run some specific tests after certain kinds of reset. For example, we want to test if the reset reason is correct
after a wake up from deep sleep. We need to create a deep-sleep reset first and then check the reset reason. To
support this, we can define multi-stage test cases, to group a set of test functions:
static void trigger_deepsleep(void)
{
esp_sleep_enable_timer_wakeup(2000);
esp_deep_sleep_start();
}
void check_deepsleep_reset_reason()
{
soc_reset_reason_t reason = esp_rom_get_reset_reason(0);
TEST_ASSERT(reason == RESET_REASON_CORE_DEEP_SLEEP);
(continues on next page)
Espressif Systems 1504
Submit Document Feedback
Release v4.4