mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 00:26:16 +03:00
Move test suite to a separate subdirectory.
* Move test suite related stuff from "src/" to "test/". * Fix "test.sh" to search for libfaketime libraries in the right place. * Split up Makefile into two separate Makefiles (one for the main program and one for the test suite). Test cases should go in another directory for the sake of clean code separation. This will also facilitate the creation of proper Makefiles. Signed-off-by: Lukas Fleischer <info@cryptocrack.de>
This commit is contained in:
16
src/Makefile
16
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
|
||||
|
||||
40
src/test.sh
40
src/test.sh
@@ -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
|
||||
18
test/Makefile
Normal file
18
test/Makefile
Normal file
@@ -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
|
||||
40
test/test.sh
Executable file
40
test/test.sh
Executable file
@@ -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
|
||||
Reference in New Issue
Block a user