Timing report: I (52322) LOG_TEST: === WRITE TIMING REPORT === I (52322) LOG_TEST: Iterations: 200 I (52322) LOG_TEST: Payload size: 39 bytes I (52322) LOG_TEST: Min: 49960 us I (52332) LOG_TEST: Max: 54476 us I (52332) LOG_TEST: Avg: 50005 us I (52342) LOG_TEST: Sector crossings: 2 (max 49983 us) I (52342) LOG_TEST: WDT margin: 4.9s (WDT=5s, worst=54476us) I (52352) LOG_TEST: =========================== so a write takes up to 54ms - not negligible!
50 lines
1.5 KiB
C
50 lines
1.5 KiB
C
#ifndef LOG_TEST_H
|
|
#define LOG_TEST_H
|
|
|
|
#include "freertos/FreeRTOS.h" // Must be FIRST
|
|
#include "freertos/projdefs.h"
|
|
#include "freertos/task.h"
|
|
#include "freertos/queue.h"
|
|
|
|
#include "esp_err.h"
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
// Test result structure
|
|
typedef struct {
|
|
const char* test_name;
|
|
bool passed;
|
|
const char* error_msg;
|
|
} test_result_t;
|
|
|
|
// Main test suite runner
|
|
esp_err_t run_all_log_tests(void);
|
|
|
|
// Individual test functions
|
|
bool test_log_integrity_basic(void);
|
|
bool test_log_integrity_wraparound(void);
|
|
bool test_log_head_tail_recovery_empty(void);
|
|
bool test_log_head_tail_recovery_partial_sector(void);
|
|
bool test_log_head_tail_recovery_full_sectors(void);
|
|
bool test_log_head_tail_recovery_wraparound(void);
|
|
bool test_log_head_equals_tail(void);
|
|
bool test_log_head_zero_tail_zero(void);
|
|
bool test_log_head_greater_than_tail(void);
|
|
bool test_log_head_less_than_tail(void);
|
|
bool test_log_wraparound_multiple_times(void);
|
|
bool test_log_sector_boundary_conditions(void);
|
|
bool test_log_maximum_payload(void);
|
|
bool test_log_minimum_payload(void);
|
|
bool test_log_corrupted_entry_recovery(void);
|
|
bool test_log_full_partition(void);
|
|
bool test_log_read_after_write(void);
|
|
bool test_log_multiple_types(void);
|
|
|
|
// Write timing benchmark (not a pass/fail test — prints min/max/avg report)
|
|
void test_log_write_timing(void);
|
|
|
|
// Helper functions for testing
|
|
void print_test_results(test_result_t* results, int num_tests);
|
|
int count_passed_tests(test_result_t* results, int num_tests);
|
|
|
|
#endif // LOG_TEST_H
|