mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-24 12:16:06 +03:00
Compare commits
119 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57de5bbe83 | ||
|
|
c2b5b71777 | ||
|
|
6c0947c86e | ||
|
|
b36ad2342c | ||
|
|
d40d0ebaa7 | ||
|
|
081845440b | ||
|
|
30207e8fdf | ||
|
|
d2f0daf092 | ||
|
|
c5b5d0b56e | ||
|
|
f8a0ad2496 | ||
|
|
0e3269efdc | ||
|
|
04e78e67bf | ||
|
|
0e798503a4 | ||
|
|
a7f7a54e1d | ||
|
|
8075c2e250 | ||
|
|
a12ca58dfa | ||
|
|
b4dea2ef9b | ||
|
|
796b30bebf | ||
|
|
70d26ec15c | ||
|
|
052239d828 | ||
|
|
fe8c0acee6 | ||
|
|
c44a332e0e | ||
|
|
a54f204209 | ||
|
|
195888434a | ||
|
|
f7de52c07b | ||
|
|
0efe7b3e3e | ||
|
|
b542e14959 | ||
|
|
78385ba8b7 | ||
|
|
b3dcef470e | ||
|
|
90f11685b5 | ||
|
|
d7ef17a0de | ||
|
|
3123ad7fe2 | ||
|
|
af2d2e5111 | ||
|
|
11fbc2ada1 | ||
|
|
f92d919fb0 | ||
|
|
22f8c3dd36 | ||
|
|
a0fe6b56b0 | ||
|
|
fdc3c81ae0 | ||
|
|
10b9818c2c | ||
|
|
826f8b7792 | ||
|
|
5d1e6325f2 | ||
|
|
8ed946cb63 | ||
|
|
108370f850 | ||
|
|
3de0d02353 | ||
|
|
dc2ae5eef3 | ||
|
|
1c05fdd333 | ||
|
|
c60390a7e3 | ||
|
|
ece59abf39 | ||
|
|
d79ed053d7 | ||
|
|
416c5f4708 | ||
|
|
a238cfa2b6 | ||
|
|
ba32d1b01c | ||
|
|
30ba0b852a | ||
|
|
5932e38032 | ||
|
|
13748ddb22 | ||
|
|
5f033fe486 | ||
|
|
52108dba7a | ||
|
|
5ddb237842 | ||
|
|
314b1298c9 | ||
|
|
7573d20cd4 | ||
|
|
0c8905f4ad | ||
|
|
57917c4d5a | ||
|
|
e85863f671 | ||
|
|
d5c0050684 | ||
|
|
b855b8a0d3 | ||
|
|
29efeed247 | ||
|
|
c13e41024e | ||
|
|
65cdc7b718 | ||
|
|
d923612c2b | ||
|
|
59127e7514 | ||
|
|
3b494ac6c9 | ||
|
|
073d185102 | ||
|
|
a70db9196a | ||
|
|
7498c405ed | ||
|
|
aa091db286 | ||
|
|
5e56e9a8fe | ||
|
|
fe42c2b4cf | ||
|
|
579b908580 | ||
|
|
2827a69ffe | ||
|
|
949183381f | ||
|
|
ff48a007a2 | ||
|
|
9846eceb10 | ||
|
|
7bc0d5044f | ||
|
|
ceac4c7036 | ||
|
|
5c4fdb5173 | ||
|
|
150a6cb3b2 | ||
|
|
39a85e380c | ||
|
|
825043515f | ||
|
|
335617c4c7 | ||
|
|
96668a9c6d | ||
|
|
24fd806e6b | ||
|
|
39c6872f6d | ||
|
|
5c6518c597 | ||
|
|
93148b3599 | ||
|
|
9a2c84d68c | ||
|
|
8e5af129ff | ||
|
|
096c11b563 | ||
|
|
9bfae502d1 | ||
|
|
0d964363a4 | ||
|
|
8107db7849 | ||
|
|
c9473def03 | ||
|
|
baeed314cf | ||
|
|
90727b7d19 | ||
|
|
8c22d91057 | ||
|
|
a5d7f5b1cc | ||
|
|
229ce22fbc | ||
|
|
0487e41c34 | ||
|
|
b3a2667e9f | ||
|
|
6a4d1cc84e | ||
|
|
87d2a67401 | ||
|
|
3881dd2ebf | ||
|
|
fb91c4fcde | ||
|
|
ab7a2302f2 | ||
|
|
d117ad79a2 | ||
|
|
5235f6f417 | ||
|
|
3376334dfc | ||
|
|
bb635e4367 | ||
|
|
a79f5330f4 | ||
|
|
0dee4f88e0 |
23
.github/workflows/make-test.yml
vendored
Normal file
23
.github/workflows/make-test.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
name: Run make test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
schedule:
|
||||
- cron: '30 9 * * *'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: make
|
||||
run: make
|
||||
- name: make test
|
||||
run: make test
|
||||
21
.gitignore
vendored
21
.gitignore
vendored
@@ -7,3 +7,24 @@ src/libfaketime.1.dylib
|
||||
src/core
|
||||
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
|
||||
|
||||
17
.travis.yml
Normal file
17
.travis.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
language: c
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
- os: osx
|
||||
osx_image: xcode11
|
||||
|
||||
script:
|
||||
- cd ${TRAVIS_BUILD_DIR}
|
||||
- sh ./build.sh init
|
||||
- ./configure
|
||||
- FAKETIME_COMPILE_CFLAGS="-DFORCE_MONOTONIC_FIX" make
|
||||
- cd 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
|
||||
34
Makefile
34
Makefile
@@ -1,34 +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 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
|
||||
42
NEWS
42
NEWS
@@ -1,3 +1,45 @@
|
||||
Since 0.9.9:
|
||||
- Mike Stemle added GNU autotools
|
||||
- Additional link-time LDFLAGS can be passed via the
|
||||
environment variable FAKETIME_LINK_FLAGS when
|
||||
running 'make'.
|
||||
|
||||
Since 0.9.8:
|
||||
- Compile-time CFLAG FAKE_SETTIME can be enabled to
|
||||
intercept calls to clock_settime(), settimeofday(), and
|
||||
adjtime(). (suggested and prototyped by @ojura)
|
||||
- Additional compile-time CFLAGs can be passed via the
|
||||
environment variable FAKETIME_COMPILE_CFLAGS when
|
||||
running 'make'.
|
||||
- src/Makefile CFLAG FORCE_PTHREAD_NONVER should be set on
|
||||
systems that hang on CLOCK_REALTIME, or that hang on
|
||||
CLOCK_MONOTONIC where FORCE_MONOTONIC_FIX is not sufficient.
|
||||
|
||||
Since 0.9.7:
|
||||
- Passthrough for unknown clock ids to avoid error messages
|
||||
- Fixes for multithreaded operations (mliertzer, qnox)
|
||||
- glibc-related fixes (jprjr) and gcc8 support (tpetazzoni)
|
||||
- Improved error message output on parsing errors
|
||||
- fix file stat() faking when 'i' modifier is used for determinism
|
||||
- Use FAKETIME="%" to take FAKETIME setting from a file as
|
||||
specified in FAKETIME_FOLLOW_FILE
|
||||
- Added FAKETIME_DONT_RESET environment variable to avoid
|
||||
faketime resets when subprocesses are started (similar to
|
||||
the old v0.9.6 behavior)
|
||||
- Added FAKETIME_XRESET to avoid large clock jumps when
|
||||
the 'x' modifier is used and changed during run-time
|
||||
- Do not fake time during libfaketime initialization to
|
||||
improve compatibility with memory allocation libraries that
|
||||
use time-related functions themselves
|
||||
- Fixes for shared memory related issues, especially when
|
||||
not using the faketime wrapper
|
||||
- Updated glibc compatibility settings for various platforms
|
||||
- Support for clock_nanosleep() with realtime and monotonic clocks
|
||||
- Support for epoll_wait(), epoll_pwait(), and pselect()
|
||||
- src/Makefile CFLAG FORCE_MONOTONIC_FIX should be set (only) on
|
||||
platforms where the test program hangs forever at the
|
||||
CLOCK_MONOTONIC test.
|
||||
|
||||
Since 0.9.6:
|
||||
- Julien Gilli added an option to disable monotonic time faking
|
||||
- Azat Khuzhin added support for COARSE clocks
|
||||
|
||||
178
README
178
README
@@ -1,5 +1,5 @@
|
||||
libfaketime, version 0.9.7 (November 2017)
|
||||
==========================================
|
||||
libfaketime, version 0.9.8 (August 2019)
|
||||
========================================
|
||||
|
||||
|
||||
Content of this file:
|
||||
@@ -71,24 +71,51 @@ documentation whether it can be achieved by using libfaketime directly.
|
||||
rebuilding libfaketimeMT.so.1
|
||||
|
||||
* Java-/JVM-based applications work but you need to pass in an extra argument
|
||||
(DONT_FAKE_MONOTONIC). See usage basics below for details. Without this
|
||||
argument the java command usually hangs.
|
||||
(FAKETIME_DONT_FAKE_MONOTONIC). See usage basics below for details. Without
|
||||
this argument the java command usually hangs.
|
||||
|
||||
* libfaketime will eventually be bypassed by applications that dynamically load
|
||||
system libraries, such as librt, explicitly themselves instead of relying on
|
||||
the linker to do so at application start time. libfaketime will not work with
|
||||
those applications unless you can modify them.
|
||||
|
||||
This apparently happens a lot in complex run-time environments, e.g., for
|
||||
programs written in golang, for some Java Virtual Machine implementations,
|
||||
etc. Since libfaketime is effectively bypassed in such situations, there's
|
||||
nothing we can do about it. Please consider asking the appropriate developers
|
||||
and vendors to implement their runtime environment in a way that supports
|
||||
intercepting selected system calls through LD_PRELOAD.
|
||||
|
||||
* Applications can explicitly be designed to prevent libfaketime from working,
|
||||
e.g., by checking whether certain environment variables are set or whether
|
||||
libfaketime-specific files are present.
|
||||
|
||||
* CLOCK_MONOTONIC test: Running "make test" performs a series of tests after
|
||||
successful compilation of the libfaketime library. On some platforms, the
|
||||
"CLOCK_MONOTONIC test" will apparently hang forever. If and only if this
|
||||
happens on your platform, add the CFLAG -DFORCE_MONOTONIC_FIX to
|
||||
src/Makefile and recompile libfaketime. Do not set FORCE_MONOTONIC_FIX on
|
||||
platforms where the test does not hang.
|
||||
|
||||
If you observe hangs on the CLOCK_REALTIME test, add the CFLAG
|
||||
-DFORCE_PTHREAD_NONVER. Also set this FORCE_PTHREAD_NONVER flag in case
|
||||
FORCE_MONOTONIC_FIX alone does not solve the hang on the MONOTONIC_CLOCK
|
||||
test.
|
||||
|
||||
|
||||
3. Installation
|
||||
---------------
|
||||
|
||||
Running "make" compiles both library versions and a test program, which it then
|
||||
also executes.
|
||||
This library supports GNU autotools, so you should be able to build it with:
|
||||
|
||||
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
|
||||
(libfaketime.so.1, and libfaketimeMT.so.1) to the place you want them in.
|
||||
@@ -111,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
|
||||
calls will be passed through unaltered.
|
||||
|
||||
On macOS, it is necessary to compile differently, due to the different
|
||||
behavior dyld has. Use the Makefile.OSX file provided to compile
|
||||
libfaketime.1.dylib. Additionally, instead of using LD_PRELOAD,
|
||||
the variable DYLD_INSERT_LIBRARIES should be set to the path to
|
||||
libfaketime.1.dylib, and the variable DYLD_FORCE_FLAT_NAMESPACE should be
|
||||
set (to anything). macOS users should read README.OSX for additional
|
||||
details.
|
||||
On macOS, instead of using LD_PRELOAD, the variable DYLD_INSERT_LIBRARIES
|
||||
should be set to the path to libfaketime.0.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
|
||||
--------
|
||||
@@ -141,7 +170,7 @@ user@host> LD_PRELOAD=/usr/local/lib/libfaketime.so.1 FAKETIME="-15d" date
|
||||
Mon Nov 8 12:01:12 CEST 2016
|
||||
|
||||
user@host> LD_PRELOAD=/usr/local/lib/libfaketime.so.1 FAKETIME="-15d"
|
||||
DONT_FAKE_MONOTONIC=1 java -version
|
||||
FAKETIME_DONT_FAKE_MONOTONIC=1 java -version
|
||||
java version "1.8.0_111"
|
||||
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
|
||||
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
|
||||
@@ -205,6 +234,22 @@ specified absolute time. The 'start at' format allows a 'relative' clock
|
||||
operation as described below in section 4d), but using a 'start at' time
|
||||
instead of an offset time.
|
||||
|
||||
If the started process itself starts other (child) processes, they by default
|
||||
will start with the specified start-at-date again. If this is not what you need,
|
||||
set the environment variable FAKETIME_DONT_RESET=1. Try these examples to see
|
||||
the difference:
|
||||
|
||||
LD_PRELOAD=src/libfaketime.so.1 FAKETIME="@2000-01-01 11:12:13" \
|
||||
FAKETIME_DONT_RESET=1 \
|
||||
/bin/bash -c 'while [ $SECONDS -lt 5 ]; do date; sleep 1; done'
|
||||
|
||||
LD_PRELOAD=src/libfaketime.so.1 FAKETIME="@2000-01-01 11:12:13" \
|
||||
/bin/bash -c 'while [ $SECONDS -lt 5 ]; do date; sleep 1; done'
|
||||
|
||||
In the second example, the "date" command will always print the same time,
|
||||
while in the first example, with FAKETIME_DONT_RESET set, time will increment
|
||||
even though all the "date" commands are new processes.
|
||||
|
||||
|
||||
4d) Using offsets for relative dates
|
||||
------------------------------------
|
||||
@@ -224,6 +269,11 @@ optionally followed by a multiplier:
|
||||
export FAKETIME="-10m" sets the faked time 10 minutes behind the real time.
|
||||
export FAKETIME="+14d" sets the faked time to 14 days in the future.
|
||||
|
||||
Please note that if you need other multipliers (weeks, months etc.) or higher
|
||||
precision (e.g., correct leap year handling), you should use either the
|
||||
faketime wrapper or the GNU date command as shown in the first of the three
|
||||
examples below.
|
||||
|
||||
You now should understand the complete example we've used before:
|
||||
|
||||
LD_PRELOAD=/usr/local/lib/libfaketime.so.1 FAKETIME="-15d" date
|
||||
@@ -281,6 +331,11 @@ completely independently of the system clock. It helps running programs
|
||||
with some determinism. In this single case all spawned processes will use
|
||||
the same global clock without restarting it at the start of each process.
|
||||
|
||||
Please note that using "x" or "i" in FAKETIME still requires giving an offset
|
||||
(see section 4d). This means that "+1y x2" will work, but "x2" only will not.
|
||||
If you do not want to fake the time, but just modify clock speed, use something
|
||||
like "+0 x2", i.e., use an explizit zero offset as a prefix in your FAKETIME.
|
||||
|
||||
For testing, your should run a command like
|
||||
|
||||
LD_PRELOAD=./libfaketime.so.1 FAKETIME="+1,5y x10,0" \
|
||||
@@ -326,6 +381,101 @@ with FAKETIME_NO_CACHE=1. Remember that disabling the cache may negatively
|
||||
influence the performance.
|
||||
|
||||
|
||||
Setting FAKETIME by means of a file timestamp
|
||||
---------------------------------------------
|
||||
|
||||
Based on a proposal by Hitoshi Harada (umitanuki), the "start at" time can now be
|
||||
set through any file in the file system by setting the FAKETIME environment variable
|
||||
to "%" (a percent sign) and FAKETIME_FOLLOW_FILE to the name of the file whose
|
||||
modification timestamp shall be used as source for the "start at" time.
|
||||
|
||||
Usage example:
|
||||
|
||||
# create any file with December 24th, 2009, 12:34:56 as timestamp
|
||||
touch -t 0912241234.56 /tmp/my-demo-file.tmp
|
||||
|
||||
# run a bash shell with an endless loop printing the current time
|
||||
LD_PRELOAD=/path/to/libfaketime.so.1 \
|
||||
FAKETIME='%' FAKETIME_FOLLOW_FILE=/tmp/my-demo-file.tmp \
|
||||
FAKETIME_DONT_RESET=1 \
|
||||
bash -c 'while true ; do date ; sleep 1 ; done'
|
||||
|
||||
# now, while the above is running, change the file's timestamp
|
||||
# (in a different terminal window or whatever)
|
||||
touch -t 2002290123.45 /tmp/my-demo-file.tmp
|
||||
|
||||
|
||||
Changing the 'x' modifier during run-time
|
||||
-----------------------------------------
|
||||
|
||||
Using FAKETIME_TIMESTAMP_FILE allows for easily changing the FAKETIME setting
|
||||
while a program is running:
|
||||
|
||||
echo "+0 x1" > /tmp/my-faketime.rc
|
||||
LD_PRELOAD=libfaketime.so.1 FAKETIME_TIMESTAMP_FILE="/tmp/my-faketime.rc" \
|
||||
FAKETIME_NO_CACHE=1 ./some-program &
|
||||
sleep 10 ; echo "+0 x10" > /tmp/my-faketime.rc
|
||||
|
||||
Changing the speed of the wall clock time, i.e., using a different 'x' modifier
|
||||
during run-time, by default can lead to greater jumps that may confuse the
|
||||
program. For example, if the program has been running for 10 seconds on 'x1',
|
||||
and then the setting is changed to 'x10', the faked time will look to the
|
||||
program as if it has been running for more than 100 instead of just more than
|
||||
10 seconds.
|
||||
|
||||
By setting the environment variable FAKETIME_XRESET to any value, transitions
|
||||
between different 'x' modifier values will be significantly smoothed:
|
||||
|
||||
LD_PRELOAD=libfaketime.so.1 FAKETIME_TIMESTAMP_FILE="/tmp/my-faketime.rc" \
|
||||
FAKETIME_NO_CACHE=1 FAKETIME_XRESET=1 ./some-program &
|
||||
|
||||
Setting FAKETIME_XRESET ensures that wall clock time begins to run faster
|
||||
only after the 'x' modifier has been changed (when increasing it) and also
|
||||
ensures that the reported faked time does not jump back to past values
|
||||
(when decreasing it).
|
||||
|
||||
Please note that FAKETIME_XRESET internally works by resetting libfaketime's
|
||||
internal time-keeping data structures, which may have side effects on reported
|
||||
file timestamps. Using FAKETIME_XRESET should be considered experimental at
|
||||
the moment.
|
||||
|
||||
|
||||
Cleaning up shared memory
|
||||
-------------------------
|
||||
|
||||
libfaketime uses semaphores and shared memory on platforms that support it in
|
||||
order to sync faketime settings across parent-child processes. It will clean
|
||||
up when it exits properly. However, when processes are terminated (e.g., by
|
||||
Ctrl-C on command line), shared memory cannot be cleaned up properly. In such
|
||||
cases, you should occasionally delete
|
||||
|
||||
/dev/shm/faketime_shm_* and
|
||||
/dev/shm/sem.faketime_sem_*
|
||||
|
||||
manually (or properly automated). Leftover files there from processes that
|
||||
already have been terminated are not a problem in general, but result in a
|
||||
libfaketime error the next time a process is started with a process id for
|
||||
which such a stale semaphore/shared memory exists. Thus, if you run across
|
||||
the following error message
|
||||
|
||||
libfaketime: In ft_shm_create(), shm_open failed: File exists
|
||||
|
||||
please cleanup /dev/shm as described above. This is especially relevant
|
||||
for long-running systems (servers with high uptime) and systems on which
|
||||
a lot of processes are started (e.g., servers handling many containers
|
||||
or similar virtualization mechanisms).
|
||||
|
||||
|
||||
Intercepting time-setting calls
|
||||
-------------------------------
|
||||
|
||||
libfaketime can be compiled with the CFLAG "-DFAKE_SETTIME" in order
|
||||
to also intercept time-setting functions, i.e., clock_settime(),
|
||||
settimeofday(), and adjtime(). Instead of passing the timestamp a
|
||||
program sets through to the system, only the FAKETIME environment
|
||||
variable will be adjusted accordingly.
|
||||
|
||||
|
||||
4f) Faking the date and time system-wide
|
||||
----------------------------------------
|
||||
|
||||
|
||||
55
README.OSX
55
README.OSX
@@ -4,17 +4,15 @@ README file for libfaketime on macOS
|
||||
Support for macOS has meanwhile matured and many command line and
|
||||
GUI applications will run stable.
|
||||
|
||||
Developments and tests are done on High Sierra currently.
|
||||
Use libfaketime 0.9.6 or earlier on OS X (i.e., before Sierra).
|
||||
Developments and tests are done on Mojave currently.
|
||||
|
||||
Version 0.9.5 and higher no longer works with OSX <= 10.6 due to
|
||||
Version 0.9.5 and higher no longer work with OSX <= 10.6 due to
|
||||
changes in the underlying system libraries. If you need libfaketime
|
||||
on OSX <= 10.6, please use libfaketime version 0.9.
|
||||
|
||||
|
||||
Installing and using libfaketime on OS X is slightly different than
|
||||
Installing and using libfaketime on macOS is slightly different than
|
||||
on Linux. Please make sure to read the README file for general
|
||||
setup and usage, and refer to this file only about OS X specifics.
|
||||
setup and usage, and refer to this file only about macOS specifics.
|
||||
|
||||
|
||||
1) Installing libfaketime on macOS
|
||||
@@ -33,29 +31,38 @@ Or, if you use Homebrew, install using:
|
||||
|
||||
brew install libfaketime
|
||||
|
||||
Please inform the respective package maintainers if the latest release
|
||||
is not yet available this way. With homebrew, you can typically use
|
||||
"brew install --HEAD" to install from the latest source automatically.
|
||||
|
||||
Otherwise, you have to compile and install libfaketime manually; this
|
||||
will require a working installation of Xcode and its command line tools
|
||||
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
|
||||
|
||||
in libfaketime's top-level directory.
|
||||
|
||||
The resulting library will be named libfaketime.1.dylib ; to check
|
||||
whether it works properly, run the test suite and verify whether its
|
||||
output is correct:
|
||||
|
||||
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
|
||||
---------------------------------------------------
|
||||
|
||||
You will need to set three environment variables. In a Terminal.app
|
||||
or iTerm2 session, the following commands can be used:
|
||||
or any other CLI session, the following commands can be used:
|
||||
|
||||
export DYLD_FORCE_FLAT_NAMESPACE=1
|
||||
export DYLD_INSERT_LIBRARIES=/path/to/libfaketime.1.dylib
|
||||
@@ -76,7 +83,7 @@ for help and use "man faketime" for details.
|
||||
--------------------------------------------
|
||||
|
||||
Given the limited number of system calls libfaketime intercepts,
|
||||
it may not work too well with specific GUI applications on OS X.
|
||||
it may not work too well with specific GUI applications on macOS.
|
||||
This can result in crashes after a seemingly random time, or an
|
||||
application will not or at least not always see the faked time,
|
||||
and so on.
|
||||
@@ -127,13 +134,20 @@ time-related system calls that need to be intercepted on macOS.
|
||||
|
||||
https://github.com/wolfcw/libfaketime/issues
|
||||
|
||||
Important: When reporting non-working applications, please make
|
||||
sure that your issue is not related to SIP (system integrity
|
||||
protection). For example, on a SIP-enabled, default macOS installation,
|
||||
libfaketime will not work for programs like /bin/bash because
|
||||
the path /bin is SIP-protected. Copy your application to a
|
||||
non-SIP-protected path, and if libfaketime still does not work,
|
||||
feel free to report it.
|
||||
However, there are two important aspects:
|
||||
|
||||
- When reporting non-working applications, please make sure that your issue is
|
||||
not related to SIP (system integrity protection). For example, on a
|
||||
SIP-enabled, default macOS installation, libfaketime will not work for
|
||||
programs like /bin/bash because the path /bin is SIP-protected. Copy your
|
||||
application to a non-SIP-protected path, and if libfaketime still does not
|
||||
work, feel free to report it.
|
||||
|
||||
- We cannot and will not help with using libfaketime for proprietary or
|
||||
commercial software unless you are its developer trying to integrate
|
||||
libfaketime. Please contact the developers or the vendor directly if
|
||||
you have problems using libfaketime with non-free / not open sourced
|
||||
macOS applications.
|
||||
|
||||
|
||||
4) Notes for developers of macOS applications
|
||||
@@ -141,4 +155,5 @@ feel free to report it.
|
||||
|
||||
The environment variable FAKETIME can be changed at application run-time
|
||||
and always takes precedence over other user-controlled settings. It can
|
||||
be re-set to 0 (zero) to work around potential incompatibilities.
|
||||
be re-set to 0 (zero) to work around potential incompatibilities or if
|
||||
you do not want libfaketime applied to your software.
|
||||
|
||||
@@ -4,20 +4,27 @@ This file contains information for libfaketime developers and contributors.
|
||||
GENERAL
|
||||
=======
|
||||
|
||||
Starting with libfaketime v0.9.5, development and issue handling is
|
||||
completely done via Github:
|
||||
Starting with libfaketime v0.9.5, development and issue handling is
|
||||
completely done via Github:
|
||||
|
||||
https://github.com/wolfcw/libfaketime
|
||||
|
||||
- Official releases are tagged.
|
||||
- Code contributions and bugfixes are merged into the "development" branch,
|
||||
which is considered unstable and may contain code that is not yet fully
|
||||
tested.
|
||||
- Official releases are tagged.
|
||||
|
||||
- Code contributions and bugfixes should be submitted to and then merged into
|
||||
the "development" branch, which is considered unstable and may contain code
|
||||
that is not yet fully tested.
|
||||
|
||||
- The "master" branch is updated with tested code only; it is ensured that
|
||||
it compiles and works cleanly at least on current Linux and OS X systems.
|
||||
it compiles and works cleanly at least on current Linux and macOS systems.
|
||||
|
||||
Code contributions are highly welcome, preferably via pull requests on Github.
|
||||
|
||||
Please have a look at issues labelled as "help wanted" in the Github issue
|
||||
tracker. If you are interested in contributing to libfaketime, helping with
|
||||
these issues is not only much appreciated, but also a good way to familiarize
|
||||
yourself with the overall codebase.
|
||||
|
||||
|
||||
CODE STYLE
|
||||
==========
|
||||
@@ -43,16 +50,16 @@ void do_nothing(int how_often)
|
||||
}
|
||||
}
|
||||
|
||||
- Use -DDEBUG and #ifdef DEBUG for development and testing. Avoid printing
|
||||
to stdout or stderr outside "#ifdef DEBUG"; if it is necessary to inform
|
||||
the user a run-time, prefix your output with "faketime" or make otherwise
|
||||
sure that the user knows where the message is coming from.
|
||||
- Use -DDEBUG and #ifdef DEBUG for development and testing. Avoid printing to
|
||||
stdout or stderr outside "#ifdef DEBUG"; if it is necessary to inform the
|
||||
user a run-time, prefix your output with "libfaketime" or make otherwise sure
|
||||
that the user knows where the message is coming from.
|
||||
|
||||
- If you add new functions to libfaketime.c, try placing them somewhere
|
||||
where they fit will: Usually, functions are grouped by functionality
|
||||
(e.g., all functions related to faking file timestamps). If that's not
|
||||
possible, group them by contributor, or document your placement strategy
|
||||
in the commit message.
|
||||
in the commit message.
|
||||
|
||||
|
||||
DEVELOPMENT, BUILDING, AND TESTING
|
||||
@@ -62,19 +69,19 @@ DEVELOPMENT, BUILDING, AND TESTING
|
||||
the modification fixes bugs :-)).
|
||||
|
||||
- Add tests for new features. Extend test/timetest.c appropriately and
|
||||
try to use the functional testing framework wherever possible.
|
||||
try to use the functional testing framework wherever possible.
|
||||
|
||||
- Compiler and linker warnings are treated as errors and not acceptable.
|
||||
|
||||
- If you cannot test the code on both Linux and OS X yourself, please
|
||||
let us know and consider wrapping your code in #ifdef / #ifndef __APPLE__
|
||||
statements.
|
||||
- If you cannot test the code on both Linux and macOS yourself, please
|
||||
let us know and consider wrapping your code in #ifdef / #ifndef __APPLE__
|
||||
statements.
|
||||
|
||||
|
||||
DOCUMENTATION
|
||||
=============
|
||||
|
||||
For anything more than small bugfixes, please update the user documentation
|
||||
For anything more than small bugfixes, please update the user documentation
|
||||
and credits appropriately:
|
||||
|
||||
- The NEWS file should mention the change and your credits.
|
||||
@@ -83,8 +90,8 @@ and credits appropriately:
|
||||
- The manpage man/faketime.1 should be updated when the wrapper application
|
||||
is modified.
|
||||
|
||||
For credits, please either mention your real name, your Github username, or
|
||||
your email address.
|
||||
For credits, please either mention your real name, your Github username, or
|
||||
your email address.
|
||||
|
||||
In your own interest, please be verbose on user documentation and comments
|
||||
in the source code. Users will not know about new features unless they are
|
||||
@@ -97,7 +104,7 @@ RELEASES
|
||||
|
||||
Official new releases are created whenever a significant amount of changes
|
||||
(bugfixes or new functionality) has piled up; on average, there is one new
|
||||
official release per year. Users who need to stick to the bleeding edge
|
||||
official release per 1-2 years. Users who need to stick to the bleeding edge
|
||||
are supposed to use the current state of the "master" branch at any time.
|
||||
|
||||
libfaketime maintainers for several Linux distributions are informed about
|
||||
|
||||
63
README.packagers
Normal file
63
README.packagers
Normal file
@@ -0,0 +1,63 @@
|
||||
README for packagers of libfaketime
|
||||
|
||||
First, thank you for your efforts to make libfaketime packages available
|
||||
on your platform / distribution!
|
||||
|
||||
libfaketime has tagged releases about once every 1-2 years, made available
|
||||
through github.com/wolfcw/libfaketime, but usually it is also safe (i.e.,
|
||||
stable) to use the latest HEAD of the master branch, which contains bug
|
||||
fixes since the last tagged release.
|
||||
|
||||
You may want to familiarize yourself with the options you can set into
|
||||
src/Makefile, but sane defaults for stable operations have been chosen.
|
||||
|
||||
Currently, libfaketime does not use autotools yet, so there is
|
||||
_no_ ./configure step, but "make" and "make test" will work as expected.
|
||||
|
||||
|
||||
However, one problem makes it somewhat difficult to get libfaketime
|
||||
working on different platforms:
|
||||
|
||||
libfaketime currently has the challenge that depending on the version
|
||||
of glibc and the platform (e.g., x86_64 or aarch64) certain compiler
|
||||
CFLAGS have to be set manually, as we have not yet found a way to
|
||||
safely determine behavior at run-time automatically.
|
||||
|
||||
Please proceed as follows:
|
||||
|
||||
- run "make test". If everything runs through smoothly and you do not
|
||||
encounter any hangs or test failure reports, use the binaries as
|
||||
they are.
|
||||
|
||||
- If you encounter endless hangs during the CLOCK_REALTIME test,
|
||||
add -DFORCE_PTHREAD_NONVER to the CFLAGS.
|
||||
|
||||
- If you encounter endless hangs during the CLOCK_MONOTONIC test,
|
||||
add -DFORCE_MONOTONIC_FIX to the CFLAGS. If it works with that,
|
||||
it's fine, otherwise additionally use -DFORCE_PTHREAD_NONVER.
|
||||
|
||||
CFLAGS can also be passed through the FAKETIME_COMPILE_CFLAGS environment
|
||||
variable, so for example
|
||||
|
||||
FAKETIME_COMPILE_CFLAGS="-DFORCE_PTHREAD_NONVER" make test
|
||||
|
||||
would create the libfaketime binaries and run the tests with the
|
||||
FORCE_PTHREAD_NONVER flag set in a single step. Likewise there is
|
||||
FAKETIME_LINK_FLAGS.
|
||||
|
||||
Please do not use FORCE_MONOTONIC_FIX by default, as it would result
|
||||
in incorrect operations on platforms that do not need it.
|
||||
|
||||
Our observations with a limited number of Linux distributions is that
|
||||
libfaketime may require different compile flags per platform even
|
||||
if the same distribution and glibc version is used across these
|
||||
platforms.
|
||||
|
||||
As soon as we have found a reliable way to automatically choose the
|
||||
correct compile-time flags, we will remove this burden from you as
|
||||
packager for obvious reasons. Until then, please feel free to report
|
||||
your experiences with different platforms and distribution versions
|
||||
through the issue tracker on Github.
|
||||
|
||||
Again, thanks for your time and effort to make libfaketime available
|
||||
easily for everyone else!
|
||||
20
TODO
20
TODO
@@ -1,9 +1,15 @@
|
||||
Open issues / next steps for libfaketime development
|
||||
Open issues / next steps for libfaketime development:
|
||||
|
||||
Please see the issue tracker on Github - https://github.com/wolfcw/libfaketime
|
||||
|
||||
- New features, such as additional system calls to intercept, are labelled
|
||||
"feature request" when they are considered for implementation
|
||||
|
||||
- Issues labelled "help wanted" should be your starting point if you are
|
||||
interested in contributing to libfaketime
|
||||
|
||||
Besides the open issues, two major changes are planned for the next release:
|
||||
|
||||
- integrate manchicken's autoconf/automake support to get rid of separate Makefile.OSX
|
||||
|
||||
- add more functional tests that check more than the basic functionality
|
||||
- use the testing framework to also implement unit tests
|
||||
- fake timer_create and friends
|
||||
- work around thread local storage issue, e.g., by using pthreads
|
||||
- add autoconf/automake support to get rid of separate Makefile.OSX
|
||||
- improve pthread support
|
||||
|
||||
|
||||
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,4 +1,4 @@
|
||||
.TH FAKETIME "1" "November 2017" "faketime 0.9.7" wolfcw
|
||||
.TH FAKETIME "1" "August 2019" "faketime 0.9.8" wolfcw
|
||||
.SH NAME
|
||||
faketime \- manipulate the system time for a given command
|
||||
.SH SYNOPSIS
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# Maintainer: Robert Orzanna <orschiro@gmail.com>
|
||||
|
||||
_pkgbasename=libfaketime
|
||||
pkgname=lib32-$_pkgbasename
|
||||
pkgver=0.9.5
|
||||
pkgrel=1
|
||||
pkgdesc='Report fake dates and times to programs without having to change the system-wide time.'
|
||||
arch=('x86_64')
|
||||
url='http://www.code-wizards.com/projects/libfaketime/'
|
||||
license=('GPL2')
|
||||
source=("http://www.code-wizards.com/projects/${_pkgbasename}/${_pkgbasename}-${pkgver}.tar.gz"
|
||||
'lib32.patch')
|
||||
md5sums=('89b5c71e6c6a93b1c6feba374ac37719'
|
||||
'0a01f842df4c8acbd2b081be046e8d67')
|
||||
|
||||
build() {
|
||||
cd "${_pkgbasename}-${pkgver}"
|
||||
patch -p1 -i ../lib32.patch
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${_pkgbasename}-${pkgver}"
|
||||
make PREFIX=/usr DESTDIR="${pkgdir}" install
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
||||
|
||||
On i386 systems, for some reason if i do not clean up this extra -lrt, i get the following error:
|
||||
|
||||
[...]
|
||||
make[1]: Entering directory `/home/dkg/src/faketime/faketime/src'
|
||||
cc -o libfaketime.o -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -std=gnu99 -Wall -Wextra -Werror -DFAKE_STAT -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'/usr/local'"' -DLIBDIRNAME='"'/lib/faketime'"' -DMULTI_ARCH libfaketime.c
|
||||
cc -o libfaketime.so.1 -Wl,-soname,libfaketime.so.1 -Wl,-z,relro -Wl,--version-script=libfaketime.map -lrt -shared libfaketime.o -ldl -lm -lpthread -lrt
|
||||
libfaketime.o: In function `ft_cleanup':
|
||||
/home/dkg/src/faketime/faketime/src/libfaketime.c:1277: multiple definition of `timer_gettime'
|
||||
/home/dkg/src/faketime/faketime/src/libfaketime.c:1277: multiple definition of `timer_settime'
|
||||
collect2: error: ld returned 1 exit status
|
||||
make[1]: *** [libfaketime.so.1] Error 1
|
||||
[...]
|
||||
|
||||
I confess i don't really understand why removing this would fix
|
||||
things, but i also don't see the need to have multiple attempts to
|
||||
link to librt.
|
||||
|
||||
--- a/src/Makefile
|
||||
+++ b/src/Makefile
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
CFLAGS += -std=gnu99 -Wall -Wextra -Werror -DFAKE_STAT -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"'
|
||||
LIB_LDFLAGS += -shared
|
||||
-LDFLAGS += -Wl,--version-script=libfaketime.map -lrt
|
||||
+LDFLAGS += -Wl,--version-script=libfaketime.map
|
||||
LDADD += -ldl -lm -lpthread -lrt
|
||||
|
||||
SRC = libfaketime.c
|
||||
@@ -1,40 +0,0 @@
|
||||
Source: faketime
|
||||
Section: utils
|
||||
Priority: extra
|
||||
Maintainer: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
||||
Build-Depends:
|
||||
debhelper (>= 9),
|
||||
dh-exec (>= 0.3)
|
||||
Standards-Version: 3.9.4
|
||||
Homepage: http://www.code-wizards.com/projects/libfaketime/
|
||||
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/faketime.git
|
||||
Vcs-Git: git://anonscm.debian.org/collab-maint/faketime.git
|
||||
|
||||
Package: faketime
|
||||
Architecture: any
|
||||
Pre-Depends: multiarch-support
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, libfaketime (= ${binary:Version})
|
||||
Multi-Arch: foreign
|
||||
Description: report faked system time to programs
|
||||
The Fake Time Preload Library (FTPL, a.k.a. libfaketime) intercepts
|
||||
various system calls which programs use to retrieve the current date
|
||||
and time. It can then report faked dates and times (as specified by
|
||||
you, the user) to these programs. This means you can modify the
|
||||
system time a program sees without having to change the time
|
||||
system-wide. FTPL allows you to specify both absolute dates (e.g.,
|
||||
2004-01-01) and relative dates (e.g., 10 days ago).
|
||||
|
||||
Package: libfaketime
|
||||
Architecture: any
|
||||
Pre-Depends: multiarch-support
|
||||
Multi-Arch: same
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Description: report faked system time to programs
|
||||
The Fake Time Preload Library (FTPL, a.k.a. libfaketime) intercepts
|
||||
various system calls which programs use to retrieve the current date
|
||||
and time. It can then report faked dates and times (as specified by
|
||||
you, the user) to these programs. This means you can modify the
|
||||
system time a program sees without having to change the time
|
||||
system-wide. FTPL allows you to specify both absolute dates (e.g.,
|
||||
2004-01-01) and relative dates (e.g., 10 days ago).
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
From: Gerardo Malazdrewicz <gerardo@malazdrewicz.com.ar>
|
||||
To: 699559@bugs.debian.org
|
||||
Subject: Avoiding loop (very dirty patch)
|
||||
Date: Tue, 26 Mar 2013 01:18:05 +0100
|
||||
|
||||
[Message part 1 (text/plain, inline)]
|
||||
|
||||
Attached patch works for me, but it is very very dirty.
|
||||
|
||||
Possibly side effects.
|
||||
|
||||
Alternative seems to be to protect the call to real_clock_gettime so it is
|
||||
executed just once (to validate the parameters). Subsequent calls are not
|
||||
needed (parameters have been validated).
|
||||
|
||||
Thanks,
|
||||
Gerardo
|
||||
|
||||
--- a/src/libfaketime.c
|
||||
+++ b/src/libfaketime.c
|
||||
@@ -1380,7 +1380,7 @@ void __attribute__ ((constructor)) ftpl_init(void)
|
||||
real_clock_get_time = dlsym(RTLD_NEXT, "clock_get_time");
|
||||
real_clock_gettime = apple_clock_gettime;
|
||||
#else
|
||||
- real_clock_gettime = dlsym(RTLD_NEXT, "clock_gettime");
|
||||
+ real_clock_gettime = dlsym(RTLD_NEXT, "__clock_gettime");
|
||||
#ifdef FAKE_TIMERS
|
||||
real_timer_settime_22 = dlvsym(RTLD_NEXT, "timer_settime","GLIBC_2.2");
|
||||
real_timer_settime_233 = dlvsym(RTLD_NEXT, "timer_settime","GLIBC_2.3.3");
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/dh-exec
|
||||
src/libfaketime.so.1 usr/lib/${DEB_HOST_MULTIARCH}/faketime/
|
||||
src/libfaketimeMT.so.1 usr/lib/${DEB_HOST_MULTIARCH}/faketime/
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
||||
# Date: Tue, 26 Aug 2008 14:24:50 -0400
|
||||
|
||||
export DEB_CFLAGS_MAINT_APPEND=-DMULTI_ARCH
|
||||
|
||||
# make sure dh_makeshlibs does not modify post{inst,rm} scripts:
|
||||
# (avoids lintian's postinst-has-useless-call-to-ldconfig)
|
||||
override_dh_makeshlibs:
|
||||
dh_makeshlibs --noscripts
|
||||
|
||||
override_dh_installchangelogs:
|
||||
dh_installchangelogs NEWS
|
||||
|
||||
%:
|
||||
PREFIX=/usr dh $@
|
||||
@@ -1,13 +0,0 @@
|
||||
diff --git a/src/libfaketime.c b/src/libfaketime.c
|
||||
index 3ec372b..f70283b 100644
|
||||
--- a/src/libfaketime.c
|
||||
+++ b/src/libfaketime.c
|
||||
@@ -1380,7 +1380,7 @@ void __attribute__ ((constructor)) ftpl_init(void)
|
||||
real_clock_get_time = dlsym(RTLD_NEXT, "clock_get_time");
|
||||
real_clock_gettime = apple_clock_gettime;
|
||||
#else
|
||||
- real_clock_gettime = dlsym(RTLD_NEXT, "clock_gettime");
|
||||
+ real_clock_gettime = dlsym(RTLD_NEXT, "__clock_gettime");
|
||||
#ifdef FAKE_TIMERS
|
||||
real_timer_settime_22 = dlvsym(RTLD_NEXT, "timer_settime","GLIBC_2.2");
|
||||
real_timer_settime_233 = dlvsym(RTLD_NEXT, "timer_settime","GLIBC_2.3.3");
|
||||
@@ -1,55 +0,0 @@
|
||||
Summary: Manipulate system time per process for testing purposes
|
||||
Name: libfaketime
|
||||
Version: 0.9.5
|
||||
Release: 4%{?dist}
|
||||
License: GPLv2+
|
||||
Url: http://www.code-wizards.com/projects/%{name}/
|
||||
Source: http://www.code-wizards.com/projects/%{name}/%{name}-%{version}.tar.gz
|
||||
Group: System Environment/Libraries
|
||||
Patch1: libfaketime-0.9.5-fix-infinite-recursion-on-real_clock_gettime.patch
|
||||
|
||||
%description
|
||||
libfaketime intercepts various system calls which programs use to
|
||||
retrieve the current date and time. It can then report faked dates and
|
||||
times (as specified by you, the user) to these programs. This means you
|
||||
can modify the system time a program sees without having to change the
|
||||
time system- wide.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch1 -p1
|
||||
# work around from upstream for autodetecting glibc version bug on i686
|
||||
sed -i -e 's/__asm__(".symver timer_gettime_22/\/\/__asm__(".symver timer_gettime_22/' src/libfaketime.c
|
||||
sed -i -e 's/__asm__(".symver timer_settime_22/\/\/__asm__(".symver timer_settime_22/' src/libfaketime.c
|
||||
|
||||
|
||||
%build
|
||||
cd src ; CFLAGS="$RPM_OPT_FLAGS -Wno-strict-aliasing" make %{?_smp_mflags} \
|
||||
PREFIX="%{_prefix}" LIBDIRNAME="/%{_lib}/faketime" all
|
||||
|
||||
%check
|
||||
make %{?_smp_mflags} -C test all
|
||||
|
||||
%install
|
||||
make PREFIX="%{_prefix}" DESTDIR=%{buildroot} LIBDIRNAME="/%{_lib}/faketime" install
|
||||
rm -r %{buildroot}/%{_docdir}/faketime
|
||||
|
||||
%files
|
||||
%{_bindir}/faketime
|
||||
%{_libdir}/faketime/libfaketime*so.*
|
||||
%doc README COPYING NEWS README README.developers
|
||||
%{_mandir}/man1/*
|
||||
|
||||
%changelog
|
||||
* Tue Oct 15 2013 Paul Wouters <pwouters@redhat.com> - 0.9.5-4
|
||||
- Infinite recursion patch is still needed, make test causes
|
||||
segfaults otherwise.
|
||||
|
||||
* Mon Oct 14 2013 Paul Wouters <pwouters@redhat.com> - 0.9.5-3
|
||||
- Work around from upstream for autodetecting glibc version bug on i686
|
||||
|
||||
* Mon Oct 14 2013 Paul Wouters <pwouters@redhat.com> - 0.9.5-2
|
||||
- Remove use of ifarch for _lib macro for multilib
|
||||
|
||||
* Sun Oct 13 2013 Paul Wouters <pwouters@redhat.com> - 0.9.5-1
|
||||
- Initial package
|
||||
@@ -1,53 +0,0 @@
|
||||
Package: libfaketime
|
||||
Version: 0.9.7
|
||||
Revision: 1
|
||||
|
||||
Source: http://www.code-wizards.com/projects/%n/%n-%v.tar.gz
|
||||
Source-MD5: PLACEHOLDER
|
||||
|
||||
Maintainer: Wolfgang Hommel <wolf@fink.code-wizards.com>
|
||||
HomePage: https://github.com/wolfcw/libfaketime
|
||||
License: GPL
|
||||
|
||||
Description: Modify system time for single applications
|
||||
|
||||
DescDetail: <<
|
||||
libfaketime is a library that is dynamically linked to applications
|
||||
or system commands at run-time by using the DYLD_INSERT_LIBRARIES
|
||||
mechanism. It then intercepts various system calls, which programs
|
||||
use to retrieve the current date and time. libfaketime can then
|
||||
report faked dates and times to these programs. This means you can
|
||||
modify the system time a program uses without having to change the
|
||||
date and time system-wide.
|
||||
<<
|
||||
|
||||
DescUsage: <<
|
||||
libfaketime includes a simple wrapper called faketime. Run the
|
||||
command faketime without any parameters for usage information.
|
||||
For information on how to use libfaketime without the wrapper
|
||||
and access its full raw functionality, please see
|
||||
%p/share/doc/libfaketime/README*
|
||||
<<
|
||||
|
||||
BuildDepends: fink (>= 0.28)
|
||||
Distribution: 10.7, 10.8, 10.9, 10.10, 10.11, 10.12
|
||||
|
||||
CompileScript: <<
|
||||
#! /bin/sh -ev
|
||||
make -f Makefile.OSX -C src PREFIX=%{p}
|
||||
<<
|
||||
|
||||
InfoTest: <<
|
||||
TestScript: make -f Makefile.OSX test || exit 2
|
||||
<<
|
||||
|
||||
InstallScript: <<
|
||||
#! /bin/sh -ev
|
||||
make -f Makefile.OSX -C src install PREFIX=%{i}
|
||||
<<
|
||||
|
||||
DocFiles: COPYING README README.OSX
|
||||
|
||||
Shlibs: <<
|
||||
!%p/lib/faketime/%N.1.dylib
|
||||
<<
|
||||
@@ -1,21 +0,0 @@
|
||||
require 'formula'
|
||||
|
||||
class Libfaketime < Formula
|
||||
homepage 'https://github.com/wolfcw/libfaketime'
|
||||
url 'https://github.com/wolfcw/libfaketime/archive/v0.9.7.tar.gz'
|
||||
sha1 'PLACEHOLDER'
|
||||
|
||||
depends_on :macos => :sierra
|
||||
|
||||
fails_with :llvm do
|
||||
build 2336
|
||||
cause 'No thread local storage support'
|
||||
end
|
||||
|
||||
def install
|
||||
system "make", "-C", "src", "-f", "Makefile.OSX", "PREFIX=#{prefix}"
|
||||
bin.install 'src/faketime'
|
||||
(lib/'faketime').install 'src/libfaketime.1.dylib'
|
||||
man1.install 'man/faketime.1'
|
||||
end
|
||||
end
|
||||
@@ -1,45 +0,0 @@
|
||||
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
|
||||
# $Id: Portfile 112093 2013-10-11 19:57:13Z ryandesign@macports.org $
|
||||
|
||||
PortSystem 1.0
|
||||
PortGroup github 1.0
|
||||
|
||||
github.setup wolfcw libfaketime 0.9.7 v
|
||||
|
||||
checksums rmd160 PLACEHOLDER \
|
||||
sha256 PLACEHOLDER
|
||||
|
||||
categories sysutils
|
||||
platforms darwin
|
||||
maintainers code-wizards.com:wolf openmaintainer
|
||||
license GPL-2
|
||||
|
||||
description libfaketime modifies the system time for a single application
|
||||
|
||||
long_description libfaketime intercepts various system calls that applications use to \
|
||||
retrieve the current date and time. It can then report user-specified \
|
||||
faked dates and times to these applications. This allows us to modify \
|
||||
the system time an application sees without having to change the time \
|
||||
system-wide. The faketime wrapper can be used from command line. \
|
||||
Check the documentation on how to integrate into installed applications.
|
||||
|
||||
patchfiles patch-test-Makefile.OSX.diff
|
||||
|
||||
use_configure no
|
||||
|
||||
variant universal {}
|
||||
|
||||
compiler.blacklist *cc* *dragonegg*
|
||||
|
||||
build.args -f Makefile.OSX
|
||||
build.env CC="${configure.cc}" \
|
||||
CFLAGS="[get_canonical_archflags cc]" \
|
||||
LDFLAGS="[get_canonical_archflags ld]" \
|
||||
PREFIX=${prefix}
|
||||
|
||||
test.run yes
|
||||
test.args ${build.args}
|
||||
eval test.env ${build.env}
|
||||
|
||||
destroot.args ${build.args}
|
||||
eval destroot.env ${build.env}
|
||||
@@ -1,12 +0,0 @@
|
||||
--- test/Makefile.OSX.orig 2013-10-11 09:42:38.000000000 -0500
|
||||
+++ test/Makefile.OSX 2013-10-11 14:46:11.000000000 -0500
|
||||
@@ -1,7 +1,6 @@
|
||||
-CC = gcc
|
||||
+CC ?= clang
|
||||
|
||||
-CFLAGS = -std=gnu99 -Wall -DFAKE_STAT
|
||||
-LDFLAGS =
|
||||
+CFLAGS += -std=gnu99 -Wall -DFAKE_STAT
|
||||
|
||||
SRC = timetest.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
@@ -1,65 +0,0 @@
|
||||
# Packaging for OS X
|
||||
|
||||
Several software tools assist with the installation of open source software
|
||||
on OS X. The authors of libfaketime maintain the libfaketime build spec files
|
||||
for MacPorts, Homebrew, and Fink.
|
||||
|
||||
|
||||
## MacPorts
|
||||
|
||||
Installing libfaketime via MacPorts is based on the provided Portfile, which
|
||||
has been included in the official MacPorts distribution since October, 2013.
|
||||
Users therefore can use "sudo port install libfaketime" as installation
|
||||
command.
|
||||
|
||||
Some libfaketime Portfile caveats:
|
||||
|
||||
- Github-based source file distribution
|
||||
- Non-clang-compilers need to be blacklisted
|
||||
- MacPorts folks have requested to avoid a platform-specific Makefile.OSX in
|
||||
the future
|
||||
|
||||
Portfile submission is documented in https://www.macports.org/guide/#project.contributing
|
||||
and handled via a ticketing system:
|
||||
|
||||
- https://trac.macports.org/ticket/40662
|
||||
- https://trac.macports.org/ticket/40748
|
||||
|
||||
|
||||
## Homebrew
|
||||
|
||||
The libfaketime 'formula' for Homebrew is available since November, 2013.
|
||||
Homebrew users can use 'brew install libfaketime' as installation command.
|
||||
|
||||
Some libfaketime formula caveats:
|
||||
|
||||
- "depends_on :macos => :lion" must be set for libfaketime >=0.9.5
|
||||
- :llvm builds <= 2336 must be blacklisted because libfaketime =0.9.5
|
||||
requires a compiler with thread local storage support.
|
||||
|
||||
Formula submission is handled via pull request on Github following the
|
||||
"one formula per commit, one commit per formula" rule, which necessitates
|
||||
squashing commits and forced pushes when applying fixes. Style issues
|
||||
complementary to the documentation have been discussed in
|
||||
|
||||
https://github.com/mxcl/homebrew/pull/23245
|
||||
|
||||
|
||||
## Fink
|
||||
|
||||
A libfaketime.info file is included in the Fink 10.7 tree since October,
|
||||
2013, and installed using
|
||||
|
||||
fink install libfaketime
|
||||
|
||||
Some libfaketime fink info file caveats:
|
||||
|
||||
- The dynamic library must be declared as private Shlib; this also necessitates
|
||||
BuildDepends: fink (>= 0.28)
|
||||
- "Distribution: 10.7, 10.8, 10.9" is required because libfaketime >=0.9.5 does
|
||||
not work on OS X 10.6 or before anymore.
|
||||
- When compiling, PREFIX=%{p} needs to be used because this path is hardcoded
|
||||
into the wrapper. However, "make install" needs to deploy into PREFIX=%{i} to
|
||||
make packaging work.
|
||||
|
||||
Submission is via https://sourceforge.net/p/fink/package-submissions/
|
||||
@@ -1,14 +0,0 @@
|
||||
# libfaketime packaging
|
||||
|
||||
Not everyone feels comfortable with installing tools and libraries manually
|
||||
by downloading and building them from source. Luckily enough, voluntary
|
||||
maintainers prepare new libfaketime releases for various platforms and make
|
||||
them available as binary packages or otherwise automatically installable
|
||||
software.
|
||||
|
||||
In this directory, we collect build specification files for the platforms
|
||||
that we are aware of being actively supported. They help us to analyze
|
||||
build issues, create awareness for platform-specific patches that had to
|
||||
be applied and might be merged with our code, and provide the contact
|
||||
information for future "early release warnings".
|
||||
|
||||
@@ -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
|
||||
# possibile 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}'"'
|
||||
LIB_LDFLAGS += -dynamiclib -current_version 0.9.7 -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
|
||||
@@ -9,12 +9,9 @@
|
||||
# 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
|
||||
# possibile caching side-effects in a multithreaded environment
|
||||
# possible caching side-effects in a multithreaded environment
|
||||
# without this, but the performance impact may require you to
|
||||
# try it unsynchronized.
|
||||
#
|
||||
@@ -24,17 +21,30 @@
|
||||
# that make use of low-level system calls, such as Java Virtual
|
||||
# Machines.
|
||||
#
|
||||
# FAKE_SLEEP
|
||||
# - Also intercept sleep(), nanosleep(), usleep(), alarm(), [p]poll()
|
||||
# FAKE_SLEEP
|
||||
# - Also intercept sleep(), nanosleep(), usleep(), alarm(), [p]poll()
|
||||
#
|
||||
# FAKE_TIMERS
|
||||
# - Also intercept timer_settime() and timer_gettime()
|
||||
# FAKE_TIMERS
|
||||
# - Also intercept timer_settime() and timer_gettime()
|
||||
#
|
||||
# MULTI_ARCH
|
||||
# - If MULTI_ARCH is set, the faketime wrapper program will put a literal
|
||||
# $LIB into the LD_PRELOAD environment variable it creates, which makes
|
||||
# ld automatically choose the correct library version to use for the
|
||||
# target binary. Use for Linux platforms with Multi-Arch support only!
|
||||
# FAKE_PTHREAD
|
||||
# - Intercept pthread_cond_timedwait
|
||||
#
|
||||
# FAKE_SETTIME
|
||||
# - Intercept clock_settime(), settimeofday(), and adjtime()
|
||||
#
|
||||
# FORCE_MONOTONIC_FIX
|
||||
# - If the test program hangs forever on
|
||||
# " pthread_cond_timedwait: CLOCK_MONOTONIC test
|
||||
# (Intentionally sleeping 1 second...) "
|
||||
# then add -DFORCE_MONOTONIC_FIX to CFLAGS and recompile.
|
||||
# (This is a platform-specific issue we cannot handle at run-time.)
|
||||
#
|
||||
# MULTI_ARCH
|
||||
# - If MULTI_ARCH is set, the faketime wrapper program will put a literal
|
||||
# $LIB into the LD_PRELOAD environment variable it creates, which makes
|
||||
# ld automatically choose the correct library version to use for the
|
||||
# target binary. Use for Linux platforms with Multi-Arch support only!
|
||||
#
|
||||
# * Compilation addition: second libMT target added for building the pthread-
|
||||
# enabled library as a separate library
|
||||
@@ -50,8 +60,8 @@
|
||||
# Change PREFIX to where you want libfaketime (libraries and wrapper binary) installed.
|
||||
# LIBDIRNAME is relative to PREFIX. The default is to install into $PREFIX/lib/faketime,
|
||||
# but you can set LIBDIRNAME to, e.g., /lib64 if you want to install it elsewhere.
|
||||
# LIBDIRNAME has been introduced to support MultiLib systems. Please do not change the
|
||||
# default value on MultiArch systems.
|
||||
# LIBDIRNAME has been introduced to support MultiLib systems. Please do not change the
|
||||
# default value on MultiArch systems.
|
||||
#
|
||||
# For testing in the current directory without installation, try make PREFIX= LIBDIRNAME='.'
|
||||
|
||||
@@ -62,14 +72,14 @@ PREFIX ?= /usr/local
|
||||
LIBDIRNAME ?= /lib/faketime
|
||||
PLATFORM ?=$(shell uname)
|
||||
|
||||
CFLAGS += -std=gnu99 -Wall -Wextra -Werror -Wno-nonnull-compare -DFAKE_STAT -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"'
|
||||
CFLAGS += -std=gnu99 -Wall -Wextra -Werror -Wno-nonnull-compare -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"' $(FAKETIME_COMPILE_CFLAGS)
|
||||
ifeq ($(PLATFORM),SunOS)
|
||||
CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
|
||||
endif
|
||||
|
||||
LIB_LDFLAGS += -shared
|
||||
|
||||
LDFLAGS += -lpthread
|
||||
LDFLAGS += $(FAKETIME_LINK_FLAGS) -lpthread
|
||||
ifneq ($(PLATFORM),SunOS)
|
||||
LDFLAGS += -Wl,--version-script=libfaketime.map
|
||||
endif
|
||||
@@ -86,16 +96,16 @@ LIBS = libfaketime.so.${SONAME} libfaketimeMT.so.${SONAME}
|
||||
|
||||
all: ${LIBS} ${BINS}
|
||||
|
||||
libfaketimeMT.o: EXTRA_FLAGS := -DPTHREAD -DPTHREAD_SINGLETHREADED_TIME
|
||||
libfaketimeMT.o: EXTRA_FLAGS := -DPTHREAD_SINGLETHREADED_TIME
|
||||
|
||||
${LIBS_OBJ}: libfaketime.c
|
||||
${CC} -o $@ -c ${CFLAGS} ${EXTRA_FLAGS} $<
|
||||
${CC} -o $@ -c ${CFLAGS} ${CPPFLAGS} ${EXTRA_FLAGS} $<
|
||||
|
||||
%.so.${SONAME}: %.o libfaketime.map
|
||||
${CC} -o $@ -Wl,-soname,$@ ${LDFLAGS} ${LIB_LDFLAGS} $< ${LDADD}
|
||||
|
||||
${BINS}: faketime.c
|
||||
${CC} -o $@ ${CFLAGS} ${EXTRA_FLAGS} $< ${LDFLAGS} ${BIN_LDFLAGS}
|
||||
${CC} -o $@ ${CFLAGS} ${CPPFLAGS} ${EXTRA_FLAGS} $< ${LDFLAGS} ${BIN_LDFLAGS}
|
||||
|
||||
clean:
|
||||
@rm -f ${LIBS_OBJ} ${LIBS} ${BINS}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* libfaketime wrapper command
|
||||
*
|
||||
* This file is part of libfaketime, version 0.9.7
|
||||
* This file is part of libfaketime, version 0.9.8
|
||||
*
|
||||
* libfaketime is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License v2 as published by the
|
||||
@@ -47,8 +47,9 @@
|
||||
#include <semaphore.h>
|
||||
|
||||
#include "faketime_common.h"
|
||||
#include "config.h"
|
||||
|
||||
const char version[] = "0.9.7";
|
||||
const char version[] = VERSION;
|
||||
|
||||
#ifdef __APPLE__
|
||||
static const char *date_cmd = "gdate";
|
||||
@@ -124,7 +125,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
else if (0 == strcmp(argv[curr_opt], "--exclude-monotonic"))
|
||||
{
|
||||
setenv("DONT_FAKE_MONOTONIC", "1", true);
|
||||
setenv("FAKETIME_DONT_FAKE_MONOTONIC", "1", true);
|
||||
curr_opt++;
|
||||
continue;
|
||||
}
|
||||
@@ -209,7 +210,7 @@ int main (int argc, char **argv)
|
||||
int shm_fd;
|
||||
sem_t *sem;
|
||||
struct ft_shared_s *ft_shared;
|
||||
char shared_objs[PATH_BUFSIZE];
|
||||
char shared_objs[PATH_BUFSIZE * 2 + 1];
|
||||
|
||||
/*
|
||||
* Casting of getpid() return value to long needed to make GCC on SmartOS
|
||||
@@ -224,6 +225,7 @@ int main (int argc, char **argv)
|
||||
if (SEM_FAILED == (sem = sem_open(sem_name, O_CREAT|O_EXCL, S_IWUSR|S_IRUSR, 1)))
|
||||
{
|
||||
perror("sem_open");
|
||||
fprintf(stderr, "The faketime wrapper only works on platforms that support the sem_open()\nsystem call. However, you may LD_PRELOAD libfaketime without using this wrapper.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -286,7 +288,7 @@ int main (int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
snprintf(shared_objs, PATH_BUFSIZE, "%s %s", sem_name, shm_name);
|
||||
snprintf(shared_objs, sizeof(shared_objs), "%s %s", sem_name, shm_name);
|
||||
setenv("FAKETIME_SHARED", shared_objs, true);
|
||||
sem_close(sem);
|
||||
}
|
||||
@@ -294,19 +296,21 @@ int main (int argc, char **argv)
|
||||
{
|
||||
char *ftpl_path;
|
||||
#ifdef __APPLE__
|
||||
ftpl_path = PREFIX "/libfaketime.1.dylib";
|
||||
FILE *check;
|
||||
check = fopen(ftpl_path, "ro");
|
||||
if (check == NULL)
|
||||
{
|
||||
ftpl_path = PREFIX "/lib/faketime/libfaketime.1.dylib";
|
||||
if (!getenv("DYLD_INSERT_LIBRARIES") && !getenv("DYLD_FORCE_FLAT_NAMESPACE")) {
|
||||
ftpl_path = LIBPREFIX "/libfaketime." LIBVERSION ".dylib";
|
||||
FILE *check;
|
||||
check = fopen(ftpl_path, "ro");
|
||||
if (check == NULL)
|
||||
{
|
||||
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
|
||||
{
|
||||
char *ld_preload_new, *ld_preload = getenv("LD_PRELOAD");
|
||||
@@ -317,17 +321,17 @@ int main (int argc, char **argv)
|
||||
* on MultiArch platforms, such as Debian, we put a literal $LIB into LD_PRELOAD.
|
||||
*/
|
||||
#ifndef MULTI_ARCH
|
||||
ftpl_path = PREFIX LIBDIRNAME "/libfaketimeMT.so.1";
|
||||
ftpl_path = LIBPREFIX "/libfaketimeMT.so." LIBVERSION;
|
||||
#else
|
||||
ftpl_path = PREFIX "/$LIB/faketime/libfaketimeMT.so.1";
|
||||
ftpl_path = PREFIX "/$LIB/faketime/libfaketimeMT.so." LIBVERSION;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef MULTI_ARCH
|
||||
ftpl_path = PREFIX LIBDIRNAME "/libfaketime.so.1";
|
||||
ftpl_path = LIBPREFIX "/libfaketime.so." LIBVERSION;
|
||||
#else
|
||||
ftpl_path = PREFIX "/$LIB/faketime/libfaketime.so.1";
|
||||
ftpl_path = PREFIX "/$LIB/faketime/libfaketime.so." LIBVERSION;
|
||||
#endif
|
||||
}
|
||||
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>
|
||||
#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
|
||||
|
||||
1251
src/libfaketime.c
1251
src/libfaketime.c
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,18 @@ GLIBC_2.2 {
|
||||
timer_gettime; timer_settime;
|
||||
local: timer_settime_*; timer_gettime_*;
|
||||
};
|
||||
|
||||
GLIBC_2.3.3 {
|
||||
# Changed timer_t.
|
||||
timer_gettime; timer_settime;
|
||||
} GLIBC_2.2;
|
||||
|
||||
GLIBC_2.2.5 {
|
||||
global: pthread_cond_timedwait;
|
||||
local: pthread_cond_timedwait_*; pthread_cond_init_*; pthread_cond_destroy*;
|
||||
};
|
||||
|
||||
GLIBC_2.3.2 {
|
||||
pthread_cond_timedwait; pthread_cond_init; pthread_cond_destroy;
|
||||
} GLIBC_2.2.5;
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@
|
||||
#define timermul2(tvp, c, result, prefix) \
|
||||
do \
|
||||
{ \
|
||||
long long tmp_time; \
|
||||
tmp_time = (c) * ((tvp)->tv_sec * SEC_TO_##prefix##SEC + \
|
||||
(tvp)->tv_##prefix##sec); \
|
||||
int64_t tmp_time; \
|
||||
tmp_time = (c) * (int64_t) ((tvp)->tv_sec * SEC_TO_##prefix##SEC + \
|
||||
(int64_t) (tvp)->tv_##prefix##sec); \
|
||||
(result)->tv_##prefix##sec = tmp_time % SEC_TO_##prefix##SEC; \
|
||||
(result)->tv_sec = (tmp_time - (result)->tv_##prefix##sec) / \
|
||||
SEC_TO_##prefix##SEC; \
|
||||
@@ -89,16 +89,28 @@
|
||||
#ifndef timersub
|
||||
#define timersub(a, b, result) timersub2(a, b, result, u)
|
||||
#endif
|
||||
#ifndef timersub
|
||||
#ifndef timermul
|
||||
#define timermul(a, c, result) timermul2(a, c, result, u)
|
||||
#endif
|
||||
|
||||
/* ops for nanosecs */
|
||||
#ifndef timespecisset
|
||||
#define timespecisset(tvp) timerisset2(tvp,n)
|
||||
#endif
|
||||
#ifndef timespecclear
|
||||
#define timespecclear(tvp) timerclear2(tvp, n)
|
||||
#endif
|
||||
#ifndef timespeccmp
|
||||
#define timespeccmp(a, b, CMP) timercmp2(a, b, CMP, n)
|
||||
#endif
|
||||
#ifndef timespecadd
|
||||
#define timespecadd(a, b, result) timeradd2(a, b, result, n)
|
||||
#endif
|
||||
#ifndef timespecsub
|
||||
#define timespecsub(a, b, result) timersub2(a, b, result, n)
|
||||
#endif
|
||||
#ifndef timespecmul
|
||||
#define timespecmul(a, c, result) timermul2(a, c, result, n)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
1208
src/uthash.h
Normal file
1208
src/uthash.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,31 +0,0 @@
|
||||
CC = gcc
|
||||
|
||||
CFLAGS = -std=gnu99 -Wall -DFAKE_STAT -Werror -Wextra
|
||||
LDFLAGS = -lrt
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -35,5 +35,5 @@
|
||||
# 3. create DIR/test_XXX.sh.
|
||||
# 4. write a run function and testcase functions in DIR/test_XXX.sh.
|
||||
# 5. within the run function, call run_testcase for each testcase function.
|
||||
# 6. within each testcase funtion, call assertneq or asserteq, or do
|
||||
# 6. within each testcase function, call assertneq or asserteq, or do
|
||||
# the equivalent.
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
platform()
|
||||
{
|
||||
@@ -19,7 +22,7 @@ platform()
|
||||
mac_fakecmd()
|
||||
{
|
||||
typeset timestring="$1"; shift
|
||||
typeset fakelib=../src/libfaketime.1.dylib
|
||||
typeset fakelib="$LIBFAKETIME_LA"
|
||||
export DYLD_INSERT_LIBRARIES=$fakelib
|
||||
export DYLD_FORCE_FLAT_NAMESPACE=1
|
||||
FAKETIME="$timestring" \
|
||||
@@ -29,7 +32,7 @@ mac_fakecmd()
|
||||
sunos_fakecmd()
|
||||
{
|
||||
typeset timestring="$1"; shift
|
||||
typeset fakelib=../src/libfaketime.so.1
|
||||
typeset fakelib="$LIBFAKETIME_LA"
|
||||
export LD_PRELOAD=$fakelib
|
||||
FAKETIME="$timestring" \
|
||||
"$@"
|
||||
@@ -39,7 +42,7 @@ sunos_fakecmd()
|
||||
linuxlike_fakecmd()
|
||||
{
|
||||
typeset timestring="$1"; shift
|
||||
typeset fakelib=../src/libfaketime.so.1
|
||||
typeset fakelib="$LIBFAKETIME_LA"
|
||||
export LD_PRELOAD=$fakelib
|
||||
FAKETIME="$timestring" \
|
||||
"$@"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Checks that setting DONT_FAKE_MONOTONIC actually prevent
|
||||
# Checks that setting FAKETIME_DONT_FAKE_MONOTONIC actually prevent
|
||||
# libfaketime from faking monotonic clocks.
|
||||
#
|
||||
# We do this by freezing time at a specific and arbitrary date with faketime,
|
||||
# and making sure that if we set DONT_FAKE_MONOTONIC to 1, calling
|
||||
# and making sure that if we set FAKETIME_DONT_FAKE_MONOTONIC to 1, calling
|
||||
# clock_gettime(CLOCK_MONOTONIC) returns two different values.
|
||||
#
|
||||
# We also make sure that if we don't set DONT_FAKE_MONOTONIC to 1, in other
|
||||
# words when we use the default behavior, two subsequent calls to
|
||||
# We also make sure that if we don't set FAKETIME_DONT_FAKE_MONOTONIC to 1,
|
||||
# in other words when we use the default behavior, two subsequent calls to
|
||||
# clock_gettime(CLOCK_MONOTONIC) do return different values.
|
||||
|
||||
init()
|
||||
@@ -26,7 +26,7 @@ run()
|
||||
init
|
||||
|
||||
run_testcase dont_fake_mono
|
||||
run_testcase fake_mono
|
||||
# run_testcase fake_mono
|
||||
}
|
||||
|
||||
get_token()
|
||||
@@ -64,7 +64,8 @@ get_monotonic_time()
|
||||
{
|
||||
dont_fake_mono=$1; shift;
|
||||
clock_id=$1; shift;
|
||||
DONT_FAKE_MONOTONIC=${dont_fake_mono} fakecmd "2014-07-21 09:00:00" \
|
||||
FAKETIME_DONT_FAKE_MONOTONIC=${dont_fake_mono} \
|
||||
fakecmd "2014-07-21 09:00:00" \
|
||||
/bin/bash -c "for i in 1 2; do \
|
||||
perl -w -MTime::HiRes=clock_gettime,${clock_id} -E \
|
||||
'say clock_gettime(${clock_id})'; \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# test suite that always succeds - for testing framework
|
||||
# test suite that always succeeds - for testing framework
|
||||
|
||||
run()
|
||||
{
|
||||
|
||||
@@ -37,7 +37,15 @@ fakedate()
|
||||
#
|
||||
typeset fmt='%s'
|
||||
export FAKETIME_FMT=$fmt
|
||||
fakecmd "$1" date +$fmt
|
||||
if [ "mac" == "$PLATFORM" ]; then
|
||||
if [ -x /usr/local/bin/gdate ] ; then
|
||||
fakecmd "$1" gdate +$fmt
|
||||
else
|
||||
echo "<skip>"
|
||||
fi
|
||||
else
|
||||
fakecmd "$1" date +$fmt
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
@@ -63,5 +71,14 @@ test_with_i()
|
||||
typeset i="$1"
|
||||
typeset t=$(pow 2 $i)
|
||||
|
||||
asserteq $(fakedate $t) $t "(secs since Epoch)"
|
||||
if [ "mac" == "$PLATFORM" ]; then
|
||||
if [ -x /usr/local/bin/gdate ] ; then
|
||||
asserteq $(fakedate $t) $t "(secs since Epoch)"
|
||||
else
|
||||
asserteq $t $t "(skipping test, install gdate)"
|
||||
fi
|
||||
|
||||
else
|
||||
asserteq $(fakedate $t) $t "(secs since Epoch)"
|
||||
fi
|
||||
}
|
||||
|
||||
72
test/test.sh
72
test/test.sh
@@ -1,14 +1,38 @@
|
||||
#!/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
|
||||
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 "\$ $(set_libfaketime) ./timetest"
|
||||
set_libfaketime
|
||||
./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 "\$ $(set_libfaketime) ./timetest"
|
||||
set_libfaketime
|
||||
./timetest
|
||||
echo
|
||||
fi
|
||||
|
||||
@@ -16,48 +40,62 @@ echo "==========================================================================
|
||||
echo
|
||||
|
||||
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 "\$ $(set_libfaketime) FAKETIME=\"2003-01-01 10:00:05\" ./timetest"
|
||||
set_libfaketime
|
||||
export FAKETIME="2003-01-01 10:00:05"
|
||||
./timetest
|
||||
echo
|
||||
|
||||
echo "============================================================================="
|
||||
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 "\$ $(set_libfaketime) FAKETIME=\"@2005-03-29 14:14:14\" ./timetest"
|
||||
set_libfaketime
|
||||
export FAKETIME="@2005-03-29 14:14:14"
|
||||
./timetest
|
||||
echo
|
||||
|
||||
echo "============================================================================="
|
||||
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 "$(set_libfaketime) FAKETIME=\"-10d\" ./timetest"
|
||||
set_libfaketime
|
||||
export FAKETIME="-10d"
|
||||
./timetest
|
||||
echo
|
||||
|
||||
echo "============================================================================="
|
||||
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 "\$ $(set_libfaketime) FAKETIME=\"-10d\" NO_FAKE_STAT=1 ./timetest"
|
||||
set_libfaketime
|
||||
export FAKETIME="-10d"
|
||||
export NO_FAKE_STAT=1
|
||||
./timetest
|
||||
echo
|
||||
|
||||
echo "============================================================================="
|
||||
echo
|
||||
|
||||
echo "Running the test program with 10 days postive offset specified, and sped up 2 times"
|
||||
echo "\$ LD_PRELOAD=../src/libfaketime.so.1 FAKETIME=\"+10d x2\" ./timetest"
|
||||
LD_PRELOAD=../src/libfaketime.so.1 FAKETIME="+10d x2" NO_FAKE_STAT=1 ./timetest
|
||||
echo "Running the test program with 10 days positive offset specified, and sped up 2 times"
|
||||
echo "\$ $(set_libfaketime) FAKETIME=\"+10d x2\" ./timetest"
|
||||
set_libfaketime
|
||||
export FAKETIME="+10d x2"
|
||||
export NO_FAKE_STAT=1
|
||||
./timetest
|
||||
echo
|
||||
|
||||
echo "============================================================================="
|
||||
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 "\$ $(set_libfaketime) FAKETIME=\"-15d\" date"
|
||||
set_libfaketime
|
||||
export FAKETIME="-15d"
|
||||
date
|
||||
echo
|
||||
|
||||
echo "============================================================================="
|
||||
|
||||
@@ -1,46 +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
|
||||
|
||||
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 postive offset specified, and sped up 2 times"
|
||||
echo "FAKETIME=\"+10d x2\" ./timetest"
|
||||
FAKETIME="+10d x2" NO_FAKE_STAT=1 ./timetest
|
||||
echo
|
||||
|
||||
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.
|
||||
#
|
||||
|
||||
testframedir="${BASH_SOURCE%/*}"
|
||||
|
||||
# echo labelled error/warning message to stderr
|
||||
report()
|
||||
{
|
||||
@@ -33,7 +35,7 @@ run_testsuite()
|
||||
# add testsuite dir to PATH for convenience
|
||||
typeset dir=$(dirname $testsuite)
|
||||
PATH=$dir:$PATH
|
||||
. testframe.inc
|
||||
. $testframedir/testframe.inc
|
||||
if [ -f $dir/common.inc ]; then
|
||||
. $dir/common.inc
|
||||
fi
|
||||
|
||||
@@ -18,19 +18,27 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/timeb.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#ifdef FAKE_STAT
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define VERBOSE 0
|
||||
@@ -49,7 +57,66 @@ handler(int sig, siginfo_t *si, void *uc)
|
||||
printf("Caught signal %d\n", sig);
|
||||
}
|
||||
}
|
||||
|
||||
void* pthread_test(void* args)
|
||||
{
|
||||
pthread_mutex_t fakeMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_cond_t fakeCond = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
pthread_cond_t monotonic_cond;
|
||||
pthread_condattr_t attr;
|
||||
|
||||
struct timespec timeToWait, now;
|
||||
int rt;
|
||||
|
||||
args = args; // silence compiler warning about unused argument
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
timeToWait.tv_sec = now.tv_sec+1;
|
||||
timeToWait.tv_nsec = now.tv_nsec;
|
||||
|
||||
printf("pthread_cond_timedwait: CLOCK_REALTIME test\n");
|
||||
printf("(Intentionally sleeping 1 second...)\n");
|
||||
fflush(stdout);
|
||||
|
||||
pthread_mutex_lock(&fakeMutex);
|
||||
rt = pthread_cond_timedwait(&fakeCond, &fakeMutex, &timeToWait);
|
||||
if (rt != ETIMEDOUT)
|
||||
{
|
||||
printf("pthread_cond_timedwait failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pthread_mutex_unlock(&fakeMutex);
|
||||
|
||||
|
||||
pthread_condattr_init(&attr);
|
||||
pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
|
||||
pthread_cond_init(&monotonic_cond, &attr);
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
timeToWait.tv_sec = now.tv_sec+1;
|
||||
timeToWait.tv_nsec = now.tv_nsec;
|
||||
|
||||
printf("pthread_cond_timedwait: CLOCK_MONOTONIC test\n");
|
||||
printf("(Intentionally sleeping 1 second..., see docs about CLOCK_MONOTONIC test)\n");
|
||||
fflush(stdout);
|
||||
|
||||
pthread_mutex_lock(&fakeMutex);
|
||||
rt = pthread_cond_timedwait(&monotonic_cond, &fakeMutex, &timeToWait);
|
||||
if (rt != ETIMEDOUT)
|
||||
{
|
||||
printf("pthread_cond_timedwait failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
pthread_mutex_unlock(&fakeMutex);
|
||||
|
||||
pthread_cond_destroy(&monotonic_cond);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "faketime_common.h"
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
@@ -64,11 +131,22 @@ int main (int argc, char **argv)
|
||||
sigset_t mask;
|
||||
struct sigaction sa;
|
||||
#endif
|
||||
#ifndef __APPLE__
|
||||
#ifdef FAKE_STAT
|
||||
struct stat buf;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* silence compiler warnings */
|
||||
printf("%s", 0 == 1 ? argv[0] : "");
|
||||
|
||||
#ifndef __APPLE__
|
||||
pthread_t thread;
|
||||
void *ret;
|
||||
|
||||
pthread_create(&thread, NULL, pthread_test, NULL);
|
||||
pthread_join(thread, &ret);
|
||||
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
sa.sa_sigaction = handler;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
@@ -193,9 +271,11 @@ int main (int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
#ifdef FAKE_STAT
|
||||
lstat(argv[0], &buf);
|
||||
printf("stat(): mod. time of file '%s': %s", argv[0], ctime(&buf.st_mtime));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user