mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/unit_test_fixes' into 'master'
Small unit-test-related fixes Fixes for some small bugs found running unit tests with heap poisoning turned on. All are bugs in the tests, except for one FreeRTOS fix (when deleting a task, check if it's running on the other CPU and preempt it if so.) See merge request !746
This commit is contained in:
commit
272551301e
@ -1251,6 +1251,11 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
|
|||||||
portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending[xPortGetCoreID()] );
|
portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending[xPortGetCoreID()] );
|
||||||
portYIELD_WITHIN_API();
|
portYIELD_WITHIN_API();
|
||||||
}
|
}
|
||||||
|
else if ( portNUM_PROCESSORS > 1 && pxTCB == pxCurrentTCB[ !xPortGetCoreID() ] )
|
||||||
|
{
|
||||||
|
/* if task is running on the other CPU, force a yield on that CPU to take it off */
|
||||||
|
vPortYieldOtherCore( !xPortGetCoreID() );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Reset the next expected unblock time in case it referred to
|
/* Reset the next expected unblock time in case it referred to
|
||||||
|
@ -31,12 +31,13 @@ static void testthread(void *arg) {
|
|||||||
in_int_context=0;
|
in_int_context=0;
|
||||||
int_handled=0;
|
int_handled=0;
|
||||||
TEST_ASSERT(!xPortInIsrContext());
|
TEST_ASSERT(!xPortInIsrContext());
|
||||||
xthal_set_ccompare(2, xthal_get_ccount()+8000000);
|
xthal_set_ccompare(1, xthal_get_ccount()+8000000);
|
||||||
esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, 0, &testint, NULL, &handle);
|
esp_err_t err = esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, 0, &testint, NULL, &handle);
|
||||||
|
TEST_ASSERT_EQUAL_HEX32(ESP_OK, err);
|
||||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
TEST_ASSERT(int_handled);
|
TEST_ASSERT(int_handled);
|
||||||
TEST_ASSERT(in_int_context);
|
TEST_ASSERT(in_int_context);
|
||||||
esp_intr_free(handle);
|
TEST_ASSERT_EQUAL_HEX32( ESP_OK, esp_intr_free(handle) );
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ TEST_CASE("Yield from lower priority task, same CPU", "[freertos]")
|
|||||||
printf("Yielding from lower priority task took %u cycles\n", delta);
|
printf("Yielding from lower priority task took %u cycles\n", delta);
|
||||||
TEST_ASSERT(delta < 10000);
|
TEST_ASSERT(delta < 10000);
|
||||||
|
|
||||||
vQueueDelete(queue);
|
|
||||||
vTaskDelete(sender_task);
|
vTaskDelete(sender_task);
|
||||||
|
vQueueDelete(queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ TEST_CASE("can read from stdin", "[vfs]")
|
|||||||
|
|
||||||
const size_t count = 12;
|
const size_t count = 12;
|
||||||
srand(count);
|
srand(count);
|
||||||
char* data = (char*) calloc(1, count * 8 + 1);
|
char* data = (char*) calloc(1, count * 8 + 2);
|
||||||
char* buf = (char*) calloc(1, count * 8 + 1);
|
char* buf = (char*) calloc(1, count * 8 + 2);
|
||||||
char* p = data;
|
char* p = data;
|
||||||
for (size_t i = 0; i < count; ++i) {
|
for (size_t i = 0; i < count; ++i) {
|
||||||
p += sprintf(p, "%08x", rand());
|
p += sprintf(p, "%08x", rand());
|
||||||
@ -62,6 +62,9 @@ TEST_CASE("can read from stdin", "[vfs]")
|
|||||||
size_t cb = fread(buf, 1, len, stdin);
|
size_t cb = fread(buf, 1, len, stdin);
|
||||||
TEST_ASSERT_EQUAL(len, cb);
|
TEST_ASSERT_EQUAL(len, cb);
|
||||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, buf, len);
|
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, buf, len);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,3 +10,13 @@ ESP-IDF unit tests are run using Unit Test App. The app can be built with the un
|
|||||||
* `make menuconfig` to configure the Unit Test App.
|
* `make menuconfig` to configure the Unit Test App.
|
||||||
* `make TEST_COMPONENTS=` with `TEST_COMPONENTS` set to names of the components to be included in the test app. Or `make TESTS_ALL=1` to build the test app with all the tests for components having `test` subdirectory.
|
* `make TEST_COMPONENTS=` with `TEST_COMPONENTS` set to names of the components to be included in the test app. Or `make TESTS_ALL=1` to build the test app with all the tests for components having `test` subdirectory.
|
||||||
* Follow the printed instructions to flash, or run `make flash`.
|
* Follow the printed instructions to flash, or run `make flash`.
|
||||||
|
|
||||||
|
# Running Unit Tests
|
||||||
|
|
||||||
|
The unit test loader will prompt by showing a menu of available tests to run:
|
||||||
|
|
||||||
|
* Type a number to run a single test.
|
||||||
|
* `*` to run all tests.
|
||||||
|
* `[tagname]` to run tests with "tag"
|
||||||
|
* `![tagname]` to run tests without "tag" (`![ignore]` is very useful as it runs all CI-enabled tests.)
|
||||||
|
* `"test name here"` to run test with given name
|
||||||
|
@ -97,9 +97,13 @@ void unity_run_all_tests()
|
|||||||
|
|
||||||
void unity_run_tests_with_filter(const char* filter)
|
void unity_run_tests_with_filter(const char* filter)
|
||||||
{
|
{
|
||||||
|
bool invert = filter[0] == '!';
|
||||||
|
if (invert) {
|
||||||
|
filter++;
|
||||||
|
}
|
||||||
for (const struct test_desc_t* test = s_unity_tests_first; test != NULL; test = test->next)
|
for (const struct test_desc_t* test = s_unity_tests_first; test != NULL; test = test->next)
|
||||||
{
|
{
|
||||||
if (strstr(test->desc, filter) != NULL)
|
if ((strstr(test->desc, filter) != NULL) == !invert)
|
||||||
{
|
{
|
||||||
unity_run_single_test(test);
|
unity_run_single_test(test);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user