esp-idf/components/driver/test/param_test/param_test.c
michael d9c5016e08 test: add new test framework for different configurations
Paremeterized Test Framework
-----------------------------

The SPI has a lot of parameters, which works in the same process.
This framework provides a way to easily test different parameter sets.
The framework can work in two different ways:

- local test: which requires only one board to perform the test - master
& slave test: which generates two sub test items which uses the same
config set to cooperate to perform the test.

The user defines a (pair if master/slave) set of init/deinit/loop
functions. Then the test framework will call init once, then call loop
several times with different configurations, then call deinit.

Then a unit test can be appended by add a parameter group, and pass it into
a macro.
2019-01-26 00:10:41 +08:00

22 lines
673 B
C

#include "param_test.h"
#include "esp_log.h"
void test_serializer(const param_group_t *param_group, const ptest_func_t* test_func)
{
ESP_LOGI("test", "run test: %s", param_group->name);
//in this test case, we want to make two devices as similar as possible, so use the same context
void *context = NULL;
test_func->pre_test(&context);
void *pset = param_group->param_group;
for (int i = param_group->pset_num; i >0; i--) {
if (test_func->def_param) test_func->def_param(pset);
test_func->loop(pset, context);
pset+=param_group->pset_size;
}
test_func->post_test(context);
free(context);
context = NULL;
}