From: Nick Mathewson Date: Mon, 13 Jul 2009 20:03:00 +0000 (+0000) Subject: Patch from Zack Weinberg: normalize perror() tt functions and add tt_fail/tt_abort_printf X-Git-Tag: release-2.0.3-alpha~187 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d866f055857794b8bfad93d93b247b2936a4f7a0;p=libevent Patch from Zack Weinberg: normalize perror() tt functions and add tt_fail/tt_abort_printf svn:r1340 --- diff --git a/test/regress_dns.c b/test/regress_dns.c index 75cf5e4b..2ee544bf 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -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); diff --git a/test/regress_et.c b/test/regress_et.c index c1930a44..f4762d9a 100644 --- a/test/regress_et.c +++ b/test/regress_et.c @@ -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; diff --git a/test/regress_zlib.c b/test/regress_zlib.c index 966bb147..25cba6df 100644 --- a/test/regress_zlib.c +++ b/test/regress_zlib.c @@ -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]); diff --git a/test/tinytest_macros.h b/test/tinytest_macros.h index b1a4729f..e3373d98 100644 --- a/test/tinytest_macros.h +++ b/test/tinytest_macros.h @@ -68,12 +68,16 @@ 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() \ @@ -135,10 +139,4 @@ 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