Added optional FAKETIME_TESTLIB environment variable for make test (#288)

This commit is contained in:
Wolfgang Hommel
2021-02-04 21:30:01 +01:00
parent 47e6f5f33d
commit 8853afb509
3 changed files with 24 additions and 17 deletions

View File

@@ -14,6 +14,10 @@ src/Makefile, but sane defaults for stable operations have been chosen.
Currently, libfaketime does not use autotools yet, so there is Currently, libfaketime does not use autotools yet, so there is
_no_ ./configure step, but "make" and "make test" will work as expected. _no_ ./configure step, but "make" and "make test" will work as expected.
For "make test", an optional environment variable FAKETIME_TESTLIB can
be set, pointing to the path and filename of the libfaketime library
to be used for tests; the default is "../src/libfaketime.so.1".
However, one problem makes it somewhat difficult to get libfaketime However, one problem makes it somewhat difficult to get libfaketime
working on different platforms: working on different platforms:

View File

@@ -39,7 +39,8 @@ sunos_fakecmd()
linuxlike_fakecmd() linuxlike_fakecmd()
{ {
typeset timestring="$1"; shift typeset timestring="$1"; shift
typeset fakelib=../src/libfaketime.so.1 FTPL="${FAKETIME_TESTLIB:-../src/libfaketime.so.1}"
typeset fakelib="$FTPL"
export LD_PRELOAD=$fakelib export LD_PRELOAD=$fakelib
FAKETIME="$timestring" \ FAKETIME="$timestring" \
"$@" "$@"

View File

@@ -1,14 +1,16 @@
#!/bin/sh #!/bin/sh
FTPL="${FAKETIME_TESTLIB:-../src/libfaketime.so.1}"
if [ -f /etc/faketimerc ] ; then if [ -f /etc/faketimerc ] ; then
echo "Running the test program with your system-wide default in /etc/faketimerc" echo "Running the test program with your system-wide default in /etc/faketimerc"
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 ./timetest" echo "\$ LD_PRELOAD=$FTPL ./timetest"
LD_PRELOAD=../src/libfaketime.so.1 ./timetest LD_PRELOAD="$FTPL" ./timetest
echo echo
else else
echo "Running the test program with no faked time specified" echo "Running the test program with no faked time specified"
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 ./timetest" echo "\$ LD_PRELOAD=$FTPL ./timetest"
LD_PRELOAD=../src/libfaketime.so.1 ./timetest LD_PRELOAD="$FTPL" ./timetest
echo echo
fi fi
@@ -16,48 +18,48 @@ echo "==========================================================================
echo echo
echo "Running the test program with absolute date 2003-01-01 10:00:05 specified" echo "Running the test program with absolute date 2003-01-01 10:00:05 specified"
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"2003-01-01 10:00:05\" ./timetest" echo "\$ LD_PRELOAD=$FTPL FAKETIME=\"2003-01-01 10:00:05\" ./timetest"
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="2003-01-01 10:00:05" ./timetest LD_PRELOAD="$FTPL" FAKETIME="2003-01-01 10:00:05" ./timetest
echo echo
echo "=============================================================================" echo "============================================================================="
echo echo
echo "Running the test program with START date @2005-03-29 14:14:14 specified" echo "Running the test program with START date @2005-03-29 14:14:14 specified"
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"@2005-03-29 14:14:14\" ./timetest" echo "\$ LD_PRELOAD=$FTPL FAKETIME=\"@2005-03-29 14:14:14\" ./timetest"
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="@2005-03-29 14:14:14" ./timetest LD_PRELOAD="$FTPL" FAKETIME="@2005-03-29 14:14:14" ./timetest
echo echo
echo "=============================================================================" echo "============================================================================="
echo echo
echo "Running the test program with 10 days negative offset specified" echo "Running the test program with 10 days negative offset specified"
echo "LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"-10d\" ./timetest" echo "LD_PRELOAD=$FTPL FAKETIME=\"-10d\" ./timetest"
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-10d" ./timetest LD_PRELOAD="$FTPL" FAKETIME="-10d" ./timetest
echo echo
echo "=============================================================================" echo "============================================================================="
echo echo
echo "Running the test program with 10 days negative offset specified, and FAKE_STAT disabled" echo "Running the test program with 10 days negative offset specified, and FAKE_STAT disabled"
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"-10d\" NO_FAKE_STAT=1 ./timetest" echo "\$ LD_PRELOAD=$FTPL FAKETIME=\"-10d\" NO_FAKE_STAT=1 ./timetest"
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-10d" NO_FAKE_STAT=1 ./timetest LD_PRELOAD="$FTPL" FAKETIME="-10d" NO_FAKE_STAT=1 ./timetest
echo echo
echo "=============================================================================" echo "============================================================================="
echo echo
echo "Running the test program with 10 days positive offset specified, and speed-up factor" echo "Running the test program with 10 days positive offset specified, and speed-up factor"
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"+10d x1\" ./timetest" echo "\$ LD_PRELOAD=$FTPL FAKETIME=\"+10d x1\" ./timetest"
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="+10d x1" NO_FAKE_STAT=1 ./timetest LD_PRELOAD="$FTPL" FAKETIME="+10d x1" NO_FAKE_STAT=1 ./timetest
echo echo
echo "=============================================================================" echo "============================================================================="
echo echo
echo "Running the 'date' command with 15 days negative offset specified" echo "Running the 'date' command with 15 days negative offset specified"
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"-15d\" date" echo "\$ LD_PRELOAD=$FTPL FAKETIME=\"-15d\" date"
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-15d" date LD_PRELOAD="$FTPL" FAKETIME="-15d" date
echo echo
echo "=============================================================================" echo "============================================================================="