![]() |
no-OS
|
Platform-agnostic test framework source for capi_selftest project. Copyright (c) 2025-2026 Analog Devices, Inc. More...
#include <errno.h>#include <stdarg.h>#include <stddef.h>#include <stdio.h>#include <string.h>#include "test_framework.h"Macros | |
| #define | TEST_FRAMEWORK_BUFFER_SIZE 256U |
Functions | |
| int | test_framework_init (const struct test_framework_config *config) |
| Initialize the test framework. | |
| void | test_framework_remove (void) |
| Remove the test framework configuration. | |
| void | test_framework_reset (void) |
| Reset the current test context and counts. | |
| void | test_framework_run_start (void) |
| Start a test run, reset its counts and arm the watchdog. | |
| void | test_framework_run_end (void) |
| Disarm the watchdog, print the final counts and end the run. | |
| void | test_framework_checkpoint (const char *func, int line) |
| Record the last reached source location (function and line). | |
| void | test_framework_on_timeout (void) |
| Report from the platform watchdog handler that the run hung. | |
| void | test_framework_begin (const char *module, const char *name) |
| Select the current test module and test name. | |
| void | test_framework_set_name (const char *name) |
| Select the current test name. | |
| void | test_framework_begin_uart (const char *backend, const char *name, const char *func, int line) |
| Begin a UART test as a special case. | |
| void | test_framework_pass (void) |
| Record and report a passing test. | |
| void | test_framework_fail (const char *format,...) |
| Record and report a failing test. | |
| void | test_framework_skip (const char *category, const char *message) |
| Record and report a skipped test. | |
| void | test_framework_info (const char *message) |
| Report test information without changing the counts. | |
| void | test_framework_value (const char *name, uint64_t value) |
| Report a named test value without changing the counts. | |
| void | test_framework_section (const char *name) |
| Print a human-readable section marker. | |
| void | test_framework_wait_us (uint32_t duration_us) |
| Invoke the configured microsecond delay callback. | |
| void | test_framework_get_count (struct test_framework_count *count) |
| Read the current test counts. | |
| int | test_framework_run_cases (const char *module, const struct test_case *cases, size_t count) |
| Run a table of test cases, respecting skip flags. | |
Platform-agnostic test framework source for capi_selftest project. Copyright (c) 2025-2026 Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define TEST_FRAMEWORK_BUFFER_SIZE 256U |
| void test_framework_begin | ( | const char * | module, |
| const char * | name ) |
Select the current test module and test name.
| module | - Test module name. |
| name | - Test name. |
| void test_framework_begin_uart | ( | const char * | backend, |
| const char * | name, | ||
| const char * | func, | ||
| int | line ) |
Begin a UART test as a special case.
UART tests can hang (for example when reconfiguring the console UART). This announces the test and records a checkpoint BEFORE the body runs, so a hang is attributable to this exact test. Prefer the TEST_BEGIN_UART() macro.
| backend | - UART backend name. |
| name | - Test name. |
| func | - Enclosing function name (func). |
| line | - Source line number (LINE). |
| void test_framework_checkpoint | ( | const char * | func, |
| int | line ) |
Record the last reached source location (function and line).
Used so a whole-run hang can report where execution stopped. Prefer the TEST_CHECKPOINT() macro over calling this directly. Uses func and LINE rather than FILE: on a microcontroller FILE bakes the full build-host path into flash, while func is a small literal and LINE costs nothing.
| func | - Enclosing function name (func). |
| line | - Source line number (LINE). |
| void test_framework_fail | ( | const char * | format, |
| ... ) |
Record and report a failing test.
| format | - Failure detail format. |
| void test_framework_get_count | ( | struct test_framework_count * | count | ) |
Read the current test counts.
| count | - Destination counts. |
| void test_framework_info | ( | const char * | message | ) |
Report test information without changing the counts.
| message | - Information message. |
| int test_framework_init | ( | const struct test_framework_config * | config | ) |
Initialize the test framework.
| config | - Framework configuration. |
| void test_framework_on_timeout | ( | void | ) |
Report from the platform watchdog handler that the run hung.
Prints the last test context, the last reached source location and the partial counts. Safe to call once from the timeout handler; it does not itself halt the processor.
| void test_framework_pass | ( | void | ) |
Record and report a passing test.
| void test_framework_remove | ( | void | ) |
Remove the test framework configuration.
| void test_framework_reset | ( | void | ) |
Reset the current test context and counts.
| int test_framework_run_cases | ( | const char * | module, |
| const struct test_case * | cases, | ||
| size_t | count ) |
Run a table of test cases, respecting skip flags.
Iterates through the table, calling TEST_BEGIN for each entry:
Every case is visited even if an earlier one fails, so the run summary stays complete; the first non-zero run() result is returned.
| module | - Test module name (passed to TEST_BEGIN). |
| cases | - Array of test cases. |
| count | - Number of entries in the cases array. |
| void test_framework_run_end | ( | void | ) |
Disarm the watchdog, print the final counts and end the run.
| void test_framework_run_start | ( | void | ) |
Start a test run, reset its counts and arm the watchdog.
| void test_framework_section | ( | const char * | name | ) |
Print a human-readable section marker.
| name | - Section name. |
| void test_framework_set_name | ( | const char * | name | ) |
Select the current test name.
| name | - Test name. |
| void test_framework_skip | ( | const char * | category, |
| const char * | message ) |
Record and report a skipped test.
| category | - Optional skip category. |
| message | - Skip reason. |
| void test_framework_value | ( | const char * | name, |
| uint64_t | value ) |
Report a named test value without changing the counts.
| name | - Value name. |
| value | - Value to report. |
| void test_framework_wait_us | ( | uint32_t | duration_us | ) |
Invoke the configured microsecond delay callback.
| duration_us | - Delay duration in microseconds. |