+ QUERY(q1);
+ QUERY(q2);
+ QUERY(q3);
+#undef QUERY
+
+#define FILTER(F) \
+ do { \
+ int __p = filter_find_with_name(&config->filters, STR(F)); \
+ if (__p < 0) { \
+ return false; \
+ } \
+ F = array_ptr(config->filters, __p); \
+ } while (0)
+ FILTER(greylist1);
+// FILTER(greylist2);
+#undef FILTER
+
+ filter_context_t context;
+ filter_context_prepare(&context, NULL);
+
+ /* Test 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, &context, HTK_GREYLIST));
+ sleep(2);
+ 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, &context, HTK_GREYLIST));
+
+ filter_context_wipe(&context);