111 Commits

Author SHA1 Message Date
Daniel Kahn Gillmor
20e74b1b02 clean up randomtest.sh, make more flexible 2021-02-24 15:58:54 -05:00
Daniel Kahn Gillmor
00d6edf90c Test repeated invocations of getrandom()
A single program that invokes getrandom() repeatedly should end up
with the same stream of bytes, regardless of how it chunks up the
reading from the entropy source.

This test already passses.  I'm including it because it seems
like a useful confirmation.
2021-02-24 15:24:45 -05:00
Daniel Kahn Gillmor
811283e683 Intercept syscall
This is an attempt at an implementation to address #301.

Some things worth noting:

 - I am not particularly confident in my reverse of the variadic C
   ABI. While the code appears to work for me on x86_64, I could
   imagine some variations between platforms that I'm not
   understanding.

 - This works to intercept the invocation of syscall as seen in
   test/syscalltest.sh, as long as it was compiled with -DFAKE_RANDOM

 - defining -DINTERCEPT_SYSCALL on non-Linux platforms should result
   in a compile-time error.

 - This does *not* work to intercept the syscall sent by `openssl
   rand`, for some reason I don't yet understand.  Perhaps openssl has
   some platform-specific syscall mechanism that doesn't route them
   through libc's syscall() shim?
