Basics of test case framework
This commit is contained in:
parent
9dec5dd628
commit
97a46e8c1a
7 changed files with 162 additions and 0 deletions
40
tests/include/testcase.h
Normal file
40
tests/include/testcase.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef _TESTCASE_H
|
||||
#define _TESTCASE_H
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include "esp/uart.h"
|
||||
|
||||
/* Types of test, defined by hardware requirements */
|
||||
typedef enum {
|
||||
SOLO, /* Test require "ESP A" only, no other connections */
|
||||
DUAL, /* Test requires "ESP A" and "ESP "B", basic interconnections between them */
|
||||
EYORE_TEST, /* Test requires an eyore-test board with onboard STM32F0 */
|
||||
} testcase_type_t;
|
||||
|
||||
typedef bool (testcase_fn_t)(void);
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
testcase_type_t type;
|
||||
testcase_fn_t *a_fn;
|
||||
testcase_fn_t *b_fn;
|
||||
} testcase_t;
|
||||
|
||||
|
||||
/* Register a test case using these macros. Use DEFINE_SOLO_TESTCASE for single-MCU tests,
|
||||
and DEFINE_TESTCASE for all other test types.
|
||||
*/
|
||||
#define DEFINE_SOLO_TESTCASE(NAME) \
|
||||
static testcase_fn_t a_##NAME; \
|
||||
const __attribute__((section(".testcases.text"))) __attribute__((used)) \
|
||||
testcase_t testcase_##NAME = { .name = #NAME, .type = SOLO, .a_fn = a_##NAME };
|
||||
|
||||
|
||||
#define DEFINE_TESTCASE(NAME, TYPE) \
|
||||
static testcase_fn_t a_##NAME; \
|
||||
static testcase_fn_t b_##NAME; \
|
||||
const __attribute__((section(".testcases.text"))) __attribute__((used)) \
|
||||
testcase_t testcase_##NAME = { .name = #NAME, .type = TYPE, .a_fn = a_##NAME, .b_fn = b_##NAME };
|
||||
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue