From 2ccc447e21a3e0836594c9c77162489f9f72be1e Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 12 Oct 2008 10:19:39 +0200 Subject: [PATCH] Fix tst-filters (use latest API). Signed-off-by: Florent Bruneau --- postlicyd/filter.h | 2 +- postlicyd/tst-filters.c | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/postlicyd/filter.h b/postlicyd/filter.h index f4511dd..10effbc 100644 --- a/postlicyd/filter.h +++ b/postlicyd/filter.h @@ -262,7 +262,7 @@ bool filter_test(const filter_t *filter, const query_t *query, /* Filter context */ -__attribute__((nonnull)) +__attribute__((nonnull(1))) void filter_context_prepare(filter_context_t *context, void* qctx); __attribute__((nonnull)) diff --git a/postlicyd/tst-filters.c b/postlicyd/tst-filters.c index 9de410c..63ca7e6 100644 --- a/postlicyd/tst-filters.c +++ b/postlicyd/tst-filters.c @@ -87,6 +87,9 @@ static bool run_testcase(const config_t *config, const char *basepath, } bool ok = true; + filter_context_t context; + filter_context_prepare(&context, NULL); + while (eol < end) { char *neol = memchr(eol, '\n', end - eol); if (neol == NULL) { @@ -122,9 +125,11 @@ static bool run_testcase(const config_t *config, const char *basepath, printf(" test %s: %s\n", Name, __test ? "SUCCESS" : "FAILED"); \ ok = ok && __test; \ } while (0) - TEST(filter->name, filter_test(filter, &query, result)); + TEST(filter->name, filter_test(filter, &query, &context, result)); eol = neol + 1; + } + filter_context_wipe(&context); return ok; } @@ -162,20 +167,24 @@ static bool run_greylisttest(const config_t *config, const char *basepath) // FILTER(greylist2); #undef FILTER + filter_context_t context; + filter_context_prepare(&context, NULL); + /* Test greylist */ - TEST("greylisted", filter_test(greylist1, &q1, HTK_GREYLIST)); - TEST("too_fast", filter_test(greylist1, &q1, HTK_GREYLIST)); + TEST("greylisted", filter_test(greylist1, &q1, &context, HTK_GREYLIST)); + TEST("too_fast", filter_test(greylist1, &q1, &context, HTK_GREYLIST)); sleep(5); - TEST("too_slow", filter_test(greylist1, &q1, HTK_GREYLIST)); + TEST("too_slow", filter_test(greylist1, &q1, &context, HTK_GREYLIST)); sleep(2); - TEST("whitelisted", filter_test(greylist1, &q1, HTK_WHITELIST)); - TEST("other_greylisted", filter_test(greylist1, &q2, HTK_GREYLIST)); - TEST("auto_whitelisted", filter_test(greylist1, &q1, HTK_WHITELIST)); - TEST("other_auto_whitelisted", filter_test(greylist1, &q2, HTK_WHITELIST)); - TEST("greylisted", filter_test(greylist1, &q3, HTK_GREYLIST)); + TEST("whitelisted", filter_test(greylist1, &q1, &context, HTK_WHITELIST)); + TEST("other_greylisted", filter_test(greylist1, &q2, &context, HTK_GREYLIST)); + TEST("auto_whitelisted", filter_test(greylist1, &q1, &context, HTK_WHITELIST)); + TEST("other_auto_whitelisted", filter_test(greylist1, &q2, &context, HTK_WHITELIST)); + TEST("greylisted", filter_test(greylist1, &q3, &context, HTK_GREYLIST)); sleep(10); - TEST("cleanup", filter_test(greylist1, &q1, HTK_GREYLIST)); + TEST("cleanup", filter_test(greylist1, &q1, &context, HTK_GREYLIST)); + filter_context_wipe(&context); return ok; } -- 2.20.1