diff options
author | Karel Zak | 2007-03-14 14:10:18 +0100 |
---|---|---|
committer | Karel Zak | 2007-03-14 14:10:18 +0100 |
commit | 82640b11ba9fbb36e8d39c2a05671ef5f8011b68 (patch) | |
tree | 9b45cf0b2a10f10e1d2fd8a1575e74e36312d22d | |
parent | build-sys: remove aclocal.m4 from SCM (diff) | |
download | kernel-qcow2-util-linux-82640b11ba9fbb36e8d39c2a05671ef5f8011b68.tar.gz kernel-qcow2-util-linux-82640b11ba9fbb36e8d39c2a05671ef5f8011b68.tar.xz kernel-qcow2-util-linux-82640b11ba9fbb36e8d39c2a05671ef5f8011b68.zip |
tests: add library for LD_PRELOAD to manipulate with time() in tests
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>
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | autogen.sh | 9 | ||||
-rw-r--r-- | config.h.in | 3 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | tests/helpers/Makefile.am | 8 | ||||
-rw-r--r-- | tests/helpers/libpreload-time.c | 26 |
6 files changed, 46 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore index 88822ba1b..c12592402 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ compile depcomp install-sh missing +ltmain.sh diff --git a/autogen.sh b/autogen.sh index ffd8de950..d730a96a0 100755 --- a/autogen.sh +++ b/autogen.sh @@ -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 diff --git a/config.h.in b/config.h.in index 807cecfdc..987945f41 100644 --- a/config.h.in +++ b/config.h.in @@ -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 diff --git a/configure.ac b/configure.ac index 95690ddf1..66e88df8b 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,7 @@ AC_PREFIX_DEFAULT(/) AC_PROG_CC_STDC AC_PROG_RANLIB +AC_PROG_LIBTOOL AC_PATH_PROG(PERL, perl) 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; +} |