]> granicus.if.org Git - libevent/commitdiff
Use new timeval diff comparison function in bufferevent test
authorNick Mathewson <nickm@torproject.org>
Wed, 24 Feb 2010 04:59:26 +0000 (23:59 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 24 Feb 2010 04:59:26 +0000 (23:59 -0500)
test/regress_bufferevent.c

index 1f2e30afffcb845a94dcd74591a743c72da7bad8..ab89d9fc84141bca38fcd8ce1cfcbb054ad9c7d8 100644 (file)
@@ -621,15 +621,6 @@ struct timeout_cb_result {
        int total_calls;
 };
 
-static long
-msec_diff(const struct timeval *start, const struct timeval *end)
-{
-       long ms = end->tv_sec - start->tv_sec;
-       ms *= 1000;
-       ms += ((end->tv_usec - start->tv_usec)+500) / 1000;
-       return ms;
-}
-
 static void
 bev_timeout_write_cb(struct bufferevent *bev, void *arg)
 {
@@ -753,10 +744,8 @@ test_bufferevent_timeouts(void *arg)
        tt_want(res1.n_read_timeouts == 1);
        tt_want(res1.n_write_timeouts == 1);
 
-       tt_int_op(abs(msec_diff(&started_at, &res1.read_timeout_at)-150),
-           <=, 40);
-       tt_int_op(abs(msec_diff(&started_at, &res1.write_timeout_at)-100),
-           <=, 30);
+       test_timeval_diff_eq(&started_at, &res1.read_timeout_at, 150);
+       test_timeval_diff_eq(&started_at, &res1.write_timeout_at, 100);
 
 end:
        if (bev1)