forked from espressif/esp-idf
freertos: Add blank freertos test app
This commit adds a blank FreeRTOS test app in preparation for migrating of FreeRTOS unit tests to the created test app.
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
# For refactored FreeRTOS unit tests, we need to support #include "xxx.h" of FreeRTOS headers
|
||||
idf_component_get_property(FREERTOS_ORIG_INCLUDE_PATH freertos ORIG_INCLUDE_PATH)
|
||||
|
||||
idf_component_register(SRC_DIRS integration # For freertos_test_utils.c
|
||||
integration/event_groups
|
||||
integration/queue
|
||||
integration/stream_buffer
|
||||
integration/tasks
|
||||
integration/timers
|
||||
miscellaneous
|
||||
performance
|
||||
port
|
||||
PRIV_INCLUDE_DIRS . ./integration "${FREERTOS_ORIG_INCLUDE_PATH}"
|
||||
PRIV_REQUIRES cmock test_utils esp_system driver esp_timer)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
16
components/freertos/test_apps/freertos/CMakeLists.txt
Normal file
16
components/freertos/test_apps/freertos/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
# This is the project CMakeLists.txt file for the test subproject
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# FreeRTOS tests of different types (e.g., kernel, port, performance etc.)are
|
||||
# split into different directores in the test app's root directory. Each test
|
||||
# type is treated as separate component
|
||||
set(test_types)
|
||||
|
||||
list(APPEND EXTRA_COMPONENT_DIRS
|
||||
${test_types}) # Add each test type as a component
|
||||
|
||||
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(freertos_test)
|
2
components/freertos/test_apps/freertos/README.md
Normal file
2
components/freertos/test_apps/freertos/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "test_freertos_main.c"
|
||||
PRIV_REQUIRES unity test_utils driver)
|
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_test_runner.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#define TEST_MEMORY_LEAK_THRESHOLD (-256)
|
||||
|
||||
static size_t before_free_8bit;
|
||||
static size_t before_free_32bit;
|
||||
|
||||
static void check_leak(size_t before_free, size_t after_free, const char *type)
|
||||
{
|
||||
ssize_t delta = after_free - before_free;
|
||||
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
|
||||
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
|
||||
}
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
||||
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
unity_run_menu();
|
||||
}
|
13
components/freertos/test_apps/freertos/pytest_freertos.py
Normal file
13
components/freertos/test_apps/freertos/pytest_freertos.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
|
||||
|
||||
@pytest.mark.supported_targets
|
||||
@pytest.mark.generic
|
||||
def test_freertos(dut: Dut) -> None:
|
||||
dut.expect_exact('Press ENTER to see the list of tests')
|
||||
dut.write('*')
|
||||
dut.expect_unity_test_output()
|
Reference in New Issue
Block a user