2021-02-24 14:45:38 -05:00
Daniel Kahn Gillmor
2ca0b719e3 test getpid() against library with constructor that calls it
This is an attempt to ensure that an external library invocation of
getpid doesn't trigger a crash (e.g. #295) or an infinite loop
(e.g. #297).
2021-02-24 11:15:31 -05:00
Daniel Kahn Gillmor
f6ddc32695 Genericize build rules for testing external libraries with constructor
This paves the way for testing other interceptions like getpid() with
shared objects that do devious things in their consturctors.
2021-02-24 11:15:01 -05:00
Daniel Kahn Gillmor
8de66f799f randomtest.sh requires librandom.so to be present
In some configurations, GNU make might treat librandom.so as an
ephemeral/intermediate build artifact and destroy it before
randomtest.sh is run.  This ensures the shared object is present when
needed.
2021-02-24 11:14:37 -05:00
Daniel Kahn Gillmor
004222585e Enable intercepting getpid()
I went with the runtime environment variable being FAKETIME_FAKEPID
since it seems less likely to collide with anything else.

Closes: #297
2021-02-23 22:19:08 -05:00
Daniel Kahn Gillmor
8f2c856d8e test getrandom() in library initialization without FAKERANDOM_SEED
Running "make randomtest" should demonstrates the segfault described
in https://github.com/wolfcw/libfaketime/issues/295
2021-02-23 11:14:37 -05:00
Daniel Kahn Gillmor
54994ceb0d Improve tests for FAKE_RANDOM
Previously, we had failed to test code with getrandom() against
LD_PRELOAD when FAKERANDOM_SEED was unset.

We also want to try calling getrandom twice in a single process to
make sure that works OK.
2021-02-22 22:49:05 -05:00
Wolfgang Hommel
772d9523a7 Do not fail due to timer overrun counter mismatch on GNU/Hurd for now (#287) 2021-02-12 16:59:42 +01:00
Wolfgang Hommel
3ba66842aa Make randomtest.sh use FAKETIME_TESTLIB like the rest of the test cases 2021-02-04 21:40:55 +01:00
Wolfgang Hommel
4359458c7c Merge pull request #289 from dkg/getrandom_test-cleanup
Ease build of getrandom_test
2021-02-04 21:39:02 +01:00
Wolfgang Hommel
8853afb509 Added optional FAKETIME_TESTLIB environment variable for make test (#288) 2021-02-04 21:30:01 +01:00
Daniel Kahn Gillmor
206ae9ea80 Ease build of getrandom_test
In trying to test the experimental getrandom features, I found a few
minor problems.  These changes should make it easier to test.

After building, the developer can now just do:

    make -C test randomtest

This will do a basic verfication that the feature works as expected.

I haven't tried to integrate this with the overall "make test".  To do
that right, it should condition the test on the definition of
FAKE_RANDOM.
2021-02-03 13:12:32 -05:00
Wolfgang Hommel
ca2f3fefa1 Preliminary support to intercept getrandom() #275 2020-11-15 21:57:10 +01:00
Robin Linden
f19d68ea32 Fix make test build failure on gcc 9.3
On Ubuntu 20.04 using gcc 9.3, make test fails due to a deprecated
function (ftime) warning in combination with -Werror in timetest.c.
Since the warning is from a test testing that the deprecated function
can be replaced using LD_PRELOAD, I think it's reasonable to just
silence the warning in that case.
2020-05-28 23:26:25 +02:00
Wolfgang Hommel
3123ad7fe2 Revert "Automake branch" 2019-11-30 09:36:46 +01:00
Michael D. Stemle, Jr
f92d919fb0 Merged master in and cleaned up.
We no longer need the OSX-specific test. Tests are passing, too.
2019-11-27 14:32:15 -05:00
Wolfgang Hommel
a238cfa2b6 Added FAKETIME_COMPILE_CFLAGS to Makefiles 2019-08-23 11:38:35 +02:00
Wolfgang Hommel
ba32d1b01c Added FORCE_MONOTONIC_FIX CFLAG to avoid hangs on timedwait (#202 #142) 2019-08-23 10:29:53 +02:00
Wolfgang Hommel
5ddb237842 Adjusted tests on macOS based on compilation defaults 2019-08-21 18:42:05 +02:00
Wolfgang Hommel
d923612c2b Improved cross-platform compatibility defaults 2019-08-19 19:16:07 +02:00
Mathis Beer
5c4fdb5173 Rename DONT_FAKE_MONOTONIC to FAKETIME_DONT_FAKE_MONOTONIC for consistency.
The old variable still works.
2019-02-05 07:45:31 +01:00
Michael D. Stemle, Jr
39a85e380c Fixed a _bunch_ of autotools bugs. 2018-10-07 22:38:55 -04:00
Michael D. Stemle, Jr
825043515f Applying fixes for GNU/Linux, and the MT variant of the library. 2018-10-03 22:17:28 -04:00
Michael D. Stemle, Jr
24fd806e6b Added GNU autotools support. 2018-10-02 22:02:30 -04:00
Michael D. Stemle, Jr
39c6872f6d Removing old makefiles. 2018-10-01 20:08:27 -04:00
Daniel Kahn Gillmor
b3a2667e9f fix spelling :) 2018-01-16 14:21:36 -05:00
Matthias Liertzer
fb91c4fcde Implement a fix for pthread_cond_timedwait with faketime
pthread_cond_timedwait takes an absolute time as an argument, which
the function directly passes on to the kernel via the futex
syscall. In an application this absolute time argument is calculated
via the fake times provided by libfaketime. Since the kernel has no
knowledge of the fake time, pthread_cond_timedwait must be redefined
such that it converts the fake time back to real time before passing
it on.
2018-01-02 02:22:59 +01:00
Matthias Liertzer
d117ad79a2 Fix spelling of positive 2018-01-02 01:42:41 +01:00
Adam Borowski
cc4c1c3a29 Fix build failure on x32 (printf warnings).
On x32, time_t is 64-bit to avoid Y2038 problems.  This doesn't play well
using printf("%ld"), and -Werror turns this into a build failure.
2015-03-09 08:39:06 +01:00
Julien Gilli
95b70c7acc Make libfaketime build, run and pass tests on SmartOS.
Since SmartOS is close to SunOS, it's possible that these changes make
libfaketime build and run on other SunOS-like platforms.

These changes were tested on MacOS X and Ubuntu 12.04, and no regression
appeared during testing.
2014-08-06 11:29:02 -07:00
Julien Gilli
d19da98bb4 Add --exclude-monotonic command line option.
--exclude-monotonic prevents faketime from overriding
the clock with id CLOCK_MONOTONIC when using clock_gettime.

Add DONT_FAKE_MONOTONIC env variable to libfaketime that
has the same effect.

Add functional test for DONT_FAKE_MONOTONIC support.
2014-07-25 15:43:38 -07:00
Wolfgang Hommel
106818614d Minor source code style fixes 2013-11-07 19:35:18 +01:00
Balint Reczey
1f938d9642 Use SIGUSR1 instead of SIGRTMIN in tests
This will probably fix compilation on Debian GNU/Hurd
2013-10-20 17:28:29 +02:00
Balint Reczey
23200c4321 Fix tests on libc 2.17 2013-10-20 16:43:10 +02:00
Wolfgang Hommel
a8f8378e77 MacPorts changeset 112093 by ryandesign 2013-10-13 12:24:52 +02:00
Wolfgang Hommel
a0987efa5c renamed library name from libfaketime.dylib.1 to libfaketime.1.dylib based on Apple design guidelines. Thanks to ryandesign at MacPorts 2013-10-11 16:33:37 +02:00
Wolfgang Hommel
cee051c2bc avoid unused variables warnings 2013-10-06 13:12:39 +02:00
Balint Reczey
7d13d305c9 Add -Wextra and -Werror CFLAGS and also fix compile errors 2013-10-04 22:54:07 +02:00
Wolfgang Hommel
bb87fb619e improved readability of test script output 2013-10-02 15:32:46 +02:00
Wolfgang Hommel
b9ba8ab444 uniform test output style 2013-10-01 13:15:34 +02:00
Wolfgang Hommel
8c1ba7899d improved output readability for timer tests 2013-10-01 13:12:34 +02:00
Balint Reczey
50c6ad4dc2 Provide timer related functions compatible with GLIBC 2.2 and >= 2.3.3 [pr32 @8615959] 2013-09-30 16:36:13 +02:00
Wolfgang Hommel
ae6af2eea9 fixed missing blank line before last timetest call 2013-09-05 11:16:57 +02:00
Balint Reczey
545685e5a8 Use nanosleep() in faked sleep() and usleep() to avoid rounding issues [rbalint/pr28] 2013-09-05 10:26:57 +02:00
Wolfgang Hommel
227ebff470 testing Makefile adapted for OSX 2013-09-02 14:38:43 +02:00
Wolfgang Hommel
568fef7228 Makefiles and test suite improved for OS X 2013-09-02 14:32:44 +02:00
Wolfgang Hommel
aef788c795 Revert "merged rbalint's pr27"
This reverts commit 5283614bec, reversing
changes made to 4ecef4db08.
2013-09-01 16:04:21 +02:00
Wolfgang Hommel
8b67256736 Revert 30dd22e..bdac73e
This rolls back to commit 30dd22e157.
2013-08-29 10:08:32 +02:00