X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Fevent-test.c;h=e4c67c5629d983b845585a0f01b409b84708269d;hb=99080c663209a733fd597a2fcab96a45c9c41291;hp=6a3bb15adeb86a6036c99095a280d362a57993fb;hpb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;p=debian%2Famanda diff --git a/common-src/event-test.c b/common-src/event-test.c index 6a3bb15..e4c67c5 100644 --- a/common-src/event-test.c +++ b/common-src/event-test.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Zmanda Inc. All Rights Reserved. + * Copyright (c) 2008,2009 Zmanda, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -14,7 +14,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Contact information: Zmanda Inc, 465 N Mathlida Ave, Suite 300 + * Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com * * Author: Dustin J. Mitchell @@ -58,7 +58,7 @@ test_decrement_cb(void *up G_GNUC_UNUSED) /**** * Test that EV_TIME events fire, repeatedly. */ -static int +static gboolean test_ev_time(void) { global = 2; @@ -74,7 +74,7 @@ test_ev_time(void) /**** * Test that nonblocking waits don't block. */ -static int +static gboolean test_nonblock(void) { global = 1; /* the callback should not be triggered, so this should stay 1 */ @@ -90,24 +90,24 @@ test_nonblock(void) * another iteration of the event loop. Security API depends on callbacks occuring * immediately. */ -static int +static gboolean test_ev_wait(void) { global = 2; hdl[0] = event_register(4422, EV_WAIT, test_decrement_cb, NULL); - if (global != 2) return 0; + if (global != 2) return FALSE; event_wakeup(4422); - if (global != 1) return 0; + if (global != 1) return FALSE; event_wakeup(4422); - if (global != 0) return 0; + if (global != 0) return FALSE; event_wakeup(4422); /* the handler has been removed, but this is not an error */ - if (global != 0) return 0; + if (global != 0) return FALSE; /* queue should now be empty, so this won't block */ event_loop(0); - return 1; + return TRUE; } /**** @@ -131,22 +131,22 @@ test_ev_wait_2_cb(void *up G_GNUC_UNUSED) } } -static int +static gboolean test_ev_wait_2(void) { global = 2; hdl[0] = event_register(84, EV_WAIT, test_ev_wait_2_cb, NULL); /* Each wakeup should only invoke the callback *once* */ - if (global != 2) return 0; + if (global != 2) return FALSE; event_wakeup(84); - if (global != 1) return 0; + if (global != 1) return FALSE; event_wakeup(84); - if (global != 0) return 0; + if (global != 0) return FALSE; event_wakeup(84); /* the handler has been removed, but this is not an error */ - if (global != 0) return 0; + if (global != 0) return FALSE; - return 1; + return TRUE; } /**** @@ -163,7 +163,7 @@ test_event_wait_cb(void *up G_GNUC_UNUSED) event_release(hdl[1]); } -static int +static gboolean test_event_wait(void) { int cb_fired = 0; @@ -183,16 +183,16 @@ test_event_wait(void) * three times */ if (global == 0) { tu_dbg("global is already zero!\n"); - return 0; + return FALSE; } /* and our own callback should have fired */ if (!cb_fired) { tu_dbg("test_event_wait_cb didn't fire\n"); - return 0; + return FALSE; } - return 1; + return TRUE; } /**** @@ -220,7 +220,7 @@ test_event_wait_2_wakeup_cb(void *up G_GNUC_UNUSED) event_wakeup(9876); } -static int +static gboolean test_event_wait_2(void) { int wakeups_remaining = 2; @@ -243,16 +243,16 @@ test_event_wait_2(void) * three times */ if (global == 0) { tu_dbg("global is already zero!\n"); - return 0; + return FALSE; } /* and our own callback should have fired twice, not just once */ if (wakeups_remaining != 0) { tu_dbg("test_event_wait_2_cb didn't fire twice\n"); - return 0; + return FALSE; } - return 1; + return TRUE; } /**** @@ -308,7 +308,7 @@ test_ev_readfd_writer(int fd, size_t count) #define TEST_EV_READFD_SIZE (1024*1024) -static int +static gboolean test_ev_readfd(void) { int writer_pid; @@ -329,7 +329,7 @@ test_ev_readfd(void) case -1: /* error */ perror("fork"); - return 0; + return FALSE; default: /* parent */ break; @@ -350,10 +350,10 @@ test_ev_readfd(void) if (global != 0) { tu_dbg("%d bytes remain unread..\n", global); - return 0; + return FALSE; } - return 1; + return TRUE; } /**** @@ -385,7 +385,7 @@ test_read_timeout_cb(void *up G_GNUC_UNUSED) event_release(hdl[1]); } -static int +static gboolean test_read_timeout(void) { int writer_pid; @@ -406,7 +406,7 @@ test_read_timeout(void) case -1: /* error */ perror("fork"); - return 0; + return FALSE; default: /* parent */ break; @@ -427,9 +427,9 @@ test_read_timeout(void) /* see if we got the sentinel indicating the timeout fired */ if (global != 1234) - return 0; + return FALSE; - return 1; + return TRUE; } /**** @@ -492,7 +492,7 @@ test_ev_writefd_consumer(int fd, size_t count) #define TEST_EV_WRITEFD_SIZE (1024*1024) -static int +static gboolean test_ev_writefd(void) { int reader_pid; @@ -513,7 +513,7 @@ test_ev_writefd(void) case -1: /* error */ perror("fork"); - return 0; + return FALSE; default: /* parent */ break; @@ -535,10 +535,10 @@ test_ev_writefd(void) /* and see what we got */ if (global != 0) { tu_dbg("writes did not complete\n"); - return 0; + return FALSE; } - return 1; + return TRUE; } /**** @@ -569,7 +569,7 @@ test_child_watch_callback( g_main_loop_quit(test_child_watch_main_loop); } -static int +static gboolean test_child_watch_source(void) { int pid, pid2; @@ -583,7 +583,7 @@ test_child_watch_source(void) case -1: /* error */ perror("fork"); - return 0; + return FALSE; default: /* parent */ break; @@ -603,7 +603,7 @@ test_child_watch_source(void) case -1: /* error */ perror("fork"); - return 0; + return FALSE; default: /* parent */ break; @@ -632,16 +632,16 @@ int main(int argc, char **argv) { static TestUtilsTest tests[] = { - TU_TEST(test_ev_time, 10), - TU_TEST(test_ev_wait, 10), - TU_TEST(test_ev_wait_2, 10), - TU_TEST(test_ev_readfd, 60), /* runs slowly on old kernels */ - TU_TEST(test_ev_writefd, 60), - TU_TEST(test_event_wait, 10), - TU_TEST(test_event_wait_2, 10), - TU_TEST(test_nonblock, 10), - TU_TEST(test_read_timeout, 10), - TU_TEST(test_child_watch_source, 5), + TU_TEST(test_ev_time, 90), + TU_TEST(test_ev_wait, 90), + TU_TEST(test_ev_wait_2, 90), + TU_TEST(test_ev_readfd, 120), /* runs slowly on old kernels */ + TU_TEST(test_ev_writefd, 90), + TU_TEST(test_event_wait, 90), + TU_TEST(test_event_wait_2, 90), + TU_TEST(test_nonblock, 90), + TU_TEST(test_read_timeout, 90), + TU_TEST(test_child_watch_source, 90), /* fdsource is used by ev_readfd/ev_writefd, and is sufficiently tested there */ TU_END() };