mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
tests: automatically detect whether or not we can run tests in parallel
This commit is contained in:
parent
0aed1a1b12
commit
b0f4577dd3
2 changed files with 50 additions and 7 deletions
|
@ -6,16 +6,9 @@
|
|||
|
||||
class FpgaState {
|
||||
public:
|
||||
FpgaState() {
|
||||
// force criterion to only run one job at a time
|
||||
setenv("CRITERION_JOBS", "1", 0);
|
||||
}
|
||||
|
||||
// list of all available FPGA cards, only first will be tested at the moment
|
||||
villas::fpga::CardList cards;
|
||||
};
|
||||
|
||||
// global state to be shared by unittests
|
||||
extern FpgaState state;
|
||||
|
||||
|
||||
|
|
|
@ -30,4 +30,54 @@
|
|||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
/** Returns true if there is at least one enabled test in this suite */
|
||||
static bool suite_enabled(struct criterion_test_set *tests, const char *name)
|
||||
{
|
||||
FOREACH_SET(void *suite_ptr, tests->suites) {
|
||||
struct criterion_suite_set *suite = (struct criterion_suite_set *) suite_ptr;
|
||||
|
||||
if (!strcmp(suite->suite.name, name)) {
|
||||
FOREACH_SET(void *test_ptr, suite->tests) {
|
||||
struct criterion_test *test = (struct criterion_test *) test_ptr;
|
||||
|
||||
if (!test->data->disabled)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Limit number of parallel jobs to 1 in case we use the FPGA */
|
||||
ReportHook(PRE_ALL)(struct criterion_test_set *tests) {
|
||||
if (suite_enabled(tests, "fpga")) {
|
||||
auto logger = loggerGetOrCreate("unittest");
|
||||
|
||||
logger->info("FPGA tests enabled. Only 1 job is executed in parallel!.\n");
|
||||
criterion_options.jobs = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
struct criterion_test_set *tests;
|
||||
|
||||
auto logger = loggerGetOrCreate("unittest");
|
||||
spdlog::set_pattern("[%T] [%l] [%n] %v");
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
|
||||
/* Run criterion tests */
|
||||
tests = criterion_initialize();
|
||||
|
||||
ret = criterion_handle_args(argc, argv, true);
|
||||
|
||||
if (ret)
|
||||
ret = !criterion_run_all_tests(tests);
|
||||
|
||||
criterion_finalize(tests);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue