]> err.no Git - util-linux/commitdiff
tests: add library for LD_PRELOAD to manipulate with time() in tests
authorKarel Zak <kzak@redhat.com>
Wed, 14 Mar 2007 13:10:18 +0000 (14:10 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 14 Mar 2007 13:10:18 +0000 (14:10 +0100)
The cal command generates output that depends on time(). For reliable
regression tests we need to use still same time. It seems that LD_PRELOAD is
pretty simple way.

Signed-off-by: Karel Zak <kzak@redhat.com>
.gitignore
autogen.sh
config.h.in
configure.ac
tests/helpers/Makefile.am
tests/helpers/libpreload-time.c [new file with mode: 0644]

index 88822ba1b784af682d7e7d318534af4a456125d1..c125924021c54c68c3df1bf5f34d548725833ad8 100644 (file)
@@ -25,3 +25,4 @@ compile
 depcomp
 install-sh
 missing
+ltmain.sh
index ffd8de9504b08516d62c59daf30554d82ca89037..d730a96a0841e6f10292231c9259c9e35de3eaf9 100755 (executable)
@@ -44,7 +44,13 @@ DIE=0
        echo "or see http://www.gnu.org/software/autoheader"
        DIE=1
 }
-
+(libtool --version) < /dev/null > /dev/null 2>&1 || {
+       echo
+       echo "You must have libtool installed to generate util-linux build-system."
+       echo "Download the appropriate package for your distribution,"
+       echo "or see http://www.gnu.org/software/libtool"
+       DIE=1
+}
 if test "$DIE" -eq 1; then
        exit 1
 fi
@@ -55,6 +61,7 @@ test -f mount/mount.c || {
 }
 
 autopoint --force
+libtoolize --copy --force
 aclocal -I m4
 automake --add-missing
 autoconf
index 807cecfdc0824f1527e0c913605469b230032de8..987945f410f2aeb852c8c830e6f17bd71a24f500 100644 (file)
@@ -8,6 +8,9 @@
    */
 #undef HAVE_DCGETTEXT
 
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
 #undef HAVE_FSEEKO
 
index 95690ddf14d979fe09c23ae59055708e18b66924..66e88df8b8bb546983e8972853ca508dcd090f5a 100644 (file)
@@ -12,6 +12,7 @@ AC_PREFIX_DEFAULT(/)
 
 AC_PROG_CC_STDC
 AC_PROG_RANLIB
+AC_PROG_LIBTOOL
 
 AC_PATH_PROG(PERL, perl)
 
index 13eaae1e9a9ce42b3bb040f1577ef262ffaf5bbb..6c514e7c7646ae239ca73e030dbfef7eb00e56a0 100644 (file)
@@ -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 (file)
index 0000000..e697950
--- /dev/null
@@ -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;
+}