Files
libfaketime/test/pidtest.sh
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

20 lines
455 B
Bash
Executable File

#!/bin/sh
FTPL="${FAKETIME_TESTLIB:-../src/libfaketime.so.1}"
set -e
run1=$(LD_PRELOAD="$FTPL" sh -c 'echo $$')
run2=$(LD_PRELOAD="$FTPL" sh -c 'echo $$')
if [ $run1 = $run2 ]; then
printf >&2 'got the same pid twice in a row without setting FAKETIME_FAKEPID\n'
exit 1
fi
output=$(FAKETIME_FAKEPID=13 LD_PRELOAD="$FTPL" sh -c 'echo $$')
if [ $output != 13 ]; then
printf >&2 'Failed to enforce a rigid response to getpid()\n'
exit 2
fi