mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 08:36:28 +03:00
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?
30 lines
957 B
Bash
Executable File
30 lines
957 B
Bash
Executable File
#!/bin/sh
|
|
|
|
FTPL="${FAKETIME_TESTLIB:-../src/libfaketime.so.1}"
|
|
|
|
set -e
|
|
|
|
error=0
|
|
run0=$(./syscall_test)
|
|
run1=$(LD_PRELOAD="$FTPL" ./syscall_test)
|
|
run2=$(FAKERANDOM_SEED=0x0000000000000000 LD_PRELOAD="$FTPL" ./syscall_test)
|
|
run3=$(FAKERANDOM_SEED=0x0000000000000000 LD_PRELOAD="$FTPL" ./syscall_test)
|
|
run4=$(FAKERANDOM_SEED=0xDEADBEEFDEADBEEF LD_PRELOAD="$FTPL" ./syscall_test)
|
|
|
|
if [ "$run0" = "$run1" ] ; then
|
|
error=1
|
|
printf >&2 'test run without LD_PRELOAD matches run with LD_PRELOAD. This is very unlikely.\n'
|
|
fi
|
|
if [ "$run1" = "$run2" ] ; then
|
|
error=2
|
|
printf >&2 'test with LD_PRELOAD but without FAKERANDOM_SEED matches run with LD_PRELOAD and FAKERANDOM_SEED. This is also very unlikely.\n'
|
|
fi
|
|
if [ "$run2" != "$run3" ]; then
|
|
error=1
|
|
printf >&2 'test run with same seed produces different outputs.\n'
|
|
fi
|
|
if [ "$run3" = "$run4" ]; then
|
|
error=1
|
|
printf >&2 'test runs with different seeds produce the same outputs.\n'
|
|
fi
|