[PATCH 1/3] tests: make event-loop-test more explicit

Marek Chalupa mchqwerty at gmail.com
Tue Aug 12 02:35:05 PDT 2014


Check value set in handler against an explicit value instead of:
  assert(value);

also add one assert() for non-NULL value.
---
 tests/event-loop-test.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
index 655de87..e327a66 100644
--- a/tests/event-loop-test.c
+++ b/tests/event-loop-test.c
@@ -37,7 +37,7 @@ fd_dispatch(int fd, uint32_t mask, void *data)
 	int *p = data;
 
 	assert(mask == 0);
-	*p = 1;
+	++(*p);
 
 	return 0;
 }
@@ -58,7 +58,7 @@ TEST(event_loop_post_dispatch_check)
 	wl_event_source_check(source);
 
 	wl_event_loop_dispatch(loop, 0);
-	assert(dispatch_ran);
+	assert(dispatch_ran == 1);
 
 	assert(close(p[0]) == 0);
 	assert(close(p[1]) == 0);
@@ -148,7 +148,7 @@ signal_callback(int signal_number, void *data)
 	int *got_it = data;
 
 	assert(signal_number == SIGUSR1);
-	*got_it = 1;
+	++(*got_it);
 
 	return 1;
 }
@@ -161,11 +161,13 @@ TEST(event_loop_signal)
 
 	source = wl_event_loop_add_signal(loop, SIGUSR1,
 					  signal_callback, &got_it);
+	assert(source);
+
 	wl_event_loop_dispatch(loop, 0);
 	assert(!got_it);
 	kill(getpid(), SIGUSR1);
 	wl_event_loop_dispatch(loop, 0);
-	assert(got_it);
+	assert(got_it == 1);
 
 	wl_event_source_remove(source);
 	wl_event_loop_destroy(loop);
@@ -177,7 +179,7 @@ timer_callback(void *data)
 {
 	int *got_it = data;
 
-	*got_it = 1;
+	++(*got_it);
 
 	return 1;
 }
@@ -194,7 +196,7 @@ TEST(event_loop_timer)
 	wl_event_loop_dispatch(loop, 0);
 	assert(!got_it);
 	wl_event_loop_dispatch(loop, 20);
-	assert(got_it);
+	assert(got_it == 1);
 
 	wl_event_source_remove(source);
 	wl_event_loop_destroy(loop);
-- 
2.0.4



More information about the wayland-devel mailing list