mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-06-04 17:42:34 +03:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57de5bbe83 | ||
|
|
c2b5b71777 | ||
|
|
6c0947c86e | ||
|
|
b36ad2342c | ||
|
|
d40d0ebaa7 | ||
|
|
081845440b | ||
|
|
30207e8fdf | ||
|
|
d2f0daf092 | ||
|
|
c5b5d0b56e |
21
.gitignore
vendored
21
.gitignore
vendored
@@ -7,3 +7,24 @@ src/libfaketime.1.dylib
|
|||||||
src/core
|
src/core
|
||||||
src/faketime
|
src/faketime
|
||||||
|
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
/aclocal.m4
|
||||||
|
/autom4te.cache/
|
||||||
|
/config.*
|
||||||
|
/configure
|
||||||
|
/depcomp
|
||||||
|
/install-sh
|
||||||
|
/libtool
|
||||||
|
/ltmain.sh
|
||||||
|
/m4/
|
||||||
|
/missing
|
||||||
|
/stamp-h?
|
||||||
|
.deps/
|
||||||
|
.dirstamp
|
||||||
|
.libs/
|
||||||
|
*.l[ao]
|
||||||
|
compile
|
||||||
|
test-driver
|
||||||
|
|||||||
@@ -9,5 +9,9 @@ matrix:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- cd ${TRAVIS_BUILD_DIR}
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
|
- sh ./build.sh init
|
||||||
|
- ./configure
|
||||||
- FAKETIME_COMPILE_CFLAGS="-DFORCE_MONOTONIC_FIX" make
|
- FAKETIME_COMPILE_CFLAGS="-DFORCE_MONOTONIC_FIX" make
|
||||||
|
- cd test
|
||||||
- make test
|
- make test
|
||||||
|
- make distcheck
|
||||||
|
|||||||
11
ChangeLog
Normal file
11
ChangeLog
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
Additional change history is viewable in the `NEWS` file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Changed
|
||||||
|
- Mike Stemle added GNU autotools
|
||||||
35
Makefile
35
Makefile
@@ -1,35 +0,0 @@
|
|||||||
INSTALL ?= install
|
|
||||||
|
|
||||||
UNAME=$(shell uname)
|
|
||||||
SELECTOR:=$(shell if test "${UNAME}" = "Darwin" ; then echo "-f Makefile.OSX" ; fi)
|
|
||||||
|
|
||||||
all:
|
|
||||||
$(MAKE) $(SELECTOR) -C src all
|
|
||||||
|
|
||||||
test:
|
|
||||||
$(MAKE) $(SELECTOR) -C src all
|
|
||||||
$(MAKE) $(SELECTOR) -C test all
|
|
||||||
|
|
||||||
install:
|
|
||||||
$(MAKE) $(SELECTOR) -C src install
|
|
||||||
$(MAKE) $(SELECTOR) -C man install
|
|
||||||
$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/share/doc/faketime/"
|
|
||||||
$(INSTALL) -m0644 README "${DESTDIR}${PREFIX}/share/doc/faketime/README"
|
|
||||||
$(INSTALL) -m0644 NEWS "${DESTDIR}${PREFIX}/share/doc/faketime/NEWS"
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
$(MAKE) $(SELECTOR) -C src uninstall
|
|
||||||
$(MAKE) $(SELECTOR) -C man uninstall
|
|
||||||
rm -f "${DESTDIR}${PREFIX}/share/doc/faketime/README"
|
|
||||||
rm -f "${DESTDIR}${PREFIX}/share/doc/faketime/NEWS"
|
|
||||||
rmdir "${DESTDIR}${PREFIX}/share/doc/faketime"
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(MAKE) $(SELECTOR) -C src clean
|
|
||||||
$(MAKE) $(SELECTOR) -C test clean
|
|
||||||
|
|
||||||
distclean:
|
|
||||||
$(MAKE) $(SELECTOR) -C src distclean
|
|
||||||
$(MAKE) $(SELECTOR) -C test distclean
|
|
||||||
|
|
||||||
.PHONY: all test install uninstall clean distclean
|
|
||||||
4
Makefile.am
Normal file
4
Makefile.am
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
ACLOCAL_AMFLAGS=-I m4
|
||||||
|
SUBDIRS=src test man
|
||||||
|
EXTRA_DIST=README.developers README.OSX README.packagers TODO
|
||||||
2
NEWS
2
NEWS
@@ -1,3 +1,5 @@
|
|||||||
|
Since 0.9.9:
|
||||||
|
- Mike Stemle added GNU autotools
|
||||||
- Additional link-time LDFLAGS can be passed via the
|
- Additional link-time LDFLAGS can be passed via the
|
||||||
environment variable FAKETIME_LINK_FLAGS when
|
environment variable FAKETIME_LINK_FLAGS when
|
||||||
running 'make'.
|
running 'make'.
|
||||||
|
|||||||
28
README
28
README
@@ -106,8 +106,16 @@ documentation whether it can be achieved by using libfaketime directly.
|
|||||||
3. Installation
|
3. Installation
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
Running "make" compiles both library versions and a test program, which it then
|
This library supports GNU autotools, so you should be able to build it with:
|
||||||
also executes.
|
|
||||||
|
sh ./build.sh init
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
|
||||||
|
After you have built the library, you may--optionally--run the tests with:
|
||||||
|
|
||||||
|
cd test
|
||||||
|
make test
|
||||||
|
|
||||||
If the test works fine, you should copy the libfaketime libraries
|
If the test works fine, you should copy the libfaketime libraries
|
||||||
(libfaketime.so.1, and libfaketimeMT.so.1) to the place you want them in.
|
(libfaketime.so.1, and libfaketimeMT.so.1) to the place you want them in.
|
||||||
@@ -130,14 +138,16 @@ not need this feature or if it confuses the application you want to use FTPL
|
|||||||
with, define the environment variable NO_FAKE_STAT, and the intercepted stat
|
with, define the environment variable NO_FAKE_STAT, and the intercepted stat
|
||||||
calls will be passed through unaltered.
|
calls will be passed through unaltered.
|
||||||
|
|
||||||
On macOS, it is necessary to compile differently, due to the different
|
On macOS, instead of using LD_PRELOAD, the variable DYLD_INSERT_LIBRARIES
|
||||||
behavior dyld has. Use the Makefile.OSX file provided to compile
|
should be set to the path to libfaketime.0.dylib, and the variable
|
||||||
libfaketime.1.dylib. Additionally, instead of using LD_PRELOAD,
|
DYLD_FORCE_FLAT_NAMESPACE should be set (to anything). macOS users should
|
||||||
the variable DYLD_INSERT_LIBRARIES should be set to the path to
|
read README.OSX for additional details.
|
||||||
libfaketime.1.dylib, and the variable DYLD_FORCE_FLAT_NAMESPACE should be
|
|
||||||
set (to anything). macOS users should read README.OSX for additional
|
|
||||||
details.
|
|
||||||
|
|
||||||
|
NOTE: When committing, clean up potentially non-portable files with:
|
||||||
|
|
||||||
|
sh build.sh clean
|
||||||
|
|
||||||
|
This will clean up the build files which we don't want to version-control.
|
||||||
|
|
||||||
4. Usage
|
4. Usage
|
||||||
--------
|
--------
|
||||||
|
|||||||
13
README.OSX
13
README.OSX
@@ -39,18 +39,23 @@ Otherwise, you have to compile and install libfaketime manually; this
|
|||||||
will require a working installation of Xcode and its command line tools
|
will require a working installation of Xcode and its command line tools
|
||||||
on your machine.
|
on your machine.
|
||||||
|
|
||||||
You can compile libfaketime by running the command
|
This library now supports GNU autotools, so you can build it using:
|
||||||
|
|
||||||
|
sh build.sh init
|
||||||
|
./configure
|
||||||
make
|
make
|
||||||
|
|
||||||
in libfaketime's top-level directory.
|
|
||||||
|
|
||||||
The resulting library will be named libfaketime.1.dylib ; to check
|
The resulting library will be named libfaketime.1.dylib ; to check
|
||||||
whether it works properly, run the test suite and verify whether its
|
whether it works properly, run the test suite and verify whether its
|
||||||
output is correct:
|
output is correct:
|
||||||
|
|
||||||
cd test
|
cd test
|
||||||
make -f Makefile.OSX
|
make test
|
||||||
|
|
||||||
|
NOTE: When committing, be sure to clean up potentially
|
||||||
|
system-dependent files by running:
|
||||||
|
|
||||||
|
sh build.sh clean
|
||||||
|
|
||||||
|
|
||||||
2) Using libfaketime from the command line on macOS
|
2) Using libfaketime from the command line on macOS
|
||||||
|
|||||||
270
ar-lib
Executable file
270
ar-lib
Executable file
@@ -0,0 +1,270 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# Wrapper for Microsoft lib.exe
|
||||||
|
|
||||||
|
me=ar-lib
|
||||||
|
scriptversion=2012-03-01.08; # UTC
|
||||||
|
|
||||||
|
# Copyright (C) 2010-2018 Free Software Foundation, Inc.
|
||||||
|
# Written by Peter Rosin <peda@lysator.liu.se>.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# As a special exception to the GNU General Public License, if you
|
||||||
|
# distribute this file as part of a program that contains a
|
||||||
|
# configuration script generated by Autoconf, you may include it under
|
||||||
|
# the same distribution terms that you use for the rest of that program.
|
||||||
|
|
||||||
|
# This file is maintained in Automake, please report
|
||||||
|
# bugs to <bug-automake@gnu.org> or send patches to
|
||||||
|
# <automake-patches@gnu.org>.
|
||||||
|
|
||||||
|
|
||||||
|
# func_error message
|
||||||
|
func_error ()
|
||||||
|
{
|
||||||
|
echo "$me: $1" 1>&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
file_conv=
|
||||||
|
|
||||||
|
# func_file_conv build_file
|
||||||
|
# Convert a $build file to $host form and store it in $file
|
||||||
|
# Currently only supports Windows hosts.
|
||||||
|
func_file_conv ()
|
||||||
|
{
|
||||||
|
file=$1
|
||||||
|
case $file in
|
||||||
|
/ | /[!/]*) # absolute file, and not a UNC file
|
||||||
|
if test -z "$file_conv"; then
|
||||||
|
# lazily determine how to convert abs files
|
||||||
|
case `uname -s` in
|
||||||
|
MINGW*)
|
||||||
|
file_conv=mingw
|
||||||
|
;;
|
||||||
|
CYGWIN*)
|
||||||
|
file_conv=cygwin
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
file_conv=wine
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
case $file_conv in
|
||||||
|
mingw)
|
||||||
|
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||||
|
;;
|
||||||
|
cygwin)
|
||||||
|
file=`cygpath -m "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
wine)
|
||||||
|
file=`winepath -w "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_at_file at_file operation archive
|
||||||
|
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
|
||||||
|
# for each of them.
|
||||||
|
# When interpreting the content of the @FILE, do NOT use func_file_conv,
|
||||||
|
# since the user would need to supply preconverted file names to
|
||||||
|
# binutils ar, at least for MinGW.
|
||||||
|
func_at_file ()
|
||||||
|
{
|
||||||
|
operation=$2
|
||||||
|
archive=$3
|
||||||
|
at_file_contents=`cat "$1"`
|
||||||
|
eval set x "$at_file_contents"
|
||||||
|
shift
|
||||||
|
|
||||||
|
for member
|
||||||
|
do
|
||||||
|
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
'')
|
||||||
|
func_error "no command. Try '$0 --help' for more information."
|
||||||
|
;;
|
||||||
|
-h | --h*)
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
|
||||||
|
|
||||||
|
Members may be specified in a file named with @FILE.
|
||||||
|
EOF
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
-v | --v*)
|
||||||
|
echo "$me, version $scriptversion"
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test $# -lt 3; then
|
||||||
|
func_error "you must specify a program, an action and an archive"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AR=$1
|
||||||
|
shift
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
if test $# -lt 2; then
|
||||||
|
func_error "you must specify a program, an action and an archive"
|
||||||
|
fi
|
||||||
|
case $1 in
|
||||||
|
-lib | -LIB \
|
||||||
|
| -ltcg | -LTCG \
|
||||||
|
| -machine* | -MACHINE* \
|
||||||
|
| -subsystem* | -SUBSYSTEM* \
|
||||||
|
| -verbose | -VERBOSE \
|
||||||
|
| -wx* | -WX* )
|
||||||
|
AR="$AR $1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
action=$1
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
orig_archive=$1
|
||||||
|
shift
|
||||||
|
func_file_conv "$orig_archive"
|
||||||
|
archive=$file
|
||||||
|
|
||||||
|
# strip leading dash in $action
|
||||||
|
action=${action#-}
|
||||||
|
|
||||||
|
delete=
|
||||||
|
extract=
|
||||||
|
list=
|
||||||
|
quick=
|
||||||
|
replace=
|
||||||
|
index=
|
||||||
|
create=
|
||||||
|
|
||||||
|
while test -n "$action"
|
||||||
|
do
|
||||||
|
case $action in
|
||||||
|
d*) delete=yes ;;
|
||||||
|
x*) extract=yes ;;
|
||||||
|
t*) list=yes ;;
|
||||||
|
q*) quick=yes ;;
|
||||||
|
r*) replace=yes ;;
|
||||||
|
s*) index=yes ;;
|
||||||
|
S*) ;; # the index is always updated implicitly
|
||||||
|
c*) create=yes ;;
|
||||||
|
u*) ;; # TODO: don't ignore the update modifier
|
||||||
|
v*) ;; # TODO: don't ignore the verbose modifier
|
||||||
|
*)
|
||||||
|
func_error "unknown action specified"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
action=${action#?}
|
||||||
|
done
|
||||||
|
|
||||||
|
case $delete$extract$list$quick$replace,$index in
|
||||||
|
yes,* | ,yes)
|
||||||
|
;;
|
||||||
|
yesyes*)
|
||||||
|
func_error "more than one action specified"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
func_error "no action specified"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test -n "$delete"; then
|
||||||
|
if test ! -f "$orig_archive"; then
|
||||||
|
func_error "archive not found"
|
||||||
|
fi
|
||||||
|
for member
|
||||||
|
do
|
||||||
|
case $1 in
|
||||||
|
@*)
|
||||||
|
func_at_file "${1#@}" -REMOVE "$archive"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
func_file_conv "$1"
|
||||||
|
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
elif test -n "$extract"; then
|
||||||
|
if test ! -f "$orig_archive"; then
|
||||||
|
func_error "archive not found"
|
||||||
|
fi
|
||||||
|
if test $# -gt 0; then
|
||||||
|
for member
|
||||||
|
do
|
||||||
|
case $1 in
|
||||||
|
@*)
|
||||||
|
func_at_file "${1#@}" -EXTRACT "$archive"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
func_file_conv "$1"
|
||||||
|
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
else
|
||||||
|
$AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
|
||||||
|
do
|
||||||
|
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif test -n "$quick$replace"; then
|
||||||
|
if test ! -f "$orig_archive"; then
|
||||||
|
if test -z "$create"; then
|
||||||
|
echo "$me: creating $orig_archive"
|
||||||
|
fi
|
||||||
|
orig_archive=
|
||||||
|
else
|
||||||
|
orig_archive=$archive
|
||||||
|
fi
|
||||||
|
|
||||||
|
for member
|
||||||
|
do
|
||||||
|
case $1 in
|
||||||
|
@*)
|
||||||
|
func_file_conv "${1#@}"
|
||||||
|
set x "$@" "@$file"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
func_file_conv "$1"
|
||||||
|
set x "$@" "$file"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -n "$orig_archive"; then
|
||||||
|
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
|
||||||
|
else
|
||||||
|
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
elif test -n "$list"; then
|
||||||
|
if test ! -f "$orig_archive"; then
|
||||||
|
func_error "archive not found"
|
||||||
|
fi
|
||||||
|
$AR -NOLOGO -LIST "$archive" || exit $?
|
||||||
|
fi
|
||||||
46
build.sh
Normal file
46
build.sh
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#autoreconf --install
|
||||||
|
|
||||||
|
# Thanks, https://github.com/raywill/automake
|
||||||
|
|
||||||
|
export AUTOM4TE="autom4te"
|
||||||
|
export AUTOCONF="autoconf"
|
||||||
|
|
||||||
|
# On OSX, it's glibtoolize
|
||||||
|
LIBTOOLIZE=$(which libtoolize)
|
||||||
|
if [ "$LIBTOOLIZE" = "" ]; then
|
||||||
|
LIBTOOLIZE=$(which glibtoolize)
|
||||||
|
fi
|
||||||
|
if [ "$LIBTOOLIZE" = "" ]; then
|
||||||
|
echo "CANNOT CONTINUE! MISSING (G)LIBTOOLIZE! Install libtool!" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "x$1" in
|
||||||
|
xinit)
|
||||||
|
[ -d m4 ] || mkdir m4
|
||||||
|
set -x
|
||||||
|
autoheader
|
||||||
|
aclocal
|
||||||
|
$LIBTOOLIZE --force --copy --automake
|
||||||
|
autoconf --force
|
||||||
|
automake --foreign --copy --add-missing -Woverride
|
||||||
|
;;
|
||||||
|
xclean)
|
||||||
|
echo 'cleaning...'
|
||||||
|
make distclean >/dev/null 2>&1
|
||||||
|
rm -rf autom4te.cache
|
||||||
|
for fn in aclocal.m4 configure config.guess config.sub depcomp install-sh \
|
||||||
|
ltmain.sh libtool missing mkinstalldirs config.log config.status Makefile; do
|
||||||
|
rm -f $fn
|
||||||
|
done
|
||||||
|
|
||||||
|
find . -name Makefile.in -exec rm -f {} \;
|
||||||
|
find . -name Makefile -exec rm -f {} \;
|
||||||
|
find . -name .deps -prune -exec rm -rf {} \;
|
||||||
|
echo 'done'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
./configure
|
||||||
|
;;
|
||||||
|
esac
|
||||||
62
configure.ac
Normal file
62
configure.ac
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info
|
||||||
|
m4_define([lft_major_version], [0])
|
||||||
|
m4_define([lft_minor_version], [9])
|
||||||
|
m4_define([lft_micro_version], [8])
|
||||||
|
m4_define([libfaketime_version],
|
||||||
|
[lft_major_version.lft_minor_version.lft_micro_version])
|
||||||
|
|
||||||
|
AC_PREREQ([2.68])
|
||||||
|
AC_INIT([libfaketime], [libfaketime_version])
|
||||||
|
AC_SUBST([LIBTOOL_DEPS])
|
||||||
|
#AC_CONFIG_MACRO_DIRS([m4])
|
||||||
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
|
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
||||||
|
AM_CONDITIONAL(MACOS, test `uname` = "Darwin")
|
||||||
|
AM_CONDITIONAL(SOLARIS, test `uname` = "SunOS")
|
||||||
|
|
||||||
|
eval PREFIX=`test "$prefix" = NONE && prefix=$ac_default_prefix; eval echo "${prefix}"`
|
||||||
|
eval LIBPREFIX="$PREFIX/lib"
|
||||||
|
LIBFAKETIME_MAJOR_VERSION=lft_major_version
|
||||||
|
AC_SUBST(PREFIX)
|
||||||
|
AC_SUBST(LIBPREFIX)
|
||||||
|
AC_SUBST(LIBVERSION)
|
||||||
|
AC_DEFINE_UNQUOTED(PREFIX, "$PREFIX", [The install prefix for the package])
|
||||||
|
AC_DEFINE_UNQUOTED(LIBPREFIX, "$LIBPREFIX", [The install prefix for libraries])
|
||||||
|
AC_DEFINE(LIBVERSION, ["lft_major_version"], [The library version number])
|
||||||
|
|
||||||
|
AC_CONFIG_SRCDIR([src])
|
||||||
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
||||||
|
# libtool versioning
|
||||||
|
LIBFAKETIME_VERSION=libfaketime_version
|
||||||
|
AC_SUBST(LIBFAKETIME_VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
# Checks for programs.
|
||||||
|
AC_PROG_CC
|
||||||
|
AM_PROG_AR
|
||||||
|
|
||||||
|
# Checks for libraries.
|
||||||
|
AC_CHECK_LIB([c], [timespecadd], [timespecmul])
|
||||||
|
|
||||||
|
## FORESHADOWING...
|
||||||
|
## AC_CHECK_LIB([cunit], [CU_assertImplementation])
|
||||||
|
|
||||||
|
# Checks for header files.
|
||||||
|
AC_CHECK_HEADERS([stdlib.h sys/param.h unistd.h stdbool.h time.h netinet/in.h math.h])
|
||||||
|
|
||||||
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
|
AC_C_INLINE
|
||||||
|
AC_TYPE_SIZE_T
|
||||||
|
AC_TYPE_SSIZE_T
|
||||||
|
AC_TYPE_UINT32_T
|
||||||
|
|
||||||
|
# Checks for library functions.
|
||||||
|
AC_FUNC_MALLOC
|
||||||
|
AC_FUNC_REALLOC
|
||||||
|
AC_CHECK_FUNCS([memset])
|
||||||
|
|
||||||
|
LT_INIT
|
||||||
|
AC_CONFIG_FILES([Makefile src/Makefile test/Makefile man/Makefile])
|
||||||
|
AC_OUTPUT
|
||||||
14
man/Makefile
14
man/Makefile
@@ -1,14 +0,0 @@
|
|||||||
INSTALL ?= install
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
|
|
||||||
all:
|
|
||||||
|
|
||||||
install:
|
|
||||||
$(INSTALL) -Dm0644 faketime.1 "${DESTDIR}${PREFIX}/share/man/man1/faketime.1"
|
|
||||||
gzip -f "${DESTDIR}${PREFIX}/share/man/man1/faketime.1"
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
rm -f "${DESTDIR}${PREFIX}/share/man/man1/faketime.1.gz"
|
|
||||||
|
|
||||||
.PHONY: all install uninstall
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
INSTALL ?= install
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
|
|
||||||
all:
|
|
||||||
|
|
||||||
install:
|
|
||||||
$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/share/man/man1"
|
|
||||||
$(INSTALL) -m0644 faketime.1 "${DESTDIR}${PREFIX}/share/man/man1/faketime.1"
|
|
||||||
gzip -f "${DESTDIR}${PREFIX}/share/man/man1/faketime.1"
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
rm -f "${DESTDIR}${PREFIX}/share/man/man1/faketime.1.gz"
|
|
||||||
|
|
||||||
.PHONY: all install uninstall
|
|
||||||
18
man/Makefile.am
Normal file
18
man/Makefile.am
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
ACLOCAL_AMFLAGS=-I m4
|
||||||
|
|
||||||
|
dist_man_MANS = faketime.1
|
||||||
|
|
||||||
|
# INSTALL ?= install
|
||||||
|
#
|
||||||
|
# PREFIX ?= /usr/local
|
||||||
|
#
|
||||||
|
# all:
|
||||||
|
#
|
||||||
|
# install:
|
||||||
|
# $(INSTALL) -Dm0644 faketime.1 "${DESTDIR}${PREFIX}/share/man/man1/faketime.1"
|
||||||
|
# gzip -f "${DESTDIR}${PREFIX}/share/man/man1/faketime.1"
|
||||||
|
#
|
||||||
|
# uninstall:
|
||||||
|
# rm -f "${DESTDIR}${PREFIX}/share/man/man1/faketime.1.gz"
|
||||||
|
#
|
||||||
|
# .PHONY: all install uninstall
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
#
|
|
||||||
# Notes:
|
|
||||||
#
|
|
||||||
# * Compilation Defines:
|
|
||||||
#
|
|
||||||
# FAKE_STAT
|
|
||||||
# - Enables time faking also for files' timestamps.
|
|
||||||
#
|
|
||||||
# NO_ATFILE
|
|
||||||
# - Disables support for the fstatat() group of functions
|
|
||||||
#
|
|
||||||
# PTHREAD
|
|
||||||
# - Define this to enable multithreading support.
|
|
||||||
#
|
|
||||||
# PTHREAD_SINGLETHREADED_TIME
|
|
||||||
# - Define this if you want to single-thread time() ... there ARE
|
|
||||||
# possible caching side-effects in a multithreaded environment
|
|
||||||
# without this, but the performance impact may require you to
|
|
||||||
# try it unsynchronized.
|
|
||||||
#
|
|
||||||
# FAKE_SLEEP
|
|
||||||
# - Also intercept sleep(), nanosleep(), usleep(), alarm(), [p]poll()
|
|
||||||
#
|
|
||||||
# * Compilation addition: second libMT target added for building the pthread-
|
|
||||||
# enabled library as a separate library
|
|
||||||
#
|
|
||||||
# * Compilation switch change: previous versions compiled using '-nostartfiles'
|
|
||||||
# This is no longer the case since there is a 'startup' constructor for the library
|
|
||||||
# which is used to activate the start-at times when specified. This also initializes
|
|
||||||
# the dynamic disabling of the FAKE_STAT calls.
|
|
||||||
#
|
|
||||||
# By default, libfaketime will be compiled for your system's default architecture.
|
|
||||||
# To build for a different architecture, add -arch flags to CFLAGS and LDFLAGS.
|
|
||||||
#
|
|
||||||
# default to clang to support thread local variables
|
|
||||||
CC ?= clang
|
|
||||||
INSTALL ?= install
|
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
|
||||||
|
|
||||||
CFLAGS += -DFAKE_SLEEP -DFAKE_INTERNAL_CALLS -DPREFIX='"'${PREFIX}'"' $(FAKETIME_COMPILE_CFLAGS)
|
|
||||||
LIB_LDFLAGS += -dynamiclib -current_version 0.9.8 -compatibility_version 0.7
|
|
||||||
|
|
||||||
SONAME = 1
|
|
||||||
LIBS = libfaketime.${SONAME}.dylib
|
|
||||||
BINS = faketime
|
|
||||||
|
|
||||||
all: ${LIBS} ${BINS}
|
|
||||||
|
|
||||||
libfaketime.${SONAME}.dylib: libfaketime.c
|
|
||||||
${CC} -o $@ ${CFLAGS} ${LDFLAGS} ${LIB_LDFLAGS} -install_name ${PREFIX}/lib/faketime/$@ $<
|
|
||||||
|
|
||||||
faketime: faketime.c
|
|
||||||
${CC} -o $@ ${CFLAGS} ${LDFLAGS} $<
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -f ${OBJ} ${LIBS} ${BINS}
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
@echo
|
|
||||||
|
|
||||||
install: ${LIBS} ${BINS}
|
|
||||||
@echo
|
|
||||||
@echo "Copying the faketime libraries to ${DESTDIR}${PREFIX}/lib/faketime and the faketime wrapper script to ${DESTDIR}${PREFIX}/bin ..."
|
|
||||||
$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/lib/faketime/"
|
|
||||||
$(INSTALL) -m0644 ${LIBS} "${DESTDIR}${PREFIX}/lib/faketime/"
|
|
||||||
$(INSTALL) -dm0755 "${DESTDIR}${PREFIX}/bin"
|
|
||||||
$(INSTALL) -m0755 faketime "${DESTDIR}${PREFIX}/bin/faketime"
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
for f in ${LIBS}; do rm -f "${DESTDIR}${PREFIX}/lib/faketime/$$f"; done
|
|
||||||
rmdir "${DESTDIR}${PREFIX}/lib/faketime"
|
|
||||||
rm -f "${DESTDIR}${PREFIX}/bin/faketime"
|
|
||||||
|
|
||||||
.PHONY: all clean distclean install uninstall
|
|
||||||
39
src/Makefile.am
Normal file
39
src/Makefile.am
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
ACLOCAL_AMFLAGS=-I m4
|
||||||
|
LIBTOOL_DEPS = @LIBTOOL_DEPS@
|
||||||
|
LIBOBJDIR = "."
|
||||||
|
libtool: $(LIBTOOL_DEPS)
|
||||||
|
$(SHELL) ./config.status libtool
|
||||||
|
|
||||||
|
AM_CFLAGS =-DFAKE_SLEEP -DFAKE_INTERNAL_CALLS
|
||||||
|
|
||||||
|
AM_LDFLAGS =
|
||||||
|
|
||||||
|
if SOLARIS
|
||||||
|
AM_CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
|
||||||
|
AM_LDFLAGS += -Wl,--version-script=@srcdir@/libfaketime.map
|
||||||
|
endif
|
||||||
|
if !MACOS
|
||||||
|
AM_CFLAGS += -std=gnu99 -Wall -Wextra -Werror -DFAKE_STAT -DFAKE_PTHREAD -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -Wno-nonnull-compare
|
||||||
|
endif
|
||||||
|
|
||||||
|
LTCFLAGS=""
|
||||||
|
|
||||||
|
EXTRA_DIST=libfaketime.map
|
||||||
|
lib_LTLIBRARIES = libfaketime.la libfaketimeMT.la
|
||||||
|
libfaketime_la_SOURCES = libfaketime.c
|
||||||
|
libfaketimeMT_la_SOURCES = libfaketime.c
|
||||||
|
noinst_HEADERS = faketime_common.h sunos_endian.h time_ops.h uthash.h
|
||||||
|
|
||||||
|
bin_PROGRAMS = faketime
|
||||||
|
faketime_SOURCES = faketime.c
|
||||||
|
|
||||||
|
if MACOS
|
||||||
|
libfaketime_la_LDFLAGS = -dynamiclib -current_version 0.9.8 -compatibility_version 0.7
|
||||||
|
else
|
||||||
|
libfaketime_la_LIBADD = -ldl -lm -lrt -lpthread
|
||||||
|
libfaketime_la_LDFLAGS = -shared -Wl,--version-script=@srcdir@/libfaketime.map
|
||||||
|
libfaketimeMT_la_LIBADD = -ldl -lm -lrt -lpthread
|
||||||
|
libfaketimeMT_la_CFLAGS = -DPTHREAD_SINGLETHREADED_TIME
|
||||||
|
libfaketimeMT_la_LDFLAGS = -shared -Wl,--version-script=@srcdir@/libfaketime.map -DPTHREAD_SINGLETHREADED_TIME
|
||||||
|
faketime_LDADD = -ldl -lm -lrt -lpthread
|
||||||
|
endif
|
||||||
@@ -47,8 +47,9 @@
|
|||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
|
||||||
#include "faketime_common.h"
|
#include "faketime_common.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
const char version[] = "0.9.7";
|
const char version[] = VERSION;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
static const char *date_cmd = "gdate";
|
static const char *date_cmd = "gdate";
|
||||||
@@ -295,19 +296,21 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char *ftpl_path;
|
char *ftpl_path;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
ftpl_path = PREFIX "/libfaketime.1.dylib";
|
if (!getenv("DYLD_INSERT_LIBRARIES") && !getenv("DYLD_FORCE_FLAT_NAMESPACE")) {
|
||||||
FILE *check;
|
ftpl_path = LIBPREFIX "/libfaketime." LIBVERSION ".dylib";
|
||||||
check = fopen(ftpl_path, "ro");
|
FILE *check;
|
||||||
if (check == NULL)
|
check = fopen(ftpl_path, "ro");
|
||||||
{
|
if (check == NULL)
|
||||||
ftpl_path = PREFIX "/lib/faketime/libfaketime.1.dylib";
|
{
|
||||||
|
ftpl_path = PREFIX "/lib/faketime/libfaketime." LIBVERSION ".dylib";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fclose(check);
|
||||||
|
}
|
||||||
|
setenv("DYLD_INSERT_LIBRARIES", ftpl_path, true);
|
||||||
|
setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", true);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
fclose(check);
|
|
||||||
}
|
|
||||||
setenv("DYLD_INSERT_LIBRARIES", ftpl_path, true);
|
|
||||||
setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", true);
|
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
char *ld_preload_new, *ld_preload = getenv("LD_PRELOAD");
|
char *ld_preload_new, *ld_preload = getenv("LD_PRELOAD");
|
||||||
@@ -318,17 +321,17 @@ int main (int argc, char **argv)
|
|||||||
* on MultiArch platforms, such as Debian, we put a literal $LIB into LD_PRELOAD.
|
* on MultiArch platforms, such as Debian, we put a literal $LIB into LD_PRELOAD.
|
||||||
*/
|
*/
|
||||||
#ifndef MULTI_ARCH
|
#ifndef MULTI_ARCH
|
||||||
ftpl_path = PREFIX LIBDIRNAME "/libfaketimeMT.so.1";
|
ftpl_path = LIBPREFIX "/libfaketimeMT.so." LIBVERSION;
|
||||||
#else
|
#else
|
||||||
ftpl_path = PREFIX "/$LIB/faketime/libfaketimeMT.so.1";
|
ftpl_path = PREFIX "/$LIB/faketime/libfaketimeMT.so." LIBVERSION;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef MULTI_ARCH
|
#ifndef MULTI_ARCH
|
||||||
ftpl_path = PREFIX LIBDIRNAME "/libfaketime.so.1";
|
ftpl_path = LIBPREFIX "/libfaketime.so." LIBVERSION;
|
||||||
#else
|
#else
|
||||||
ftpl_path = PREFIX "/$LIB/faketime/libfaketime.so.1";
|
ftpl_path = PREFIX "/$LIB/faketime/libfaketime.so." LIBVERSION;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
len = ((ld_preload)?strlen(ld_preload) + 1: 0) + 1 + strlen(ftpl_path);
|
len = ((ld_preload)?strlen(ld_preload) + 1: 0) + 1 + strlen(ftpl_path);
|
||||||
|
|||||||
@@ -58,4 +58,28 @@ struct ft_shared_s
|
|||||||
#include <mach/mach_port.h>
|
#include <mach/mach_port.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef FAKE_SLEEP
|
||||||
|
#include <time.h>
|
||||||
|
#include <poll.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
/*
|
||||||
|
* Fake sleep prototypes!
|
||||||
|
*/
|
||||||
|
struct pollfd;
|
||||||
|
|
||||||
|
int nanosleep(const struct timespec *req, struct timespec *rem);
|
||||||
|
int usleep(useconds_t usec);
|
||||||
|
unsigned int sleep(unsigned int seconds);
|
||||||
|
unsigned int alarm(unsigned int seconds);
|
||||||
|
int ppoll(struct pollfd *fds, nfds_t nfds,
|
||||||
|
const struct timespec *timeout_ts, const sigset_t *sigmask);
|
||||||
|
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
|
||||||
|
int select(int nfds, fd_set *readfds,
|
||||||
|
fd_set *writefds,
|
||||||
|
fd_set *errorfds,
|
||||||
|
struct timeval *timeout);
|
||||||
|
int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
|
||||||
|
#endif /* FAKE_SLEEP */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "uthash.h"
|
#include "uthash.h"
|
||||||
|
|
||||||
#include "time_ops.h"
|
#include "time_ops.h"
|
||||||
@@ -3209,6 +3210,17 @@ int pthread_cond_init_232(pthread_cond_t *restrict cond, const pthread_condattr_
|
|||||||
clockid_t clock_id;
|
clockid_t clock_id;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
ftpl_init();
|
||||||
|
}
|
||||||
|
if (NULL == real_pthread_cond_init_232)
|
||||||
|
{ /* dlsym() failed */
|
||||||
|
#ifdef DEBUG
|
||||||
|
(void) fprintf(stderr, "faketime problem: original pthread_cond_init (@@GLIBC_2.3.2, fallback) not found.\n");
|
||||||
|
#endif
|
||||||
|
return -1; /* propagate error to caller */
|
||||||
|
}
|
||||||
result = real_pthread_cond_init_232(cond, attr);
|
result = real_pthread_cond_init_232(cond, attr);
|
||||||
|
|
||||||
if (result != 0 || attr == NULL)
|
if (result != 0 || attr == NULL)
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
CC = gcc
|
|
||||||
|
|
||||||
CFLAGS = -std=gnu99 -Wall -DFAKE_STAT -Werror -Wextra $(FAKETIME_COMPILE_CFLAGS)
|
|
||||||
LDFLAGS = -lrt -lpthread
|
|
||||||
|
|
||||||
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
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
CC ?= clang
|
|
||||||
|
|
||||||
CFLAGS += -std=gnu99 -Wall -DFAKE_STAT $(FAKETIME_COMPILE_CFLAGS)
|
|
||||||
|
|
||||||
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_OSX.sh
|
|
||||||
|
|
||||||
# run functional tests
|
|
||||||
functest:
|
|
||||||
./testframe.sh functests
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -f ${OBJ} timetest
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
@echo
|
|
||||||
|
|
||||||
.PHONY: all test clean distclean
|
|
||||||
29
test/Makefile.am
Normal file
29
test/Makefile.am
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
AM_CPPFLAGS =-DFAKE_SLEEP -DFAKE_INTERNAL_CALLS -I@top_srcdir@/src
|
||||||
|
|
||||||
|
AM_CFLAGS =
|
||||||
|
AM_LDFLAGS =
|
||||||
|
|
||||||
|
# functests.sh fail for me, test.sh hangs for me.
|
||||||
|
# TESTS = test.sh functests.sh
|
||||||
|
check_PROGRAMS = timetest
|
||||||
|
timetest_SOURCES = timetest.c
|
||||||
|
check_SCRIPTS = functests.sh testframe.sh test.sh
|
||||||
|
EXTRA_DIST = $(check_SCRIPTS) \
|
||||||
|
functests/common.inc \
|
||||||
|
functests/dont_test_false.sh \
|
||||||
|
functests/test_exclude_mono.sh \
|
||||||
|
functests/test_null.sh \
|
||||||
|
functests/test_true.sh \
|
||||||
|
functests/test_walkone.sh
|
||||||
|
|
||||||
|
if SOLARIS
|
||||||
|
AM_CPPFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
|
||||||
|
AM_LDFLAGS += -Wl,--version-script=libfaketime.map
|
||||||
|
endif
|
||||||
|
if !MACOS
|
||||||
|
AM_CPPFLAGS += -DFAKE_STAT -DFAKE_PTHREAD -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS
|
||||||
|
AM_CFLAGS += -std=gnu99 -Wall -Wextra -Werror -fPIC -Wno-nonnull-compare
|
||||||
|
timetest_LDADD = -ldl -lm -lrt -lpthread
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
7
test/functests.sh
Executable file
7
test/functests.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
[ "${srcdir}" ] || srcdir=.
|
||||||
|
|
||||||
|
# run functional tests
|
||||||
|
# cd "${srcdir}/"
|
||||||
|
${srcdir}/testframe.sh ${srcdir}/functests
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
# libfaketime-specific common support routines for tests
|
# libfaketime-specific common support routines for tests
|
||||||
|
|
||||||
|
LIB_BUILD_PATH="../src/$(grep 'LT_OBJDIR' ../config.h | cut -d'"' -f2)"
|
||||||
|
LIBFAKETIME_LA=$(find "$LIB_BUILD_PATH" | grep 'libfaketime\.\(dylib\|so\)$')
|
||||||
|
|
||||||
# say which *_fakecmd wrapper to use
|
# say which *_fakecmd wrapper to use
|
||||||
platform()
|
platform()
|
||||||
{
|
{
|
||||||
@@ -19,7 +22,7 @@ platform()
|
|||||||
mac_fakecmd()
|
mac_fakecmd()
|
||||||
{
|
{
|
||||||
typeset timestring="$1"; shift
|
typeset timestring="$1"; shift
|
||||||
typeset fakelib=../src/libfaketime.1.dylib
|
typeset fakelib="$LIBFAKETIME_LA"
|
||||||
export DYLD_INSERT_LIBRARIES=$fakelib
|
export DYLD_INSERT_LIBRARIES=$fakelib
|
||||||
export DYLD_FORCE_FLAT_NAMESPACE=1
|
export DYLD_FORCE_FLAT_NAMESPACE=1
|
||||||
FAKETIME="$timestring" \
|
FAKETIME="$timestring" \
|
||||||
@@ -29,7 +32,7 @@ mac_fakecmd()
|
|||||||
sunos_fakecmd()
|
sunos_fakecmd()
|
||||||
{
|
{
|
||||||
typeset timestring="$1"; shift
|
typeset timestring="$1"; shift
|
||||||
typeset fakelib=../src/libfaketime.so.1
|
typeset fakelib="$LIBFAKETIME_LA"
|
||||||
export LD_PRELOAD=$fakelib
|
export LD_PRELOAD=$fakelib
|
||||||
FAKETIME="$timestring" \
|
FAKETIME="$timestring" \
|
||||||
"$@"
|
"$@"
|
||||||
@@ -39,7 +42,7 @@ sunos_fakecmd()
|
|||||||
linuxlike_fakecmd()
|
linuxlike_fakecmd()
|
||||||
{
|
{
|
||||||
typeset timestring="$1"; shift
|
typeset timestring="$1"; shift
|
||||||
typeset fakelib=../src/libfaketime.so.1
|
typeset fakelib="$LIBFAKETIME_LA"
|
||||||
export LD_PRELOAD=$fakelib
|
export LD_PRELOAD=$fakelib
|
||||||
FAKETIME="$timestring" \
|
FAKETIME="$timestring" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|||||||
72
test/test.sh
72
test/test.sh
@@ -1,14 +1,38 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
##################################################################
|
||||||
|
# NOTICE: #
|
||||||
|
# When you edit this script, maintain compatibility with BASH 3. #
|
||||||
|
# This is the version that Apple distributes. #
|
||||||
|
##################################################################
|
||||||
|
|
||||||
|
LIB_BUILD_PATH="../src/$(grep 'LT_OBJDIR' ../config.h | cut -d'"' -f2)"
|
||||||
|
LIBFAKETIME_LA=$(find "$LIB_BUILD_PATH" | grep 'libfaketime\.\(dylib\|so\)$')
|
||||||
|
|
||||||
|
set_libfaketime() {
|
||||||
|
the_path="$LIBFAKETIME_LA"
|
||||||
|
if [ "$(uname)" = "Darwin" ]; then
|
||||||
|
export DYLD_INSERT_LIBRARIES="$the_path"
|
||||||
|
export DYLD_FORCE_FLAT_NAMESPACE=1
|
||||||
|
else
|
||||||
|
export LD_PRELOAD="$the_path"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $(set_libfaketime)
|
||||||
|
|
||||||
|
|
||||||
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 "\$ $(set_libfaketime) ./timetest"
|
||||||
LD_PRELOAD=../src/libfaketime.so.1 ./timetest
|
set_libfaketime
|
||||||
|
./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 "\$ $(set_libfaketime) ./timetest"
|
||||||
LD_PRELOAD=../src/libfaketime.so.1 ./timetest
|
set_libfaketime
|
||||||
|
./timetest
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -16,48 +40,62 @@ 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 "\$ $(set_libfaketime) FAKETIME=\"2003-01-01 10:00:05\" ./timetest"
|
||||||
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="2003-01-01 10:00:05" ./timetest
|
set_libfaketime
|
||||||
|
export 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 "\$ $(set_libfaketime) FAKETIME=\"@2005-03-29 14:14:14\" ./timetest"
|
||||||
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="@2005-03-29 14:14:14" ./timetest
|
set_libfaketime
|
||||||
|
export 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 "$(set_libfaketime) FAKETIME=\"-10d\" ./timetest"
|
||||||
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-10d" ./timetest
|
set_libfaketime
|
||||||
|
export 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 "\$ $(set_libfaketime) FAKETIME=\"-10d\" NO_FAKE_STAT=1 ./timetest"
|
||||||
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-10d" NO_FAKE_STAT=1 ./timetest
|
set_libfaketime
|
||||||
|
export FAKETIME="-10d"
|
||||||
|
export 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 sped up 2 times"
|
||||||
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"+10d x1\" ./timetest"
|
echo "\$ $(set_libfaketime) FAKETIME=\"+10d x2\" ./timetest"
|
||||||
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="+10d x1" NO_FAKE_STAT=1 ./timetest
|
set_libfaketime
|
||||||
|
export FAKETIME="+10d x2"
|
||||||
|
export 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 "\$ $(set_libfaketime) FAKETIME=\"-15d\" date"
|
||||||
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="-15d" date
|
set_libfaketime
|
||||||
|
export FAKETIME="-15d"
|
||||||
|
date
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "============================================================================="
|
echo "============================================================================="
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export DYLD_FORCE_FLAT_NAMESPACE=1
|
|
||||||
export DYLD_INSERT_LIBRARIES=../src/libfaketime.1.dylib
|
|
||||||
|
|
||||||
if [ -f /etc/faketimerc ] ; then
|
|
||||||
echo "Running the test program with your system-wide default in /etc/faketimerc"
|
|
||||||
./timetest
|
|
||||||
echo
|
|
||||||
else
|
|
||||||
echo "Running the test program with no faked time specified"
|
|
||||||
./timetest
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Running the test program with absolute date 2003-01-01 10:00:05 specified"
|
|
||||||
echo "FAKETIME=\"2003-01-01 10:00:05\" ./timetest"
|
|
||||||
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 "FAKETIME=\"@2005-03-29 14:14:14\" ./timetest"
|
|
||||||
FAKETIME="@2005-03-29 14:14:14" ./timetest
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "Running the test program with 10 days negative offset specified"
|
|
||||||
echo "FAKETIME=\"-10d\" ./timetest"
|
|
||||||
FAKETIME="-10d" ./timetest
|
|
||||||
echo
|
|
||||||
|
|
||||||
# FAKE_STAT is disabled on macOS by default, so testing NO_FAKE_STAT is not useful
|
|
||||||
#echo "Running the test program with 10 days negative offset specified, and FAKE_STAT disabled"
|
|
||||||
#echo "FAKETIME=\"-10d\" NO_FAKE_STAT=1 ./timetest"
|
|
||||||
#FAKETIME="-10d" NO_FAKE_STAT=1 ./timetest
|
|
||||||
#echo
|
|
||||||
|
|
||||||
echo "Running the test program with 10 days positive offset specified, and sped up 2 times"
|
|
||||||
echo "FAKETIME=\"+10d x2\" ./timetest"
|
|
||||||
FAKETIME="+10d x2" NO_FAKE_STAT=1 ./timetest
|
|
||||||
echo
|
|
||||||
|
|
||||||
# On more recent macOS versions, the following won't work without copying gdate
|
|
||||||
# to a different folder beforehand. We don't do that here, and since the output
|
|
||||||
# of these tests must be reviewed manually anyway, the timetest binary should be
|
|
||||||
# sufficient to determine whether everything works as planned.
|
|
||||||
|
|
||||||
#echo "Running the 'date' command with 15 days negative offset specified"
|
|
||||||
#echo "FAKETIME=\"-15d\" date"
|
|
||||||
#FAKETIME="-15d" date
|
|
||||||
#echo
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
# see README.testframe.txt for details.
|
# see README.testframe.txt for details.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
testframedir="${BASH_SOURCE%/*}"
|
||||||
|
|
||||||
# echo labelled error/warning message to stderr
|
# echo labelled error/warning message to stderr
|
||||||
report()
|
report()
|
||||||
{
|
{
|
||||||
@@ -33,7 +35,7 @@ run_testsuite()
|
|||||||
# add testsuite dir to PATH for convenience
|
# add testsuite dir to PATH for convenience
|
||||||
typeset dir=$(dirname $testsuite)
|
typeset dir=$(dirname $testsuite)
|
||||||
PATH=$dir:$PATH
|
PATH=$dir:$PATH
|
||||||
. testframe.inc
|
. $testframedir/testframe.inc
|
||||||
if [ -f $dir/common.inc ]; then
|
if [ -f $dir/common.inc ]; then
|
||||||
. $dir/common.inc
|
. $dir/common.inc
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -115,6 +116,7 @@ void* pthread_test(void* args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#include "faketime_common.h"
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user