#include "file.h"
#include <dirent.h>
-#define DAEMON_NAME "tst-filters"
-
-DECLARE_MAIN
-
static char *read_query(const char *basepath, const char *filename,
char *buff, char **end, query_t *q)
{
}
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) {
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;
}
// 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;
}
char path[FILENAME_MAX];
char *p;
+ common_startup();
p = strrchr(argv[0], '/');
if (p == NULL) {
p = argv[0];
#undef RUN
- config_delete(&config);
return 0;
}