<br><div class="gmail_quote">On Fri, Feb 15, 2013 at 7:56 AM, Philip Withnall <span dir="ltr"><<a href="mailto:philip@tecnocode.co.uk" target="_blank">philip@tecnocode.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There’s a bug in FreeBSD’s handling of timer events which means we have to<br>
be more relaxed about how we check when timer events have happened because<br>
FreeBSD can’t manage enough precision on scheduling the events.<br>
<br>
Signed-off-by: Philip Withnall <<a href="mailto:philip@tecnocode.co.uk">philip@tecnocode.co.uk</a>><br>
---<br>
 tests/event-loop-test.c | 22 ++++++++++++++++------<br>
 1 file changed, 16 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c<br>
index c46d3b0..cf9dabe 100644<br>
--- a/tests/event-loop-test.c<br>
+++ b/tests/event-loop-test.c<br>
@@ -155,10 +155,11 @@ TEST(event_loop_signal)<br>
<br>
        source = wl_event_loop_add_signal(loop, SIGUSR1,<br>
                                          signal_callback, &got_it);<br>
-       wl_event_loop_dispatch(loop, 0);<br>
+       assert(source);<br>
+       assert(wl_event_loop_dispatch(loop, 0) == 0);<br></blockquote><div><br></div><div>You shouldn't put code with side effects inside asserts, since it'll be compiled out in release mode.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

        assert(!got_it);<br>
-       kill(getpid(), SIGUSR1);<br>
-       wl_event_loop_dispatch(loop, 0);<br>
+       assert(kill(getpid(), SIGUSR1) == 0);<br>
+       assert(wl_event_loop_dispatch(loop, 0) == 0);<br>
        assert(got_it);<br>
<br>
        wl_event_source_remove(source);<br>
@@ -183,12 +184,21 @@ TEST(event_loop_timer)<br>
        int got_it = 0;<br>
<br>
        source = wl_event_loop_add_timer(loop, timer_callback, &got_it);<br>
-       wl_event_source_timer_update(source, 10);<br>
-       wl_event_loop_dispatch(loop, 0);<br>
+       assert(source);<br>
+       assert(wl_event_source_timer_update(source, 10) == 0);<br>
+       assert(wl_event_loop_dispatch(loop, 0) == 0);<br>
        assert(!got_it);<br>
-       wl_event_loop_dispatch(loop, 20);<br>
+       /* FreeBSD has a bug where it converts ms_timeout to ticks; it always adds 1 to the tick count.<br>
+        * Consequently, we need to grossly overcompensate here.<br>
+        * See: <a href="http://unix.derkeiler.com/Mailing-Lists/FreeBSD/hackers/2012-07/msg00319.html" target="_blank">http://unix.derkeiler.com/Mailing-Lists/FreeBSD/hackers/2012-07/msg00319.html</a> */<br>
+       assert(wl_event_loop_dispatch(loop, 50) == 0);<br>
        assert(got_it);<br>
<br>
+       /* Check it doesn't fire again. */<br>
+       got_it = 0;<br>
+       assert(wl_event_loop_dispatch(loop, 20) == 0);<br>
+       assert(!got_it);<br>
+<br>
        wl_event_source_remove(source);<br>
        wl_event_loop_destroy(loop);<br>
 }<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.7<br>
<br>
</font></span><br>_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
<br></blockquote></div><br>