summaryrefslogtreecommitdiffstats
path: root/tests/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/Makefile.am8
-rw-r--r--tests/helpers/libpreload-time.c26
2 files changed, 33 insertions, 1 deletions
diff --git a/tests/helpers/Makefile.am b/tests/helpers/Makefile.am
index 13eaae1e9..6c514e7c7 100644
--- a/tests/helpers/Makefile.am
+++ b/tests/helpers/Makefile.am
@@ -1,5 +1,11 @@
include $(top_srcdir)/config/include-Makefile.am
noinst_PROGRAMS = mnt_test_sysinfo
+mnt_test_sysinfo_SOURCES = mnt_test_sysinfo.c
+
+
+noinst_LTLIBRARIES = libpreload-time.la
+
+libpreload_time_la_SOURCES = libpreload-time.c
+libpreload_time_la_LDFLAGS = -shared -rpath `pwd` -avoid-version
-mnt_test_sysinfo_SOURCES = mnt_test_sysinfo.c
diff --git a/tests/helpers/libpreload-time.c b/tests/helpers/libpreload-time.c
new file mode 100644
index 000000000..e69795098
--- /dev/null
+++ b/tests/helpers/libpreload-time.c
@@ -0,0 +1,26 @@
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/time.h>
+
+time_t
+time(time_t *t)
+{
+ time_t tt = 0;
+ char *e = getenv("TEST_TIME");
+
+ if (e && isdigit((unsigned char) *e))
+ tt = atol(e);
+ else {
+ struct timeval tv;
+
+ if (gettimeofday(&tv, NULL) == 0)
+ tt = tv.tv_sec;
+ }
+ if (t)
+ *t = tt;
+
+ return tt;
+}