[PATCH] tests: add NO_FORK option
Peter Hutterer
peter.hutterer at who-t.net
Wed Aug 6 15:08:28 PDT 2014
On Wed, Aug 06, 2014 at 11:23:42AM +0200, Marek Chalupa 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>
have a look at libinput/test/litest.c:is_debugger_attached(), you may find
that handy too. it detects if a debugger is already attached and sets the
no-fork environment variable automatically.
Cheers,
Peter
> ---
> 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);
>
> --
> 2.0.4
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
More information about the wayland-devel
mailing list