From: Nick Mathewson Date: Wed, 26 May 2010 17:18:30 +0000 (-0400) Subject: Remove the now-obsolete setup_test() and cleanup_test() functions X-Git-Tag: release-2.0.6-rc~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e73f1d792a1c3e8e97a0339fbc20c062c880669a;p=libevent Remove the now-obsolete setup_test() and cleanup_test() functions --- diff --git a/test/regress.c b/test/regress.c index c230e1db..5d8a6f0b 100644 --- a/test/regress.c +++ b/test/regress.c @@ -297,54 +297,14 @@ combined_write_cb(evutil_socket_t fd, short event, void *arg) exit(1); } -/* Test infrastructure */ - -static int -setup_test(const char *name) -{ - if (in_legacy_test_wrapper) - return 0; - - fprintf(stdout, "%s", name); - - if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) { - fprintf(stderr, "%s: socketpair\n", __func__); - exit(1); - } - - if (evutil_make_socket_nonblocking(pair[0]) == -1) - fprintf(stderr, "fcntl(O_NONBLOCK)"); - - if (evutil_make_socket_nonblocking(pair[1]) == -1) - fprintf(stderr, "fcntl(O_NONBLOCK)"); - - test_ok = 0; - called = 0; - return (0); -} - -static int -cleanup_test(void) -{ - if (in_legacy_test_wrapper) - return 0; - -#ifndef WIN32 - close(pair[0]); - close(pair[1]); -#else - CloseHandle((HANDLE)pair[0]); - CloseHandle((HANDLE)pair[1]); -#endif - if (test_ok) - fprintf(stdout, "OK\n"); - else { - fprintf(stdout, "FAILED\n"); - exit(1); - } - test_ok = 0; - return (0); -} +/* These macros used to replicate the work of the legacy test wrapper code */ +#define setup_test(x) do { \ + if (!in_legacy_test_wrapper) { \ + TT_FAIL(("Legacy test %s not wrapped properly", x)); \ + return; \ + } \ + } while (0) +#define cleanup_test() setup_test("cleanup") static void test_simpleread(void)