Start of 5.X work

This commit is contained in:
Sebastien L
2025-03-18 17:38:34 -04:00
parent c0ddf0a997
commit 73bd096f37
442 changed files with 227862 additions and 21075 deletions

View File

@@ -0,0 +1,4 @@
idf_component_register(SRC_DIRS "."
INCLUDE_DIRS "."
REQUIRES unity
PRIV_REQUIRES esp_common log tools services wifi-manager)

View File

@@ -0,0 +1,4 @@
menu "Test Configuration"
rsource "../../main/Kconfig.projbuild"
endmenu

View File

@@ -0,0 +1,32 @@
#include "unity.h"
#include "tools.h" // Assuming tools.h contains init_spiffs and listFiles
#include "test_common_init.h"
#include "tools_spiffs_utils.h"
static const char * TAG = "test_common";
esp_err_t start_ota_return_code=ESP_OK;
void start_ota_set_return(esp_err_t mockreturn){
start_ota_return_code = mockreturn;
}
esp_err_t start_ota(const char * bin_url, char * bin_buffer, uint32_t length) {
ESP_LOGI(TAG,"Received OTA Request url %s/bin buffer size: %d. returning: %s",bin_url,length,esp_err_to_name(start_ota_return_code));
return start_ota_return_code;
}
esp_log_level_t SetLogLevels(esp_log_level_t level) {
esp_log_level_set("*", level);
return esp_log_level_get(TAG);
}
TEST_CASE("Raise Log Level","[test]") {
TEST_ASSERT_TRUE(SetLogLevels(ESP_LOG_DEBUG) == ESP_LOG_DEBUG );
}
TEST_CASE("Lower Log Level","[test]") {
TEST_ASSERT_TRUE(SetLogLevels(ESP_LOG_INFO) == ESP_LOG_INFO );
}
TEST_CASE("List dir content", "[tools]") {
common_test_init();
listFiles("/spiffs");
TEST_ASSERT_TRUE(true);
}

View File

@@ -0,0 +1,11 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "esp_log.h"
#include "esp_system.h"
extern void common_test_init();
void start_ota_set_return(esp_err_t mockreturn);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,77 @@
/* Example test application for testable component.
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <string.h>
#include "unity.h"
#include "esp_log.h"
#include "test_common_init.h"
#include "tools.h" // Assuming tools.h contains init_spiffs and listFiles
#include "freertos/task.h"
#include "network_manager.h"
#include "messaging.h"
#include "tools_spiffs_utils.h"
#include "bootstate.h"
static const char * TAG = "test_runner";
bool spiffs_started=false;
bool dummycond=false;
static EXT_RAM_ATTR RingbufHandle_t messaging;
static void print_banner(const char* text)
{
printf("\n#### %s #####\n\n", text);
}
void common_test_init() {
if(!spiffs_started){
spiffs_started = true;
init_spiffs();
listFiles(spiffs_base_path);
}
}
void app_main() {
esp_log_level_set("*", ESP_LOG_DEBUG);
messaging_service_init();
bootstate_handle_boot();
init_spiffs();
if (esp_log_level_get(TAG) >= ESP_LOG_DEBUG) {
listFiles(spiffs_base_path);
}
// Start the network task at this point; this is critical
// as various subsequent init steps will post events to the queue
network_initialize_task();
// also register a subscriber in case we need to check for results in tests
messaging = messaging_register_subscriber(10, "test_runner");
/* These are the different ways of running registered tests.
* In practice, only one of them is usually needed.
*
* UNITY_BEGIN() and UNITY_END() calls tell Unity to print a summary
* (number of tests executed/failed/ignored) of tests executed between these calls.
*/
UNITY_BEGIN();
unity_run_all_tests();
UNITY_END();
print_banner("Starting interactive test menu");
/* This function will not return, and will be busy waiting for UART input.
* Make sure that task watchdog is disabled if you use this function.
*/
unity_run_menu();
}