diff options
| author | David Bremner <david@tethera.net> | 2019-06-26 12:23:36 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2019-06-29 21:10:44 +0200 |
| commit | 6544a2e3054ee96d8d4efccc51b4bc9e09e23d6c (patch) | |
| tree | d7afa6570cd321411f6e786b50a4def5a6b39308 | |
| parent | 11f7e52651d5f16bac0df00a8f51cb141df0675a (diff) | |
test: provide machinery to make and use test_shims
These can be used e.g. to override return values for functions, in
place of the existing scripting of gdb.
This prepends to LD_PRELOAD rather than clobbering it, thanks to a
suggestion from Tomi Ollila.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
| -rw-r--r-- | test/test-lib.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh index 616cb674..7f8a3a4d 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -95,6 +95,8 @@ TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient} TEST_GDB=${TEST_GDB:-gdb} TEST_CC=${TEST_CC:-cc} TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"} +TEST_SHIM_CFLAGS=${TEST_SHIM_CFLAGS:-"-fpic -shared"} +TEST_SHIM_LDFLAGS=${TEST_SHIM_LDFLAGS:-"-ldl"} # Protect ourselves from common misconfiguration to export # CDPATH into the environment @@ -1056,6 +1058,20 @@ test_C () { notmuch_dir_sanitize OUTPUT.stdout OUTPUT.stderr > OUTPUT } +make_shim () { + base_name="$1" + test_file="${base_name}.c" + shim_file="${base_name}.so" + cat > ${test_file} + ${TEST_CC} ${TEST_CFLAGS} ${TEST_SHIM_CFLAGS} -I${NOTMUCH_SRCDIR}/test -I${NOTMUCH_SRCDIR}/lib -o ${shim_file} ${test_file} ${TEST_SHIM_LDFLAGS} +} + +notmuch_with_shim () { + base_name="$1" + shift + shim_file="${base_name}.so" + LD_PRELOAD=./${shim_file}${LD_PRELOAD:+:$LD_PRELOAD} notmuch-shared "$@" +} # Creates a script that counts how much time it is executed and calls # notmuch. $notmuch_counter_command is set to the path to the |
