diff --git a/src/Makefile b/src/Makefile index 19be7a1..b9b1aa2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -44,7 +44,7 @@ CC = gcc PREFIX = /usr/local -all: lib libMT testprog test +all: lib libMT libs: lib libMT @@ -54,18 +54,8 @@ lib: faketime.c libMT: faketime.c ${CC} -DFAKE_STAT -DFAKE_INTERNAL_CALLS -DPTHREAD -DPTHREAD_SINGLETHREADED_TIME -shared -fPIC -Wl,-soname,libfaketimeMT.so.1 -o libfaketimeMT.so.1 faketime.c -ldl -lm -lpthread -testprog: timetest.c - ${CC} -DFAKE_STAT -o timetest timetest.c -lrt - -test: lib testprog - @echo - @./test.sh - -notest: lib libMT testprog - @echo - clean: - @rm -f libfaketime.so.1 libfaketimeMT.so.1 timetest + @rm -f libfaketime.so.1 libfaketimeMT.so.1 distclean: clean @echo @@ -92,4 +82,4 @@ uninstall: rm -f "${DESTDIR}${PREFIX}/share/doc/faketime/Changelog" rmdir "${DESTDIR}${PREFIX}/share/doc/faketime" -.PHONY: all libs lib libMT testprog test notest clean distclean install uninstall +.PHONY: all libs lib libMT clean distclean install uninstall diff --git a/src/test.sh b/src/test.sh deleted file mode 100755 index 4e20b7c..0000000 --- a/src/test.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -if [ -f /etc/faketimerc ] ; then - echo "Running the test program with your system-wide default in /etc/faketimerc" - echo "\$ LD_PRELOAD=./libfaketime.so.1 ./timetest" - LD_PRELOAD=./libfaketime.so.1 ./timetest - echo -else - echo "Running the test program with no faked time specified" - echo "\$ LD_PRELOAD=./libfaketime.so.1 ./timetest" - LD_PRELOAD=./libfaketime.so.1 ./timetest - echo -fi - -echo "Running the test program with absolute date 2003-01-01 10:00:05 specified" -echo "\$ LD_PRELOAD=./libfaketime.so.1 FAKETIME=\"2003-01-01 10:00:05\" ./timetest" -LD_PRELOAD=./libfaketime.so.1 FAKETIME="2003-01-01 10:00:05" ./timetest -echo - -echo "Running the test program with START date @2005-03-29 14:14:14 specified" -echo "\$ LD_PRELOAD=./libfaketime.so.1 FAKETIME=\"@2005-03-29 14:14:14\" ./timetest" -LD_PRELOAD=./libfaketime.so.1 FAKETIME="@2005-03-29 14:14:14" ./timetest -echo - -echo "Running the test program with 10 days negative offset specified" -echo "LD_PRELOAD=./libfaketime.so.1 FAKETIME=\"-10d\" ./timetest" -LD_PRELOAD=./libfaketime.so.1 FAKETIME="-10d" ./timetest -echo - -echo "Running the test program with 10 days negative offset specified, and FAKE_STAT disabled" -echo "\$ LD_PRELOAD=./libfaketime.so.1 FAKETIME=\"-10d\" NO_FAKE_STAT=1 ./timetest" -LD_PRELOAD=./libfaketime.so.1 FAKETIME="-10d" NO_FAKE_STAT=1 ./timetest -echo - -echo "Running the 'date' command with 15 days negative offset specified" -echo "\$ LD_PRELOAD=./libfaketime.so.1 FAKETIME=\"-15d\" date" -LD_PRELOAD=./libfaketime.so.1 FAKETIME="-15d" date -echo - -exit 0 diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..98dc520 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,18 @@ +CC = gcc + +all: testprog test + +testprog: timetest.c + ${CC} -DFAKE_STAT -o timetest timetest.c -lrt + +test: testprog + @echo + @./test.sh + +clean: + @rm -f timetest + +distclean: clean + @echo + +.PHONY: all testprog test clean distclean diff --git a/test/test.sh b/test/test.sh new file mode 100755 index 0000000..a377b3f --- /dev/null +++ b/test/test.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +if [ -f /etc/faketimerc ] ; then + echo "Running the test program with your system-wide default in /etc/faketimerc" + echo "\$ LD_PRELOAD=../src/libfaketime.so.1 ./timetest" + LD_PRELOAD=../src/libfaketime.so.1 ./timetest + echo +else + echo "Running the test program with no faked time specified" + echo "\$ LD_PRELOAD=../src/libfaketime.so.1 ./timetest" + LD_PRELOAD=../src/libfaketime.so.1 ./timetest + echo +fi + +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" +LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="2003-01-01 10:00:05" ./timetest +echo + +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" +LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="@2005-03-29 14:14:14" ./timetest +echo + +echo "Running the test program with 10 days negative offset specified" +echo "LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"-10d\" ./timetest" +LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-10d" ./timetest +echo + +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" +LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-10d" NO_FAKE_STAT=1 ./timetest +echo + +echo "Running the 'date' command with 15 days negative offset specified" +echo "\$ LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"-15d\" date" +LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-15d" date +echo + +exit 0 diff --git a/src/timetest.c b/test/timetest.c similarity index 100% rename from src/timetest.c rename to test/timetest.c