[PATCH 3/3] tests: add one more test for event-loop signal source

Pekka Paalanen ppaalanen at gmail.com
Mon Aug 18 03:18:30 PDT 2014


On Tue, 12 Aug 2014 11:35:07 +0200
Marek Chalupa <mchqwerty at gmail.com> wrote:

> Test if when we get a signal, all signal sources for that signal
> get dispatched.
> 
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
>  tests/event-loop-test.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
> index e327a66..1709a1a 100644
> --- a/tests/event-loop-test.c
> +++ b/tests/event-loop-test.c
> @@ -173,6 +173,44 @@ TEST(event_loop_signal)
>  	wl_event_loop_destroy(loop);
>  }
>  
> +TEST(event_loop_multiple_same_signals)
> +{
> +	struct wl_event_loop *loop = wl_event_loop_create();
> +	struct wl_event_source *s1, *s2;
> +	int calls_no = 0;
> +	int i;
> +
> +	s1 = wl_event_loop_add_signal(loop, SIGUSR1,
> +				      signal_callback, &calls_no);
> +	assert(s1);
> +
> +	s2 = wl_event_loop_add_signal(loop, SIGUSR1,
> +				      signal_callback, &calls_no);
> +	assert(s2);
> +
> +	assert(wl_event_loop_dispatch(loop, 0) == 0);
> +	assert(!calls_no);
> +
> +	/* Try it more times */
> +	for (i = 0; i < 5; ++i) {
> +		calls_no = 0;
> +		kill(getpid(), SIGUSR1);
> +		assert(wl_event_loop_dispatch(loop, 0) == 0);
> +		assert(calls_no == 2);
> +	}
> +
> +	wl_event_source_remove(s1);
> +
> +	/* Try it again  with one source */
> +	calls_no = 0;
> +	kill(getpid(), SIGUSR1);
> +	assert(wl_event_loop_dispatch(loop, 0) == 0);
> +	assert(calls_no == 1);
> +
> +	wl_event_source_remove(s2);
> +
> +	wl_event_loop_destroy(loop);
> +}
>  
>  static int
>  timer_callback(void *data)

The first two of the three patches pushed. We have an explicit configure
check from SFD_CLOEXEC, but I suppose we don't need to add one for
SFD_NONBLOCK, because the two were supposedly introduced at the same
time in glibc.

I did not push this third patch, because in my testing, the test failed
once. It was very hard, but I did manage to trigger it a second time
too, by having lots of CPU and IO load on the machine and running the
test in loop until it failed:

test "event_loop_destroy":      exit status 0, pass.
event-loop-test: tests/event-loop-test.c:298: event_loop_timer_updates: Assertion `context.count == 2' failed.
test "event_loop_timer_updates":        signal 6, fail.
test "event_loop_timer":        exit status 0, pass.
test "event_loop_multiple_same_signals":        exit status 0, pass.
test "event_loop_signal":       exit status 0, pass.
test "event_loop_free_source_with_data":        exit status 0, pass.
test "event_loop_post_dispatch_check":  exit status 0, pass.
7 tests, 6 pass, 1 fail

I would like to see some fix on that, even if only theoretical, before
I push this one.

Or an ack from someone else that we should just push this and wait for
the fallout if any.


Thanks,
pq


More information about the wayland-devel mailing list