Multi-Device Test Cases: unity_send_signal() and unity_wait_for_signal() not working
Posted: Mon Aug 31, 2020 9:13 pm
The documentation https://docs.espressif.com/projects/esp ... test-cases summarizes how to perform multi-device-test-cases and synchronize multiple devices using unity_send_signal() and unity_wait_for_signal()
Here is the provided sample multi-device test case code from that documentation:
I copied that sample code into the example unit test application here: https://github.com/espressif/esp-idf/tr ... /unit_test
Into components/testable/tests/test_mean.c, and the two functions unity_send_signal() and unity_wait_for_signal() are undefined
I determined these functions are defined in esp-idf/tools/unit-test-app/components/test_utils/include/test_utils.h
I modified the EXTRA_COMPONENT_DIRS CMake variable to include the test_utils component,
Added the test_utils component in the testable component
and included the file in testable/test/test_mean.c
Now unity_send_signal() and unity_wait_for_signal() are defined and everything builds.
BUT it still doesn't work.
When I run the tests, every single test now fails with error "Expected Non-NULL", even tests that don't call unity_send_signal() or unity_wait_for_signal(). If I remove both calls to unity_send_signal() or unity_wait_for_signal() then all the tests pass as expected again.
What am I missing? The tests for the esp-idf components use these functions and they seem to work when I run the unit-test-app. This feature will be very useful for me, but I cannot figure it out.
Thanks!
Here is the provided sample multi-device test case code from that documentation:
Code: Select all
void gpio_master_test()
{
gpio_config_t slave_config = {
.pin_bit_mask = 1 << MASTER_GPIO_PIN,
.mode = GPIO_MODE_INPUT,
};
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);
Into components/testable/tests/test_mean.c, and the two functions unity_send_signal() and unity_wait_for_signal() are undefined
I determined these functions are defined in esp-idf/tools/unit-test-app/components/test_utils/include/test_utils.h
I modified the EXTRA_COMPONENT_DIRS CMake variable to include the test_utils component,
Code: Select all
set(EXTRA_COMPONENT_DIRS "../components;$ENV{IDF_PATH}/tools/unit-test-app/components")
Added the test_utils component in the testable component
Code: Select all
idf_component_register(SRC_DIRS "."
INCLUDE_DIRS "."
REQUIRES unity test_utils testable)
Code: Select all
#include "test_utils.h"
BUT it still doesn't work.
When I run the tests, every single test now fails with error "Expected Non-NULL", even tests that don't call unity_send_signal() or unity_wait_for_signal(). If I remove both calls to unity_send_signal() or unity_wait_for_signal() then all the tests pass as expected again.
What am I missing? The tests for the esp-idf components use these functions and they seem to work when I run the unit-test-app. This feature will be very useful for me, but I cannot figure it out.
Thanks!