]> granicus.if.org Git - libevent/commitdiff
Patch from Zack Weinberg: normalize perror() tt functions and add tt_fail/tt_abort_printf
authorNick Mathewson <nickm@torproject.org>
Mon, 13 Jul 2009 20:03:00 +0000 (20:03 +0000)
committerNick Mathewson <nickm@torproject.org>
Mon, 13 Jul 2009 20:03:00 +0000 (20:03 +0000)
svn:r1340

test/regress_dns.c
test/regress_et.c
test/regress_zlib.c
test/tinytest_macros.h

index 75cf5e4b756c6389357a71fcfa5305bed5c7734c..2ee544bffad7375b07d1a5ccbe19eb18bc2d5045 100644 (file)
@@ -356,7 +356,7 @@ dns_server(void)
        /* Now configure a nameserver port. */
        sock = socket(AF_INET, SOCK_DGRAM, 0);
         if (sock<=0) {
-                tt_fail_perror("socket");
+                tt_abort_perror("socket");
         }
 
         evutil_make_socket_nonblocking(sock);
@@ -366,7 +366,7 @@ dns_server(void)
        my_addr.sin_port = htons(35353);
        my_addr.sin_addr.s_addr = htonl(0x7f000001UL);
        if (bind(sock, (struct sockaddr*)&my_addr, sizeof(my_addr)) < 0) {
-               tt_fail_perror("bind");
+               tt_abort_perror("bind");
        }
        port = evdns_add_server_port(sock, 0, dns_server_request_cb, NULL);
 
index c1930a44fe8a84c6337b29854f9eb7ab73ad0f83..f4762d9abd05fef64ebc6cf4b6971a439a4eaecb 100644 (file)
@@ -90,7 +90,7 @@ test_edgetriggered(void *et)
        int success;
 
        if (evutil_socketpair(LOCAL_SOCKETPAIR_AF, SOCK_STREAM, 0, pair) == -1) {
-               tt_fail_perror("socketpair");
+               tt_abort_perror("socketpair");
        }
 
        called = was_et = 0;
index 966bb1477be05467ce85d4ddda13acd41e3bfe69..25cba6df25772fd9974a99f3fc26a21005ad5a9f 100644 (file)
@@ -261,7 +261,7 @@ test_bufferevent_zlib(void *arg)
             = errorcb_invoked = 0;
 
        if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) {
-               tt_fail_perror("socketpair");
+               tt_abort_perror("socketpair");
        }
 
        evutil_make_socket_nonblocking(pair[0]);
index b1a4729f5a9c3d7de4065c1e17beb36866c04efe..e3373d98b11deeef78f85600f1c1ed72d0cfffea 100644 (file)
        TT_STMT_END
 
 /* Fail and abort the current test for the reason in msg */
-#define tt_abort_msg(msg) TT_DIE((msg))
-#define tt_abort() tt_fail_msg("(Failed.)")
+#define tt_abort_printf(msg) TT_DIE(msg)
+#define tt_abort_perror(op) TT_DIE(("%s: %s [%d]",(op),strerror(errno), errno))
+#define tt_abort_msg(msg) TT_DIE(("%s", msg))
+#define tt_abort() TT_DIE(("%s", "(Failed.)"))
 
 /* Fail but do not abort the current test for the reason in msg. */
-#define tt_fail_msg(msg) TT_FAIL((msg))
-#define tt_fail() tt_fail_msg("(Failed.)")
+#define tt_fail_printf(msg) TT_FAIL(msg)
+#define tt_fail_perror(op) TT_FAIL(("%s: %s [%d]",(op),strerror(errno), errno))
+#define tt_fail_msg(msg) TT_FAIL(("%s", msg))
+#define tt_fail() TT_FAIL(("%s", "(Failed.)"))
 
 /* End the current test, and indicate we are skipping it. */
 #define tt_skip()                               \
        tt_assert_test_type(a,b,#a" "#op" "#b,const char *,             \
                            (strcmp(_val1,_val2) op 0),"<%s>")
 
-/** Fail and log the errno as with perror. */
-#define tt_fail_perror(op)                                     \
-       TT_STMT_BEGIN                                           \
-       TT_DIE(("%s: %s [%d]",(op),strerror(errno),errno));     \
-       TT_STMT_END
-
 #endif