littlefs/runners/test_runner.h
Christopher Haster d683f1c76c Reintroduced test-defines into the new test_runner
This moves defines entirely into the runtime of the test_runner,
simplifying thing and reducing the amount of generated code that needs
to be build, at the cost of limiting test-defines to uintmax_t types.

This is implemented using a set of index-based scopes (created by
test.py) that allow different layers to override defines from other
layers, accessible through the global `test_define` function.

layers:
1. command-line overrides
2. per-case defines
3. per-geometry defines
2022-04-17 21:45:47 -05:00

62 lines
1.4 KiB
C

#ifndef TEST_RUNNER_H
#define TEST_RUNNER_H
#include "lfs.h"
// generated test configurations
enum test_type {
TEST_NORMAL = 0x1,
TEST_REENTRANT = 0x2,
TEST_VALGRIND = 0x4,
};
struct test_case {
const char *id;
const char *name;
const char *path;
uint8_t types;
size_t permutations;
const uintmax_t *const *defines;
const bool *define_mask;
bool (*filter)(struct lfs_config *cfg, uint32_t perm);
void (*run)(struct lfs_config *cfg, uint32_t perm);
};
struct test_suite {
const char *id;
const char *name;
const char *path;
const char *const *define_names;
size_t define_count;
const struct test_case *const *cases;
size_t case_count;
};
// TODO remove this indirection
extern const struct test_suite *test_suites[];
extern const size_t test_suite_count;
// access generated test defines
uintmax_t test_define(size_t define);
// a few preconfigured defines that control how tests run
#define READ_SIZE test_define(0)
#define PROG_SIZE test_define(1)
#define BLOCK_SIZE test_define(2)
#define BLOCK_COUNT test_define(3)
#define BLOCK_CYCLES test_define(4)
#define CACHE_SIZE test_define(5)
#define LOOKAHEAD_SIZE test_define(6)
#define ERASE_VALUE test_define(7)
#define ERASE_CYCLES test_define(8)
#define BADBLOCK_BEHAVIOR test_define(9)
#endif