summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWolfgang Hommel <wolf@code-wizards.com>2011-07-30 10:58:12 +0200
committerWolfgang Hommel <wolf@code-wizards.com>2011-07-30 10:58:12 +0200
commitf07939d9489f9426ccf6926bc716f0a673c69507 (patch)
treeac5069bb8100d2883cc2ee1adf14115fc6a1ab8c /test
parent68ccdb74b5d8a06ca8c722821ca4354ed48fcf56 (diff)
downloadlibfaketime-f07939d9489f9426ccf6926bc716f0a673c69507.tar.gz
Minor adaptions for Mac OS X
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.MacOS31
-rw-r--r--test/functests/common.inc4
-rw-r--r--test/timetest.c4
3 files changed, 37 insertions, 2 deletions
diff --git a/test/Makefile.MacOS b/test/Makefile.MacOS
new file mode 100644
index 0000000..216ca6f
--- /dev/null
+++ b/test/Makefile.MacOS
@@ -0,0 +1,31 @@
+CC = gcc
+
+CFLAGS = -std=gnu99 -Wall -DFAKE_STAT
+LDFLAGS =
+
+SRC = timetest.c
+OBJ = ${SRC:.c=.o}
+
+all: timetest test
+
+.c.o:
+ ${CC} -c ${CFLAGS} $<
+
+timetest: ${OBJ}
+ ${CC} -o $@ ${OBJ} ${LDFLAGS}
+
+test: timetest functest
+ @echo
+ @./test.sh
+
+# run functional tests
+functest:
+ ./testframe.sh functests
+
+clean:
+ @rm -f ${OBJ} timetest
+
+distclean: clean
+ @echo
+
+.PHONY: all test clean distclean
diff --git a/test/functests/common.inc b/test/functests/common.inc
index a011982..4541dd3 100644
--- a/test/functests/common.inc
+++ b/test/functests/common.inc
@@ -6,7 +6,7 @@ platform()
# may want to expand the pattern for linuxlike
typeset out=$(uname)
case "$out" in
- *OSX*) echo "mac" ;;
+ *Darwin*) echo "mac" ;;
*Linux*) echo "linuxlike" ;;
*) echo 1>&2 unsupported platform, uname=\"$out\" ;;
esac
@@ -17,7 +17,7 @@ platform()
mac_fakecmd()
{
typeset timestring="$1"; shift
- typeset fakelib=../src/libfaketime.so.1
+ typeset fakelib=../src/libfaketime.dylib.1
export DYLD_INSERT_LIBRARIES=$fakelib
export DYLD_FORCE_FLAT_NAMESPACE=1
FAKETIME="$timestring" \
diff --git a/test/timetest.c b/test/timetest.c
index 2177730..36e208c 100644
--- a/test/timetest.c
+++ b/test/timetest.c
@@ -36,7 +36,9 @@ int main (int argc, char **argv) {
time_t now;
struct timeb tb;
struct timeval tv;
+#ifndef __APPLE__
struct timespec ts;
+#endif
#ifdef FAKE_STAT
struct stat buf;
#endif
@@ -55,8 +57,10 @@ int main (int argc, char **argv) {
gettimeofday(&tv, NULL);
printf("gettimeofday() : Current date and time: %s", ctime(&tv.tv_sec));
+#ifndef __APPLE__
clock_gettime(CLOCK_REALTIME, &ts);
printf("clock_gettime(): Current date and time: %s", ctime(&ts.tv_sec));
+#endif
#ifdef FAKE_STAT
lstat(argv[0], &buf);