-#check_PROGRAMS = \
-# test_datacache_api \
-# perf_datacache_api \
-# perf_plugin_datacache
-#
-#TESTS = $(check_PROGRAMS)
-#
-#test_datacache_api_SOURCES = \
-# test_datacache_api.c
-#test_datacache_api_LDADD = \
-# $(top_builddir)/src/datacache/libgnunetdatacache.la \
-# $(top_builddir)/src/util/libgnunetutil.la
-#
-#perf_datacache_api_SOURCES = \
-# perf_datacache_api.c
-#perf_datacache_api_LDADD = \
-# $(top_builddir)/src/datacache/libgnunetdatacache.la \
-# $(top_builddir)/src/util/libgnunetutil.la
-#
-#perf_plugin_datacache_SOURCES = \
-# perf_plugin_datacache.c
-#perf_plugin_datacache_LDADD = \
-# $(top_builddir)/src/util/libgnunetutil.la
-#
-#
-#EXTRA_DIST = \
-# test_datacache_api_data.conf \
-# perf_plugin_datacache_data.conf
+if HAVE_TESTING
+if HAVE_SQLITE
+if HAVE_BENCHMARKS
+ SQLITE_BENCHMARKS = \
+ perf_datacache_sqlite
+endif
+SQLITE_TESTS = \
+ test_datacache_sqlite \
+ test_datacache_quota_sqlite \
+ $(SQLITE_BENCHMARKS)
+endif
+
+if HAVE_BENCHMARKS
+ HEAP_BENCHMARKS = \
+ perf_datacache_heap
+endif
+HEAP_TESTS = \
+ test_datacache_heap \
+ test_datacache_quota_heap \
+ $(HEAP_BENCHMARKS)
+
+if HAVE_POSTGRESQL
+if HAVE_BENCHMARKS
+ POSTGRES_BENCHMARKS = \
+ perf_datacache_postgres
+endif
+POSTGRES_TESTS = \
+ test_datacache_postgres \
+ test_datacache_quota_postgres \
+ $(POSTGRES_BENCHMARKS)
+endif
+endif
+
+check_PROGRAMS = \
+ $(SQLITE_TESTS) \
+ $(HEAP_TESTS) \
+ $(POSTGRES_TESTS)
+
+if ENABLE_TEST_RUN
+AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
+TESTS = $(check_PROGRAMS)
+endif
+
+test_datacache_sqlite_SOURCES = \
+ test_datacache.c
+test_datacache_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+test_datacache_quota_sqlite_SOURCES = \
+ test_datacache_quota.c
+test_datacache_quota_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+perf_datacache_sqlite_SOURCES = \
+ perf_datacache.c
+perf_datacache_sqlite_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+test_datacache_heap_SOURCES = \
+ test_datacache.c
+test_datacache_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+test_datacache_quota_heap_SOURCES = \
+ test_datacache_quota.c
+test_datacache_quota_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+perf_datacache_heap_SOURCES = \
+ perf_datacache.c
+perf_datacache_heap_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+test_datacache_postgres_SOURCES = \
+ test_datacache.c
+test_datacache_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+test_datacache_quota_postgres_SOURCES = \
+ test_datacache_quota.c
+test_datacache_quota_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+perf_datacache_postgres_SOURCES = \
+ perf_datacache.c
+perf_datacache_postgres_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ libgnunetdatacache.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+EXTRA_DIST = \
+ test_datacache_data_sqlite.conf \
+ perf_datacache_data_sqlite.conf \
+ test_datacache_data_heap.conf \
+ perf_datacache_data_heap.conf \
+ test_datacache_data_postgres.conf \
+ perf_datacache_data_postgres.conf