New test flag to suppress logging for one test.

svn:r1466
This commit is contained in:
Nick Mathewson 2009-10-27 04:03:50 +00:00
parent 7f10fac342
commit ed0e91e02a
3 changed files with 16 additions and 2 deletions

View File

@ -75,12 +75,13 @@ extern const struct testcase_setup_t basic_setup;
extern const struct testcase_setup_t legacy_setup; extern const struct testcase_setup_t legacy_setup;
void run_legacy_test_fn(void *ptr); void run_legacy_test_fn(void *ptr);
/* A couple of flags that legacy_setup can support. */ /* A couple of flags that basic/legacy_setup can support. */
#define TT_NEED_SOCKETPAIR TT_FIRST_USER_FLAG #define TT_NEED_SOCKETPAIR TT_FIRST_USER_FLAG
#define TT_NEED_BASE (TT_FIRST_USER_FLAG<<1) #define TT_NEED_BASE (TT_FIRST_USER_FLAG<<1)
#define TT_NEED_DNS (TT_FIRST_USER_FLAG<<2) #define TT_NEED_DNS (TT_FIRST_USER_FLAG<<2)
#define TT_LEGACY (TT_FIRST_USER_FLAG<<3) #define TT_LEGACY (TT_FIRST_USER_FLAG<<3)
#define TT_NEED_THREADS (TT_FIRST_USER_FLAG<<4) #define TT_NEED_THREADS (TT_FIRST_USER_FLAG<<4)
#define TT_NO_LOGS (TT_FIRST_USER_FLAG<<5)
/* All the flags that a legacy test needs. */ /* All the flags that a legacy test needs. */
#define TT_ISOLATED TT_FORK|TT_NEED_SOCKETPAIR|TT_NEED_BASE #define TT_ISOLATED TT_FORK|TT_NEED_SOCKETPAIR|TT_NEED_BASE

View File

@ -406,6 +406,7 @@ test_evbuffer_add_file(void *ptr)
static void * static void *
failing_malloc(size_t how_much) failing_malloc(size_t how_much)
{ {
errno = ENOMEM;
return NULL; return NULL;
} }
@ -1249,7 +1250,7 @@ struct testcase_t evbuffer_testcases[] = {
{ "reserve2", test_evbuffer_reserve2, 0, NULL, NULL }, { "reserve2", test_evbuffer_reserve2, 0, NULL, NULL },
{ "reference", test_evbuffer_reference, 0, NULL, NULL }, { "reference", test_evbuffer_reference, 0, NULL, NULL },
{ "iterative", test_evbuffer_iterative, 0, NULL, NULL }, { "iterative", test_evbuffer_iterative, 0, NULL, NULL },
{ "readln", test_evbuffer_readln, 0, NULL, NULL }, { "readln", test_evbuffer_readln, TT_NO_LOGS, &basic_setup, NULL },
{ "find", test_evbuffer_find, 0, NULL, NULL }, { "find", test_evbuffer_find, 0, NULL, NULL },
{ "ptr_set", test_evbuffer_ptr_set, 0, NULL, NULL }, { "ptr_set", test_evbuffer_ptr_set, 0, NULL, NULL },
{ "search", test_evbuffer_search, 0, NULL, NULL }, { "search", test_evbuffer_search, 0, NULL, NULL },

View File

@ -120,6 +120,11 @@ regress_make_tmpfile(const void *data, size_t datalen)
#endif #endif
} }
static void
ignore_log_cb(int s, const char *msg)
{
}
static void * static void *
basic_test_setup(const struct testcase_t *testcase) basic_test_setup(const struct testcase_t *testcase)
{ {
@ -173,6 +178,9 @@ basic_test_setup(const struct testcase_t *testcase)
return NULL; /* fast failure */ /*XXX asserts. */ return NULL; /* fast failure */ /*XXX asserts. */
} }
if (testcase->flags & TT_NO_LOGS)
event_set_log_callback(ignore_log_cb);
data = calloc(1, sizeof(*data)); data = calloc(1, sizeof(*data));
if (!data) if (!data)
exit(1); exit(1);
@ -187,6 +195,10 @@ static int
basic_test_cleanup(const struct testcase_t *testcase, void *ptr) basic_test_cleanup(const struct testcase_t *testcase, void *ptr)
{ {
struct basic_test_data *data = ptr; struct basic_test_data *data = ptr;
if (testcase->flags & TT_NO_LOGS)
event_set_log_callback(NULL);
if (testcase->flags & TT_NEED_SOCKETPAIR) { if (testcase->flags & TT_NEED_SOCKETPAIR) {
if (data->pair[0] != -1) if (data->pair[0] != -1)
EVUTIL_CLOSESOCKET(data->pair[0]); EVUTIL_CLOSESOCKET(data->pair[0]);