Ken Van Hoeylandt f943c4dd69
Move tests to relevant subprojects (#615)
- Moved test projects to the parent project they belong to
- Improved test stability/corectness
- Improved recursive directory deletion by safely ignoring current- and parent-directory entries.
- Update docs
2026-08-13 23:01:12 +02:00

65 lines
1.2 KiB
C++

#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"
#include <cstdio>
#include <cstdlib>
#include "FreeRTOS.h"
#include "task.h"
typedef struct {
int argc;
char** argv;
int result;
} TestTaskData;
void test_task(void* parameter) {
auto* data = (TestTaskData*)parameter;
doctest::Context context;
context.applyCommandLine(data->argc, data->argv);
// overrides
context.setOption("no-breaks", true); // don't break in the debugger when assertions fail
data->result = context.run();
vTaskEndScheduler();
vTaskDelete(nullptr);
}
int main(int argc, char** argv) {
TestTaskData data = {
.argc = argc,
.argv = argv,
.result = 0
};
BaseType_t task_result = xTaskCreate(
test_task,
"test_task",
8192,
&data,
1,
nullptr
);
if (task_result != pdPASS) {
return 1;
}
vTaskStartScheduler();
return data.result;
}
// NOTE: This is normally provided by the platform kernel module, but that's not loaded for crypt-module
extern "C" {
// Required for FreeRTOS
void vAssertCalled(unsigned long line, const char* const file) {
std::fprintf(stderr, "assert failed at %s:%lu\n", file, line);
std::abort();
}
}