size_t max_forks;
unsigned int timeout;
bool verbose;
+ bool exit_on_fail;
int terminating;
runner->verbose = verbose;
}
+void
+litest_runner_set_exit_on_fail(struct litest_runner *runner, bool do_exit)
+{
+ runner->exit_on_fail = do_exit;
+}
+
void
litest_runner_add_test(struct litest_runner *runner,
const struct litest_runner_test_description *desc)
if (runner->terminating) {
break;
}
+
+ if (runner->exit_on_fail) {
+ bool do_exit = false;
+ struct litest_runner_test *complete;
+ list_for_each(complete, &runner->tests_complete, node) {
+ switch (complete->result) {
+ case LITEST_FAIL:
+ case LITEST_SYSTEM_ERROR:
+ case LITEST_TIMEOUT:
+ do_exit = true;
+ break;
+ default:
+ break;
+ }
+ if (do_exit)
+ break;
+ }
+ if (do_exit)
+ break;
+ }
}
while (!runner->terminating && !list_empty(&runner->tests_running)) {
void litest_runner_set_num_parallel(struct litest_runner *runner, size_t num_jobs);
void litest_runner_set_timeout(struct litest_runner *runner, unsigned int timeout);
void litest_runner_set_verbose(struct litest_runner *runner, bool verbose);
+void litest_runner_set_exit_on_fail(struct litest_runner *runner, bool do_exit);
void litest_runner_add_test(struct litest_runner *runner,
const struct litest_runner_test_description *t);
enum litest_runner_result litest_runner_run_tests(struct litest_runner *runner);
static bool verbose = false;
static bool run_deviceless = false;
static bool use_system_rules_quirks = false;
+static bool exit_first = false;
static const char *filter_test = NULL;
static const char *filter_device = NULL;
static const char *filter_group = NULL;
litest_runner_set_num_parallel(runner, jobs > 0 ? jobs : 0);
litest_runner_set_verbose(runner, verbose);
litest_runner_set_timeout(runner, 30);
+ litest_runner_set_exit_on_fail(runner, exit_first);
list_for_each(s, suites, node) {
struct test *t;
litest_parse_argv(int argc, char **argv)
{
enum {
+ OPT_EXIT_FIRST,
OPT_FILTER_TEST,
OPT_FILTER_DEVICE,
OPT_FILTER_GROUP,
{ "filter-device", 1, 0, OPT_FILTER_DEVICE },
{ "filter-group", 1, 0, OPT_FILTER_GROUP },
{ "filter-deviceless", 0, 0, OPT_FILTER_DEVICELESS },
+ { "exitfirst", 0, 0, OPT_EXIT_FIRST },
{ "xml-output", 1, 0, OPT_XML_PREFIX },
{ "jobs", 1, 0, OPT_JOBS },
{ "list", 0, 0, OPT_LIST },
int c;
int option_index = 0;
- c = getopt_long(argc, argv, "j:", opts, &option_index);
+ c = getopt_long(argc, argv, "j:x", opts, &option_index);
if (c == -1)
break;
switch(c) {
printf("Usage: %s [--verbose] [--jobs] [--filter-...]\n"
"\n"
"Options:\n"
+ " -x | --exitfirst\n"
+ " Exit instantly on first failed test\n"
" --filter-test=.... \n"
" Glob to filter on test names\n"
" --filter-device=.... \n"
case OPT_FILTER_DEVICELESS:
run_deviceless = true;
break;
+ case 'x':
+ case OPT_EXIT_FIRST:
+ exit_first = true;
+ break;
}
}