mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-06 00:40:34 +00:00
test: add a filter for iteration
Debugging is easier if we can explicitly run a single iteration only. This filter could be a range but for now it's sufficient to be able to run a single test only.
This commit is contained in:
parent
82de0613d6
commit
3f6521819f
|
@ -130,6 +130,8 @@ struct pwtest_context {
|
||||||
bool no_fork;
|
bool no_fork;
|
||||||
|
|
||||||
const char *test_filter;
|
const char *test_filter;
|
||||||
|
bool has_iteration_filter;
|
||||||
|
int iteration_filter;
|
||||||
char *xdg_dir;
|
char *xdg_dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1109,6 +1111,10 @@ static int run_tests(struct pwtest_context *ctx)
|
||||||
bool have_range = min != 0 || max != 1;
|
bool have_range = min != 0 || max != 1;
|
||||||
|
|
||||||
for (int iteration = min; iteration < max; iteration++) {
|
for (int iteration = min; iteration < max; iteration++) {
|
||||||
|
if (ctx->has_iteration_filter &&
|
||||||
|
ctx->iteration_filter != iteration)
|
||||||
|
continue;
|
||||||
|
|
||||||
fprintf(stderr, " - name: \"%s\"\n", t->name);
|
fprintf(stderr, " - name: \"%s\"\n", t->name);
|
||||||
if (have_range)
|
if (have_range)
|
||||||
fprintf(stderr, " iteration: %d # %d - %d\n",
|
fprintf(stderr, " iteration: %d # %d - %d\n",
|
||||||
|
@ -1192,6 +1198,7 @@ static void usage(FILE *fp, const char *progname)
|
||||||
" --timeout=N Set the test timeout to N seconds (default: 30)\n"
|
" --timeout=N Set the test timeout to N seconds (default: 30)\n"
|
||||||
" --filter-test=glob Run only tests matching the given glob\n"
|
" --filter-test=glob Run only tests matching the given glob\n"
|
||||||
" --filter-suites=glob Run only suites matching the given glob\n"
|
" --filter-suites=glob Run only suites matching the given glob\n"
|
||||||
|
" --filter-iteration=N Run only iteration N\n"
|
||||||
" --no-fork Do not fork for the test (see note below)\n"
|
" --no-fork Do not fork for the test (see note below)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Using --no-fork allows for easy debugging of tests but should only be used.\n"
|
"Using --no-fork allows for easy debugging of tests but should only be used.\n"
|
||||||
|
@ -1209,6 +1216,7 @@ int main(int argc, char **argv)
|
||||||
OPT_VERBOSE,
|
OPT_VERBOSE,
|
||||||
OPT_FILTER_TEST,
|
OPT_FILTER_TEST,
|
||||||
OPT_FILTER_SUITE,
|
OPT_FILTER_SUITE,
|
||||||
|
OPT_FILTER_ITERATION,
|
||||||
OPT_NOFORK,
|
OPT_NOFORK,
|
||||||
};
|
};
|
||||||
static const struct option opts[] = {
|
static const struct option opts[] = {
|
||||||
|
@ -1217,6 +1225,7 @@ int main(int argc, char **argv)
|
||||||
{ "list", no_argument, 0, OPT_LIST },
|
{ "list", no_argument, 0, OPT_LIST },
|
||||||
{ "filter-test", required_argument, 0, OPT_FILTER_TEST },
|
{ "filter-test", required_argument, 0, OPT_FILTER_TEST },
|
||||||
{ "filter-suite", required_argument, 0, OPT_FILTER_SUITE },
|
{ "filter-suite", required_argument, 0, OPT_FILTER_SUITE },
|
||||||
|
{ "filter-iteration", required_argument, 0, OPT_FILTER_ITERATION },
|
||||||
{ "list", no_argument, 0, OPT_LIST },
|
{ "list", no_argument, 0, OPT_LIST },
|
||||||
{ "verbose", no_argument, 0, OPT_VERBOSE },
|
{ "verbose", no_argument, 0, OPT_VERBOSE },
|
||||||
{ "no-fork", no_argument, 0, OPT_NOFORK },
|
{ "no-fork", no_argument, 0, OPT_NOFORK },
|
||||||
|
@ -1225,6 +1234,7 @@ int main(int argc, char **argv)
|
||||||
struct pwtest_context test_ctx = {
|
struct pwtest_context test_ctx = {
|
||||||
.suites = SPA_LIST_INIT(&test_ctx.suites),
|
.suites = SPA_LIST_INIT(&test_ctx.suites),
|
||||||
.timeout = 30,
|
.timeout = 30,
|
||||||
|
.has_iteration_filter = false,
|
||||||
};
|
};
|
||||||
enum {
|
enum {
|
||||||
MODE_TEST,
|
MODE_TEST,
|
||||||
|
@ -1260,6 +1270,9 @@ int main(int argc, char **argv)
|
||||||
case OPT_FILTER_SUITE:
|
case OPT_FILTER_SUITE:
|
||||||
suite_filter= optarg;
|
suite_filter= optarg;
|
||||||
break;
|
break;
|
||||||
|
case OPT_FILTER_ITERATION:
|
||||||
|
ctx->has_iteration_filter = spa_atoi32(optarg, &ctx->iteration_filter, 10);
|
||||||
|
break;
|
||||||
case OPT_NOFORK:
|
case OPT_NOFORK:
|
||||||
ctx->no_fork = true;
|
ctx->no_fork = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -141,6 +141,9 @@ extern "C" {
|
||||||
* Disabling forking makes it easy to debug but should always be used with
|
* Disabling forking makes it easy to debug but should always be used with
|
||||||
* `--filter-test`. Any test that modifies its environment will affect
|
* `--filter-test`. Any test that modifies its environment will affect
|
||||||
* subsequent tests and may invalidate the test results.
|
* subsequent tests and may invalidate the test results.
|
||||||
|
*
|
||||||
|
* Where a test has multiple iterations, use `--filter-iteration` to only run
|
||||||
|
* one single iteration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue