]> granicus.if.org Git - libevent/commitdiff
Remove the now-obsolete setup_test() and cleanup_test() functions
authorNick Mathewson <nickm@torproject.org>
Wed, 26 May 2010 17:18:30 +0000 (13:18 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 26 May 2010 17:43:00 +0000 (13:43 -0400)
test/regress.c

index c230e1db03bf1249492319e1953942d9ef2d52af..5d8a6f0b43249a473114e85cda3d64b5bfc00e9f 100644 (file)
@@ -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)