2016-02-08 03:15:12 +00:00
|
|
|
#ifndef _TESTCASE_H
|
|
|
|
#define _TESTCASE_H
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "esp/uart.h"
|
|
|
|
|
2016-02-09 10:03:50 +00:00
|
|
|
/* Unity is the framework with test assertions, etc. */
|
|
|
|
#include "unity.h"
|
|
|
|
|
|
|
|
/* Need to explicitly flag once a test has completed successfully. */
|
2016-02-24 11:14:00 +00:00
|
|
|
#define TEST_PASS() do { UnityConcludeTest(); while(1) { } } while (0)
|
2016-02-09 10:03:50 +00:00
|
|
|
|
2016-02-08 03:15:12 +00:00
|
|
|
/* 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;
|
|
|
|
|
2016-02-09 10:03:50 +00:00
|
|
|
typedef void (testcase_fn_t)(void);
|
2016-02-08 03:15:12 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2016-02-16 21:28:56 +00:00
|
|
|
const char *name;
|
|
|
|
const char *file;
|
|
|
|
int line;
|
2016-02-08 03:15:12 +00:00
|
|
|
testcase_type_t type;
|
|
|
|
testcase_fn_t *a_fn;
|
|
|
|
testcase_fn_t *b_fn;
|
|
|
|
} testcase_t;
|
|
|
|
|
2016-02-16 21:28:56 +00:00
|
|
|
void testcase_register(const testcase_t *testcase);
|
2016-02-08 03:15:12 +00:00
|
|
|
|
|
|
|
/* Register a test case using these macros. Use DEFINE_SOLO_TESTCASE for single-MCU tests,
|
|
|
|
and DEFINE_TESTCASE for all other test types.
|
2016-02-09 10:03:50 +00:00
|
|
|
*/
|
|
|
|
#define DEFINE_SOLO_TESTCASE(NAME) \
|
|
|
|
static testcase_fn_t a_##NAME; \
|
|
|
|
_DEFINE_TESTCASE_COMMON(NAME, SOLO, a_##NAME, 0)
|
|
|
|
|
|
|
|
#define DEFINE_TESTCASE(NAME, TYPE) \
|
|
|
|
static testcase_fn_t a_##NAME; \
|
|
|
|
static testcase_fn_t b_##NAME; \
|
|
|
|
_DEFINE_TESTCASE_COMMON(NAME, TYPE, A_##NAME, B_##NAME)
|
|
|
|
|
|
|
|
|
2016-02-16 21:28:56 +00:00
|
|
|
#define _DEFINE_TESTCASE_COMMON(NAME, TYPE, A_FN, B_FN) \
|
2016-02-09 10:03:50 +00:00
|
|
|
void __attribute__((constructor)) testcase_ctor_##NAME() { \
|
2016-02-16 21:28:56 +00:00
|
|
|
const testcase_t testcase = { .name = #NAME, \
|
|
|
|
.file = __FILE__, \
|
|
|
|
.line = __LINE__, \
|
|
|
|
.type = TYPE, \
|
|
|
|
.a_fn = A_FN, \
|
|
|
|
.b_fn = B_FN, \
|
|
|
|
}; \
|
|
|
|
testcase_register(&testcase); \
|
2016-02-09 10:03:50 +00:00
|
|
|
}
|
2016-02-08 03:15:12 +00:00
|
|
|
|
|
|
|
#endif
|