[PATCH] tests: add NO_FORK option

Pekka Paalanen ppaalanen at gmail.com
Fri Aug 8 07:27:44 PDT 2014


On Wed,  6 Aug 2014 11:23:42 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:

> When WAYLAND_TEST_NO_FORK environment variable is set, then
> do not run the test in fork. It's convenient for debugging
> 
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
>  tests/test-runner.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/test-runner.c b/tests/test-runner.c
> index 8f3d5d3..4f363a0 100644
> --- a/tests/test-runner.c
> +++ b/tests/test-runner.c
> @@ -137,7 +137,7 @@ int main(int argc, char *argv[])
>  {
>  	const struct test *t;
>  	pid_t pid;
> -	int total, pass;
> +	int total, pass, no_fork = 0;
>  	siginfo_t info;
>  
>  	/* Load system malloc, free, and realloc */
> @@ -147,6 +147,7 @@ int main(int argc, char *argv[])
>  	sys_free = dlsym(RTLD_NEXT, "free");
>  
>  	leak_check_enabled = !getenv("NO_ASSERT_LEAK_CHECK");
> +	no_fork = !!getenv("WAYLAND_TESTS_NO_FORK");
>  
>  	if (argc == 2 && strcmp(argv[1], "--help") == 0)
>  		usage(argv[0], EXIT_SUCCESS);
> @@ -165,6 +166,12 @@ int main(int argc, char *argv[])
>  	for (t = &__start_test_section; t < &__stop_test_section; t++) {
>  		int success = 0;
>  
> +		/* no_fork option is useful for debuging */
> +		if (no_fork) {
> +			run_test(t);
> +			continue;
> +		}
> +
>  		pid = fork();
>  		assert(pid >= 0);
>  

Hi,

you can already just pass a test name as an argument, which makes only
that test run and not fork. When is that not enough?

Also, run_test() always calls exit(), so you'd be only ever running the
first test?


Thanks,
pq


More information about the wayland-devel mailing list