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:
Ivan Grokhotkov 2017-05-12 14:53:46 +08:00
commit 272551301e
6 changed files with 30 additions and 7 deletions

View File

@ -1251,6 +1251,11 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB, TaskFunction_t pxTaskCode
portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending[xPortGetCoreID()] );
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
{
/* Reset the next expected unblock time in case it referred to

View File

@ -31,12 +31,13 @@ static void testthread(void *arg) {
in_int_context=0;
int_handled=0;
TEST_ASSERT(!xPortInIsrContext());
xthal_set_ccompare(2, xthal_get_ccount()+8000000);
esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, 0, &testint, NULL, &handle);
xthal_set_ccompare(1, xthal_get_ccount()+8000000);
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);
TEST_ASSERT(int_handled);
TEST_ASSERT(in_int_context);
esp_intr_free(handle);
TEST_ASSERT_EQUAL_HEX32( ESP_OK, esp_intr_free(handle) );
vTaskDelete(NULL);
}

View File

@ -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);
TEST_ASSERT(delta < 10000);
vQueueDelete(queue);
vTaskDelete(sender_task);
vQueueDelete(queue);
}
}

View File

@ -50,8 +50,8 @@ TEST_CASE("can read from stdin", "[vfs]")
const size_t count = 12;
srand(count);
char* data = (char*) calloc(1, count * 8 + 1);
char* buf = (char*) calloc(1, count * 8 + 1);
char* data = (char*) calloc(1, count * 8 + 2);
char* buf = (char*) calloc(1, count * 8 + 2);
char* p = data;
for (size_t i = 0; i < count; ++i) {
p += sprintf(p, "%08x", rand());
@ -62,6 +62,9 @@ TEST_CASE("can read from stdin", "[vfs]")
size_t cb = fread(buf, 1, len, stdin);
TEST_ASSERT_EQUAL(len, cb);
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, buf, len);
free(data);
free(buf);
}

View File

@ -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 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`.
# 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

View File

@ -97,9 +97,13 @@ void unity_run_all_tests()
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)
{
if (strstr(test->desc, filter) != NULL)
if ((strstr(test->desc, filter) != NULL) == !invert)
{
unity_run_single_test(test);
}