Testing framework for TLE92466ED driver examples on ESP32-C6.
More...
#include "esp_log.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "driver/gpio.h"
Go to the source code of this file.
Testing framework for TLE92466ED driver examples on ESP32-C6.
This file provides testing infrastructure including:
- Test result tracking
- Execution timing
- FreeRTOS task-based test execution
- GPIO14 progress indicator
- Standardized test execution macros
Adapted from HardFOC Internal Interface Wrap test framework
- Author
- N3b3x
- Date
- 2025-10-21
- Version
- 2.0.0
◆ RUN_TEST
| #define RUN_TEST |
( |
| test_func | ) |
|
Value:do { \
ensure_gpio14_initialized(); \
ESP_LOGI(
TAG,
"╔══════════════════════════════════════════════════════════════════════════════╗"); \
ESP_LOGI(
TAG,
"║ Running: " #test_func
" "); \
ESP_LOGI(
TAG,
"╚══════════════════════════════════════════════════════════════════════════════╝"); \
uint64_t start_time = esp_timer_get_time(); \
bool result = test_func(); \
uint64_t end_time = esp_timer_get_time(); \
uint64_t execution_time = end_time - start_time; \
if (result) { \
ESP_LOGI(
TAG,
"[SUCCESS] PASSED: " #test_func
" (%.2f ms)", execution_time / 1000.0); \
} else { \
ESP_LOGE(
TAG,
"[FAILED] FAILED: " #test_func
" (%.2f ms)", execution_time / 1000.0); \
} \
flip_test_progress_indicator(); \
vTaskDelay(pdMS_TO_TICKS(100)); \
} while (0)
static const char * TAG
Definition BasicUsageExample.cpp:30
static TestResults g_test_results
Definition TLE92466ED_TestFramework.hpp:161
void add_result(bool passed, uint64_t execution_time) noexcept
Definition TLE92466ED_TestFramework.hpp:127
Run a test function inline (no separate task)
◆ RUN_TEST_IN_TASK
| #define RUN_TEST_IN_TASK |
( |
| name, |
|
|
| func, |
|
|
| stack_size_bytes, |
|
|
| priority ) |
Run a test in its own FreeRTOS task.
◆ RUN_TEST_SECTION_IF_ENABLED
| #define RUN_TEST_SECTION_IF_ENABLED |
( |
| enabled, |
|
|
| section_name, |
|
|
| ... ) |
Value:do { \
if (enabled) { \
ESP_LOGI(
TAG,
"╔══════════════════════════════════════════════════════════════════════════════╗"); \
ESP_LOGI(
TAG,
"║ SECTION: %-69s║", section_name); \
ESP_LOGI(
TAG,
"╚══════════════════════════════════════════════════════════════════════════════╝"); \
output_section_indicator(5); \
__VA_ARGS__ \
} \
} while (0)
Run a test section with indicator pattern.
◆ RUN_TEST_SECTION_IF_ENABLED_WITH_PATTERN
| #define RUN_TEST_SECTION_IF_ENABLED_WITH_PATTERN |
( |
| enabled, |
|
|
| section_name, |
|
|
| blink_count, |
|
|
| ... ) |
Value:do { \
if (enabled) { \
ESP_LOGI(
TAG,
"╔══════════════════════════════════════════════════════════════════════════════╗"); \
ESP_LOGI(
TAG,
"║ SECTION: %-69s║", section_name); \
ESP_LOGI(
TAG,
"╚══════════════════════════════════════════════════════════════════════════════╝"); \
output_section_indicator(blink_count); \
__VA_ARGS__ \
} \
} while (0)
Run a test section with custom blink pattern.
◆ cleanup_test_progress_indicator()
| void cleanup_test_progress_indicator |
( |
| ) |
|
|
inlinenoexcept |
Cleanup GPIO14 indicator.
◆ ensure_gpio14_initialized()
| void ensure_gpio14_initialized |
( |
| ) |
|
|
inlinenoexcept |
Ensure GPIO14 is initialized.
◆ flip_test_progress_indicator()
| void flip_test_progress_indicator |
( |
| ) |
|
|
inlinenoexcept |
Toggle GPIO14 to indicate test progression.
◆ init_test_progress_indicator()
| bool init_test_progress_indicator |
( |
| ) |
|
|
inlinenoexcept |
Initialize GPIO14 as test progression indicator.
◆ output_section_indicator()
| void output_section_indicator |
( |
uint8_t | blink_count = 5 | ) |
|
|
inlinenoexcept |
Blink GPIO14 to indicate section start/end.
◆ print_test_section_status()
| void print_test_section_status |
( |
const char * | tag, |
|
|
const char * | module_name ) |
|
inline |
Print section configuration status.
◆ test_task_trampoline()
| void test_task_trampoline |
( |
void * | param | ) |
|
|
inline |
FreeRTOS task trampoline for test execution.
◆ g_gpio14_initialized
| bool g_gpio14_initialized = false |
|
static |
◆ g_gpio14_state
| bool g_gpio14_state = false |
|
static |
◆ g_test_results
◆ TEST_PROGRESS_PIN
| constexpr gpio_num_t TEST_PROGRESS_PIN = GPIO_NUM_14 |
|
staticconstexpr |