initial refactoring

This commit is contained in:
Sebastien L
2023-12-04 23:25:57 -05:00
parent d03678ea81
commit c0ddf0a997
331 changed files with 29663 additions and 16553 deletions

View File

@@ -1,9 +1,9 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
# Include the components directory of the main application:
#
set(EXTRA_COMPONENT_DIRS "../components")
# Set the components to include the tests for.
# This can be overriden from CMake cache:
@@ -11,9 +11,42 @@ set(EXTRA_COMPONENT_DIRS "../components")
# - when using idf.py: idf.py -T xxxxx build
#
set(TEST_COMPONENTS "platform_console" CACHE STRING "List of components to test")
set(COMPONENTS main)
# Freertos is included via common components, however, currently only the mock component is compatible with linux
# target.
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/driver/")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/spi_flash/")
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/components/unity/")
idf_build_set_property(COMPILE_DEFINITIONS "-DNO_DEBUG_STORAGE" APPEND)
# list(APPEND EXTRA_COMPONENT_DIRS "${PROJECT_SOURCE_DIR}/../components")
# list(APPEND EXTRA_COMPONENT_DIRS "${PROJECT_SOURCE_DIR}/../components/tools")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(squeezelite_esp32_test)
add_definitions(-include "${PROJECT_SOURCE_DIR}/../build/config/sdkconfig.h")
# add_definitions(-include "${PROJECT_SOURCE_DIR}/../build/config/sdkconfig.h")
set_property(TARGET squeezelite_esp32_test.elf PROPERTY RECOVERY_PREFIX app_update )
add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build/coverage.info"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build"
COMMAND lcov --capture --directory . --output-file coverage.info
COMMENT "Create coverage report"
)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/build/coverage_report/"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build/coverage.info"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build"
COMMAND genhtml coverage.info --output-directory coverage_report/
COMMENT "Turn coverage report into html-based visualization"
)
add_custom_target(coverage
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build"
DEPENDS "coverage_report/"
)

View File

@@ -1,2 +1,2 @@
idf_component_register(SRCS "unit_tests.c"
INCLUDE_DIRS ".")
INCLUDE_DIRS "." "${PROJECT_SOURCE_DIR}/../components/tools" REQUIRES unity )

View File

@@ -47,7 +47,8 @@
#include "squeezelite-ota.h"
#include <math.h>
#include "audio_controls.h"
#include "platform_config.h"
// #include "Configurator.h"
#pragma message("fixme: search for TODO below")
#include "telnet.h"
#include "messaging.h"
#include "gds.h"
@@ -78,6 +79,8 @@ void init_commands(){
register_config_cmd();
register_nvs();
register_i2ctools();
#if CONFIG_WITH_CONFIG_UI
#endif
}
void test_init()
{
@@ -111,6 +114,13 @@ void app_main()
unity_run_menu();
}
int main(int argc, char **argv)
{
setbuf(stdout, NULL);
app_main();
return 0;
}
static void print_banner(const char* text)
{
printf("\n#### %s #####\n\n", text);

3
test/sdkconfig.defaults Normal file
View File

@@ -0,0 +1,3 @@
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
CONFIG_IDF_TARGET="linux"
CONFIG_COMPILER_CXX_EXCEPTIONS=y