test_programs = \
test-auth-cache \
- test-auth-request-var-expand \
- test-username-filter \
- test-db-dict
+ test-auth
noinst_PROGRAMS = $(test_programs)
+noinst_HEADERS = test-auth.h
+
test_libs = \
- ../lib-test/libtest.la \
- ../lib/liblib.la
+ ../lib-dovecot/libdovecot.la
test_auth_cache_SOURCES = auth-cache.c test-auth-cache.c
test_auth_cache_LDADD = $(test_libs)
# this is needed to force auth-cache.c recompilation
test_auth_cache_CPPFLAGS = $(AM_CPPFLAGS)
-test_auth_request_var_expand_SOURCES = test-auth-request-var-expand.c
-test_auth_request_var_expand_LDADD = $(test_libs) libauth.la
-test_auth_request_var_expand_DEPENDENCIES = $(pkglibexec_PROGRAMS) $(test_libs)
-
-test_username_filter_SOURCES = test-username-filter.c
-test_username_filter_LDADD = $(test_libs) $(auth_libs) $(AUTH_LIBS) $(LIBDOVECOT)
-test_username_filter_DEPENDENCIES = $(pkglibexec_PROGRAMS) $(test_libs) $(LIBDOVECOT_DEPS)
-
-test_db_dict_SOURCES = test-db-dict.c
-test_db_dict_LDADD = $(test_libs) libauth.la
-test_db_dict_DEPENDENCIES = $(pkglibexec_PROGRAMS) $(test_libs)
+test_auth_SOURCES = \
+ test-auth-request-var-expand.c \
+ test-username-filter.c \
+ test-db-dict.c \
+ test-mock.c \
+ test-main.c
+test_auth_LDADD = $(test_libs) $(auth_libs) $(AUTH_LIBS)
+test_auth_DEPENDENCIES = $(pkglibexec_PROGRAMS) $(test_libs)
check: check-am check-test
check-test: all-am
/* Copyright (c) 2015-2017 Dovecot authors, see the included COPYING file */
-#include "lib.h"
+#include "test-auth.h"
#include "str.h"
#include "auth.h"
#include "passdb.h"
#include "userdb.h"
#include "auth-request.h"
-#include "test-common.h"
static struct passdb_module test_passdb = {
.id = 40
test_end();
}
-int main(void)
+void test_auth_request_var_expand(void)
{
- static void (*const test_functions[])(void) = {
- test_auth_request_var_expand_shortlong,
- test_auth_request_var_expand_flags,
- test_auth_request_var_expand_long,
- test_auth_request_var_expand_usernames,
- test_auth_request_var_expand_funcs,
- NULL
- };
-
default_test_request.local_ip.u.ip4.s_addr = htonl(123456789);
default_test_request.remote_ip.u.ip4.s_addr = htonl(1234567890);
default_test_request.real_local_ip.u.ip4.s_addr = htonl(223456788);
default_test_request.real_remote_ip.u.ip4.s_addr = htonl(223456789);
test_request = default_test_request;
- return test_run(test_functions);
+
+ test_auth_request_var_expand_shortlong();
+ test_auth_request_var_expand_flags();
+ test_auth_request_var_expand_long();
+ test_auth_request_var_expand_usernames();
+ test_auth_request_var_expand_funcs();
}
--- /dev/null
+/* Copyright (c) 2017 Dovecot authors, see the included COPYING file */
+
+#ifndef TEST_AUTH_H
+#define TEST_AUTH_H 1
+
+#include "lib.h"
+#include "test-common.h"
+
+void test_auth_request_var_expand(void);
+void test_db_dict_parse_cache_key(void);
+void test_username_filter(void);
+
+#endif
+
/* Copyright (c) 2013-2017 Dovecot authors, see the included COPYING file */
-#include "lib.h"
+#include "test-auth.h"
#include "array.h"
#include "db-dict.h"
-#include "test-common.h"
-static void test_db_dict_parse_cache_key(void)
+void test_db_dict_parse_cache_key(void)
{
struct db_dict_key keys[] = {
{ "key0", "%d and %n", NULL, NULL, 0 },
"\t%d and %n\t%l\t%{foo}%r%{bar}\t%{test1}/path\t%{extra}\tpath2/%{test2}\t%{plop}") == 0);
test_end();
}
-
-int main(void)
-{
- static void (*const test_functions[])(void) = {
- test_db_dict_parse_cache_key,
- NULL
- };
- return test_run(test_functions);
-}
--- /dev/null
+#include "lib.h"
+#include "test-common.h"
+#include "test-auth.h"
+
+int main(int argc, const char *argv[])
+{
+ const char *match = "";
+ static const struct named_test test_functions[] = {
+ TEST_NAMED(test_auth_request_var_expand)
+ TEST_NAMED(test_db_dict_parse_cache_key)
+ TEST_NAMED(test_username_filter)
+ { NULL, NULL }
+ };
+
+ if (argc > 2 && strcasecmp(argv[1], "--match") == 0)
+ match = argv[2];
+
+ return test_run_named(test_functions, match);
+}
--- /dev/null
+#include "lib.h"
+#include "auth-common.h"
+
+struct auth_penalty *auth_penalty;
+time_t process_start_time;
+bool worker, worker_restart_request;
+void auth_module_load(const char *names ATTR_UNUSED)
+{
+}
+void auth_refresh_proctitle(void) {
+}
/* Copyright (c) 2017 Dovecot authors, see the included COPYING file */
-#include "lib.h"
-#include "test-common.h"
-#include "auth-common.h"
+#include "test-auth.h"
#include "auth-request.h"
-struct auth_penalty *auth_penalty;
-time_t process_start_time;
-bool worker, worker_restart_request;
-void auth_module_load(const char *names ATTR_UNUSED)
-{
-}
-void auth_refresh_proctitle(void) {
-}
-static void test_username_filter(void)
+void test_username_filter(void)
{
const struct {
const char *filter;
test_end();
}
-
-int main(void)
-{
- static void (*const test_functions[])(void) = {
- test_username_filter,
- NULL
- };
-
- return test_run(test_functions);
-}