inc/tree.h \
inc/usage.h \
inc/util.h
+
+SUBDIRS = . test/unit
AC_FUNC_MALLOC
AC_CHECK_FUNCS([atexit])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile
+ test/unit/Makefile])
AC_OUTPUT
#include<log.h>
#include<session.h>
-int setup();
+int setup_logging();
int setup_session();
#endif
}
}
- if(setup()<0) { return EXIT_FAILURE; }
+ if(setup_logging()<0) { return EXIT_FAILURE; }
if(add()<0) { return EXIT_FAILURE; }
#include<setup.h>
-static int setup_logging();
-
-int setup() {
- // logging must be setup first
- if(setup_logging()<0) { return -1; }
-
- return 1;
-}
-
pthread_t logging_thread;
pthread_mutex_t logging_mutex = PTHREAD_MUTEX_INITIALIZER;
-static int setup_logging() {
+int setup_logging() {
if(0!=atexit(&log_entries_clean)) {
perror("atexit");
return -1;
--- /dev/null
+AM_CPPFLAGS = \
+ -DPREFIX=\"/tmp/seeder\" \
+ -Wall \
+ -Werror
+
+EXTRA_DIST = \
+ test_utils.h \
+ util.filter.tests.h
+
+if ENABLE_DEBUG
+else
+AM_CPPFLAGS += \
+ -DNDEBUG
+endif
+
+check_PROGRAMS = util.filter.tests
+TESTS = $(check_PROGRAMS)
+
+if ENABLE_MEMCHECK
+LOG_COMPILER = $(VALGRIND)
+AM_LOG_FLAGS = --leak-check=full -v --track-origins=yes --error-exitcode=1
+endif
+
+common_SOURCES = test_utils.c
+
+common_SOURCES += $(top_srcdir)/src/default.c
+common_SOURCES += $(top_srcdir)/src/log.c
+
+util_filter_tests_SOURCES = \
+ $(common_SOURCES) \
+ util.filter.tests.c
--- /dev/null
+#include<test_utils.h>
+
+void clean() {
+ system("rm -rf " PREFIX);
+}
+
+void reset_env() {
+ clean();
+ setup_env();
+}
+
+void setup_env() {
+ assert(setup_session()==1);
+ assert(defaults()==1);
+ assert(setup_logging()==1);
+}
--- /dev/null
+#ifndef __TEST_UTILS_H_
+#define __TEST_UTILS_H_
+
+#include<assert.h>
+
+#include<default.h>
+#include<setup.h>
+
+void clean();
+void reset_env();
+void setup_env();
+
+#endif
--- /dev/null
+#include<util.filter.tests.h>
+
+int main() {
+ setup_env();
+
+ clean();
+
+ return EXIT_FAILURE;
+}
--- /dev/null
+#ifndef __UTIL_FILTER_TESTS_H_
+#define __UTIL_FILTER_TESTS_H_
+
+#include<test_utils.h>
+
+int main();
+
+#endif