END_OF_TESTCASES
};
-int
-legacy_main(void)
-{
- /* Initalize the event library */
- global_base = event_init();
-
-#if defined(_EVENT_HAVE_PTHREADS) && !defined(_EVENT_DISABLE_THREAD_SUPPORT)
- regress_pthread();
-#endif
-
-#if defined(_EVENT_HAVE_LIBZ)
- regress_zlib();
-#endif
-
- return (0);
-}
-
extern struct testcase_t rpc_testcases[];
extern struct testcase_t edgetriggered_testcases[];
-int legacy_main(void);
-
-void regress_pthread(void);
-void regress_zlib(void);
+void regress_threads(void *);
+void test_bufferevent_zlib(void *);
/* Helpers to wrap old testcases */
extern int pair[2];
#include <errno.h>
#include <assert.h>
+#include "event-config.h"
#include "event2/event.h"
#include "event2/event_struct.h"
#include "event2/event_compat.h"
LEGACY(bufferevent, TT_ISOLATED),
LEGACY(bufferevent_watermarks, TT_ISOLATED),
LEGACY(bufferevent_filters, TT_ISOLATED),
+#ifdef _EVENT_HAVE_LIBZ
+ LEGACY(bufferevent_zlib, TT_ISOLATED),
+#else
+ { "bufferevent_zlib", NULL, TT_SKIP, NULL, NULL },
+#endif
END_OF_TESTCASES,
};
#include <event2/dns.h>
#include <event2/dns_compat.h>
+#include "event-config.h"
#include "regress.h"
#include "tinytest.h"
#include "tinytest_macros.h"
/* ============================================================ */
+struct testcase_t thread_testcases[] = {
+#if defined(_EVENT_HAVE_PTHREADS) && !defined(_EVENT_DISABLE_THREAD_SUPPORT)
+ { "pthreads", regress_threads, TT_FORK, NULL, NULL, },
+#else
+ { "pthreads", NULL, TT_SKIP, NULL, NULL },
+#endif
+ END_OF_TESTCASES
+};
+
struct testgroup_t testgroups[] = {
- { "main/", legacy_testcases },
- { "et/", edgetriggered_testcases },
- { "evbuffer/", evbuffer_testcases },
- { "signal/", signal_testcases },
- { "util/", util_testcases },
- { "bufferevent/", bufferevent_testcases },
- { "http/", http_testcases },
- { "dns/", dns_testcases },
- { "rpc/", rpc_testcases },
+ { "main/", legacy_testcases },
+ { "et/", edgetriggered_testcases },
+ { "evbuffer/", evbuffer_testcases },
+ { "signal/", signal_testcases },
+ { "util/", util_testcases },
+ { "bufferevent/", bufferevent_testcases },
+ { "http/", http_testcases },
+ { "dns/", dns_testcases },
+ { "rpc/", rpc_testcases },
+ { "thread/", thread_testcases },
END_OF_GROUPS
};
if (tinytest_main(argc,argv,testgroups))
return 1;
- in_legacy_test_wrapper = 0;
- return legacy_main();
+ return 0;
}
#include "event2/event.h"
#include "event2/event_struct.h"
#include "event2/thread.h"
-
-void regress_pthread(void);
+#include "regress.h"
+#include "tinytest_macros.h"
struct cond_wait {
pthread_mutex_t lock;
struct timeval tv;
int i;
- fprintf(stdout, "Testing basic pthreads support: ");
-
for (i = 0; i < NUM_THREADS; ++i)
pthread_create(&threads[i], NULL, basic_thread, base);
pthread_join(threads[i], NULL);
event_del(&ev);
-
- fprintf(stdout, "OK\n");
}
void
-regress_pthread(void)
+regress_threads(void *arg)
{
struct event_base *base;
+ (void) arg;
pthread_mutex_init(&count_lock, NULL);
base = event_base_new();
if (evthread_make_base_notifiable(base)<0) {
- puts("Couldn't make base notifiable!");
- return;
+ tt_abort_msg("Couldn't make base notifiable!");
}
pthread_basic(base);
pthread_mutex_destroy(&count_lock);
event_base_free(base);
+end:
+ ;
}
#include <zlib.h>
#include <assert.h>
+#include <errno.h>
#include "event2/util.h"
#include "event2/event.h"
#include "event2/buffer.h"
#include "event2/bufferevent.h"
-void regress_zlib(void);
+#include "regress.h"
static int infilter_calls;
static int outfilter_calls;
errorcb_invoked = 1;
}
-static void
-test_bufferevent_zlib(void)
+void
+test_bufferevent_zlib(void *arg)
{
- struct bufferevent *bev1, *bev2, *bev1_orig, *bev2_orig;
+ struct bufferevent *bev1=NULL, *bev2=NULL, *bev1_orig, *bev2_orig;
char buffer[8333];
z_stream z_input, z_output;
- int i, pair[2], r;
- int test_ok;
+ int i, pair[2]={-1,-1}, r;
+ (void)arg;
infilter_calls = outfilter_calls = readcb_finished = writecb_finished
= errorcb_invoked = 0;
- fprintf(stdout, "Testing Zlib Filter: ");
-
if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) {
- fprintf(stderr, "%s: socketpair\n", __func__);
- exit(1);
+ tt_fail_perror("socketpair");
}
evutil_make_socket_nonblocking(pair[0]);
memset(&z_output, 0, sizeof(z_output));
r = deflateInit(&z_output, Z_DEFAULT_COMPRESSION);
- assert(r == Z_OK);
+ tt_int_op(r, ==, Z_OK);
memset(&z_input, 0, sizeof(z_input));
r = inflateInit(&z_input);
/* initialize filters */
bev1 = bufferevent_filter_new(bev1, NULL, zlib_output_filter, 0,
- zlib_deflate_free, &z_output);
+ zlib_deflate_free, &z_output);
bev2 = bufferevent_filter_new(bev2, zlib_input_filter,
- NULL, 0, zlib_inflate_free, &z_input);
+ NULL, 0, zlib_inflate_free, &z_input);
bufferevent_setcb(bev1, readcb, writecb, errorcb, NULL);
bufferevent_setcb(bev2, readcb, writecb, errorcb, NULL);
-
bufferevent_disable(bev1, EV_READ);
bufferevent_enable(bev1, EV_WRITE);
event_dispatch();
- bufferevent_free(bev1);
- bufferevent_free(bev2);
-
-
- test_ok = infilter_calls &&
- outfilter_calls &&
- readcb_finished &&
- writecb_finished &&
- !errorcb_invoked;
-
- if (! test_ok) {
- fprintf(stdout, "FAILED: %d\n", test_ok);
- exit(1);
- }
-
-#ifndef WIN32
- close(pair[0]);
- close(pair[1]);
-#else
- CloseHandle((HANDLE)pair[0]);
- CloseHandle((HANDLE)pair[1]);
-#endif
-
- fprintf(stdout, "OK\n");
-}
-
-void
-regress_zlib(void)
-{
- test_bufferevent_zlib();
+ tt_want(infilter_calls);
+ tt_want(outfilter_calls);
+ tt_want(readcb_finished);
+ tt_want(writecb_finished);
+ tt_want(!errorcb_invoked);
+
+ test_ok = 1;
+end:
+ if (bev1)
+ bufferevent_free(bev1);
+ if (bev2)
+ bufferevent_free(bev2);
+
+ if (pair[0] >= 0)
+ EVUTIL_CLOSESOCKET(pair[0]);
+ if (pair[1] >= 0)
+ EVUTIL_CLOSESOCKET(pair[1]);
}