+static bool run_greylisttest(const config_t *config, const char *basepath)
+{
+ char buff_q1[BUFSIZ];
+ char buff_q2[BUFSIZ];
+ char buff_q3[BUFSIZ];
+ query_t q1;
+ query_t q2;
+ query_t q3;
+ bool ok = true;
+
+ filter_t *greylist1;
+// filter_t *greylist2;
+
+#define QUERY(Q) \
+ if (read_query(basepath, "greylist_" STR(Q), buff_##Q, NULL, &Q) == NULL) { \
+ return false; \
+ }
+ 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
+
+ /* Test greylist */
+ TEST("greylisted", filter_test(greylist1, &q1, HTK_GREYLIST));
+ TEST("too_fast", filter_test(greylist1, &q1, HTK_GREYLIST));
+ sleep(5);
+ TEST("too_slow", filter_test(greylist1, &q1, 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));
+ sleep(10);
+ TEST("cleanup", filter_test(greylist1, &q1, HTK_GREYLIST));
+
+ return ok;
+}
+