for (size_t i = 0, j = 0; i < ARRAY_SIZE(suites); i++, j = 0) \
while ((suite = suites[i][j++]) != NULL)
- for_each_suite(t)
+ for_each_suite(t) {
+ if (t->setup) {
+ int ret = t->setup(t);
+
+ if (ret < 0) {
+ errno = -ret;
+ return NULL;
+ }
+ }
num_suites++;
+ }
result = calloc(num_suites + 1, sizeof(struct test_suite *));
+ if (!result)
+ return NULL;
for (int pass = 1; pass <= 2; pass++) {
for_each_suite(t) {
argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0);
if (argc >= 1 && !strcmp(argv[0], "list")) {
suites = build_suites();
+ if (!suites)
+ return errno ? -errno : -ENOMEM;
ret = perf_test__list(stdout, suites, argc - 1, argv + 1);
free(suites);
return ret;
rlimit__bump_memlock();
suites = build_suites();
+ if (!suites)
+ return errno ? -errno : -ENOMEM;
ret = __cmd_test(suites, argc, argv, skiplist);
free(suites);
return ret;
const char *skip_reason;
test_fnptr run_case;
bool exclusive;
+ void *priv;
};
struct test_suite {
const char *desc;
struct test_case *test_cases;
void *priv;
+ int (*setup)(struct test_suite *suite);
};
#define DECLARE_SUITE(name) \