[PATCH] tests: add NO_FORK option
Marek Chalupa
mchqwerty at gmail.com
Fri Aug 8 07:52:22 PDT 2014
On 08/08/14 16:27, Pekka Paalanen wrote:
> 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?
Of course, I'm stupid. It is enough :)
I was debugging a test and this did not come to my mind (so I wrote this
patch - it worked for me that time - and later sent it here)
However, I'll take a look at Peter's note about automatic attaching the
debuger, maybe it could be useful.
> Also, run_test() always calls exit(), so you'd be only ever running the
> first test?
>
>
> Thanks,
> pq
Thanks,
Marek
More information about the wayland-devel
mailing list