Commit Graph

514 Commits

Author SHA1 Message Date
Wolfgang Hommel
f4ae29fb91 Merge pull request #348 from GranBurguesa/patch-1
fix do/while guard for DONT_FAKE_TIME macro
2021-09-17 19:34:53 +02:00
GranBurguesa
a9142e0e9a fix do/while guard for DONT_FAKE_TIME macro
the newer version gcc warns `this ‘while’ clause does not guard... [-Werror=misleading-indentation]`. looks like the author just omitted the `do` and the `while(0) counts as a separate statement.

in practice this isn't causing any actual problem now afaict.
2021-09-17 10:41:55 -04:00
Wolfgang Hommel
b7fff74716 Merge pull request #344 from sliquister/fake-stateless
Add a build variable to opt-out of behaviors that reduce reliability
2021-08-01 20:44:14 +02:00
Valentin Gatien-Baron
e26859e5ca add a build variable to opt-out of some behaviors
Specifically behaviors that increase the chance that a wrapped program
will not behave like an unwrapped program does, thus causing
reliability issues.
2021-08-01 08:41:17 -04:00
Valentin Gatien-Baron
3155e0ee38 try to clarify the help of a couple of compilatoin variables 2021-08-01 08:02:59 -04:00
Valentin Gatien-Baron
078a4e4060 group cpp variables according to whether they are set by default 2021-08-01 07:58:06 -04:00
Wolfgang Hommel
9043941fa9 Merge pull request #342 from sliquister/timespec_get
wrap timespec_get
2021-07-30 22:54:00 +02:00
Valentin Gatien-Baron
973111d78a wrap timespec_get 2021-07-30 13:46:24 -04:00
Wolfgang Hommel
4bab3179ce Unlock mutex before exiting in case of error (fixes #340) 2021-07-17 19:44:20 +02:00
Wolfgang Hommel
2090f5e548 Fix in __xstat regarding dont_fake handling 2021-06-22 21:51:28 +02:00
Wolfgang Hommel
f88c8d4221 Do not cache '%' in parse_ft_string (addresses #337) 2021-06-22 21:47:57 +02:00
Wolfgang Hommel
9a73db074b Merge pull request #328 from jelly/gzip_reproducible
Do not store the timestamp in the gzip
2021-05-11 18:42:09 +02:00
Jelle van der Waa
932c138112 Do not store the timestamp in the gzip
To make libfaketime reproducible don't embed the timestamp in the gzip
header.

Motivation: https://reproducible-builds.org
2021-05-11 17:03:01 +02:00
Wolfgang Hommel
9e27b2ed8b Merge pull request #320 from sliquister/master
add support for timerfd_{set,get}time
2021-03-31 20:05:02 +02:00
Valentin Gatien-Baron
c9f292ee39 add support for timerfd_{set,get}time 2021-03-30 13:02:24 -04:00
Wolfgang Hommel
d37421dbe7 Merge pull request #319 from jimklimov/install-doc
Makefile: define PREFIX same as in sub-Makefiles to install "doc" to …
2021-03-28 21:09:34 +02:00
Jim Klimov
89161a0cdf Makefile: define PREFIX same as in sub-Makefiles to install "doc" to reasonable path 2021-03-28 21:01:38 +03:00
Wolfgang Hommel
f87c2f8915 Merge pull request #318 from jimklimov/date-prog-sun
faketime.c: default to GNU date as "gdate" on Sun-related OSes
2021-03-28 19:35:41 +02:00
Wolfgang Hommel
ce1d39c98f Merge pull request #317 from jimklimov/date-prog-arg
faketime.c: allow user to select their implementation of GNU date
2021-03-28 19:35:10 +02:00
Wolfgang Hommel
262d1d574f Merge pull request #316 from jimklimov/eol
src/sunos_endian.h: No newline at end of file
2021-03-28 19:32:01 +02:00
Jim Klimov
06d49adc12 faketime.c: default to GNU date as "gdate" on Sun-related OSes 2021-03-28 20:17:07 +03:00
Jim Klimov
1686664c97 faketime.c: allow user to select their implementation of GNU date 2021-03-28 20:14:27 +03:00
Jim Klimov
5217bcd13d src/sunos_endian.h: No newline at end of file
For pedantic compilers this is actually a fatal error, since per
(older?) C standards the file should end with an EOL.
2021-03-28 18:54:26 +03:00
Wolfgang Hommel
8ae4c9bc0e Merge pull request #313 from dkg/test-variadic-promotion
Test variadic promotion
2021-03-06 09:46:07 +01:00
Daniel Kahn Gillmor
6733dc3a8d tests: Confirm variadic argument promotion assumptions when INTERCEPT_SYSCALL
The test suite should not succeed if INTERCEPT_SYSCALL is defined but
the variadic argument promotion test fails.

OTOH, if we're not asking for INTERCEPT_SYSCALL, we don't care about
the results of that test.
2021-03-05 22:48:47 -05:00
Daniel Kahn Gillmor
008d33fdf2 Test assumptions about variadic re-packing
This test uses the same style of re-packing variadic arguments through
two layers of variadic calls, and compares that call chain against one
direct variadic call.

The outer function uses the same kind of re-packing used in
src/libfaketime.c's syscall (leading to real_syscall), but the inner
functions use different assumptions about the types of each argument.

This is not an entirely comprehensive test, because we only define two
different inner function signatures.  If some particular syscall is
breaking when intercepted, consider adding something like its expected
function signature in test/variadic/inner.c, and invoke it in
test/variadic/main.c.

Note that we don't test any floating point types (those types are
typically passed in registers in x86-64, not on the stack, and are
also not used for any syscall that i'm aware of).
2021-03-05 22:48:47 -05:00
Daniel Kahn Gillmor
5a0071f952 Centralize assumptions about variadic argument re-packing
By stating these assumptions in src/faketime_common.h, we can reuse
them in the tests as well as in the code.
2021-03-05 21:46:18 -05:00
Daniel Kahn Gillmor
51f1248593 tests: use CFLAGS from the environment.
This makes the test build process use the same sort of CFLAGS as the rest of the code.
2021-03-05 21:45:23 -05:00
Daniel Kahn Gillmor
e70b143733 Prepare to add new tests depending on the definitions
We want to be able to conditionally add tests.  This sets up to be
able to do that cleanly.
2021-03-05 21:45:23 -05:00
Wolfgang Hommel
e1073c8733 Promote syscall passthrough arguments to long instead of int (#310) 2021-03-04 19:24:24 +01:00
Wolfgang Hommel
01b0b4bb56 Merge pull request #312 from dkg/avoid-diversion
Pass through syscall(__NR_clock_gettime) if FAKERANDOM is unset
2021-03-03 06:36:26 +01:00
Daniel Kahn Gillmor
5f5756ccd9 Pass through syscall(__NR_clock_gettime) if FAKERANDOM is unset
If FAKERANDOM is unset, we were still intercepting syscall() and
passing it through to clock_gettime, rather than letting it fall
through to real_syscall.

That would have the effect of diverting syscall(__NR_clock_gettime,…)
into the libc invocation of clock_gettime(…) (via real_clock_gettime).
While that probably does the same thing, it's probably a mistake to do
such a diversion when FAKETIME is unset.
2021-03-02 20:01:18 -05:00
Wolfgang Hommel
bca9f1bf90 Merge pull request #311 from dkg/more-testing
More snippet testing and better documentation
2021-03-02 21:44:56 +01:00
Daniel Kahn Gillmor
d3f3ee38c6 Add syscall_clock_gettime_heap snippet
This invokes clock_gettime, but uses a timespec from the heap instead
of the stack.

It appears to be successful for me on x86-64 GNU/Linux.

This rules out one possible cause of the error reported in #310: I was
worried that an address from the range occupied by the heap might
somehow be corrupted by the syscall variadic argument de-mangling, but
that looks like it is not the case.
2021-03-02 10:33:07 -05:00
Daniel Kahn Gillmor
a3f9410e51 Add clock_gettime_heap snippet
This invokes clock_gettime, but uses a timespec from the heap instead
of the stack.
2021-03-02 10:26:20 -05:00
Daniel Kahn Gillmor
a92d6ffe7c add snippet testing clock_gettime(CLOCK_REALTIME) 2021-03-02 10:23:11 -05:00
Daniel Kahn Gillmor
253774c8d8 added new simple snippet "time.c" 2021-03-01 21:47:18 -05:00
Daniel Kahn Gillmor
986e6e1cdc Clarify test/Makefile and snippet testing documentation
Hopefully this makes it easier for future development work to augment
the snippet-based testing.
2021-03-01 21:40:57 -05:00
Daniel Kahn Gillmor
0bfb72b627 tests: normalize "where" variable to include framework prefix and snippet name 2021-03-01 21:08:00 -05:00
Daniel Kahn Gillmor
5a1bd98979 parallelize library_contructors test 2021-03-01 21:05:22 -05:00
Daniel Kahn Gillmor
7e62881c8f Name "snippets" explicitly
Earlier, this code was conceived of to test a "function" specifically,
but some future snippet could test multiple function calls, or a
subset of a function call (e.g. snippets/syscall_clock_gettime.c
already only tests one particular syscall diversion number).

Normalizing on the name "snippet" should make it easier to understand
the code going forward.
2021-03-01 15:06:22 -05:00
Wolfgang Hommel
0e6b1b2460 Merge pull request #309 from dkg/faketime-pid
faketime: add -p option to wrapper for setting PID
2021-02-26 20:46:27 +01:00
Wolfgang Hommel
1297568caf Merge pull request #306 from dkg/cleanup-tests
Overhaul recently-added tests (new additional snippet-driven testing framework)
2021-02-26 20:28:38 +01:00
Daniel Kahn Gillmor
940502b3de Added snippet for syscall(__NR_clock_gettime)
Closes: #176
2021-02-25 23:33:30 -05:00
Daniel Kahn Gillmor
26b4b395e9 Include a check for getentropy interception
This snippet applies to both the library constructors and variable
data test frameworks.
2021-02-25 23:17:25 -05:00
Daniel Kahn Gillmor
0b0cc29d2e test/randomtest.sh: avoid touching the filesystem 2021-02-25 23:17:25 -05:00
Daniel Kahn Gillmor
a5885f1479 Drop more duplicative tests
Now that we have the snippet-driven test_variable_data suite, most of
the other longer hand-written tests are duplicative.
2021-02-25 23:17:25 -05:00
Daniel Kahn Gillmor
0872c6c0c0 Add test_variable_data framework that reuses the snippets
Most of these snippets are likely to have some env var that causes the
data to hold constant, while the data will otherwise be likely to vary
over time.

This framework offers a way to test those snippets, by dropping the
variable and an example value in the test/snippets/FOO.variable
one-line file.

Note that the test/snippets/syscall.c snippet is *not* expected to
vary over time (or to differ when any given variable is set), so we
simply don't add any test/snippets/syscall.variable file to avoid it
being tested in this way.
2021-02-25 23:17:25 -05:00
Daniel Kahn Gillmor
a51a38d0ae Handle when another library uses a syscall in a constructor
Without this fix, the test_library_constructors test was failing on
use_lib_syscall.
2021-02-25 23:17:25 -05:00
Daniel Kahn Gillmor
f47223ff12 Include snippet for syscall() interception in library constructors 2021-02-25 23:17:25 -05:00