From bdfb10a776dbecd3028f4a2c523018f86bbcc8d1 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Tue, 3 Mar 2015 02:06:27 +0100 Subject: [PATCH] Fix a test case so that it doesn't fail if ltrace config files are installed --- testsuite/ltrace.main/system_call_params.exp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/testsuite/ltrace.main/system_call_params.exp b/testsuite/ltrace.main/system_call_params.exp index f3a55d2..4eade10 100644 --- a/testsuite/ltrace.main/system_call_params.exp +++ b/testsuite/ltrace.main/system_call_params.exp @@ -1,5 +1,5 @@ # This file is part of ltrace. -# Copyright (C) 2013, 2014 Petr Machata, Red Hat Inc. +# Copyright (C) 2013, 2014, 2015 Petr Machata, Red Hat Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -60,8 +60,33 @@ set conf [ltraceNamedSource "$dir/syscalls.conf" { # somelib.conf is passed, and syscalls.conf is not available, or # doesn't list readdir, that would be taken from somelib.conf with a # wrong prototype. +# +# This test relies on the fact that there is no global config file +# that would provide legitimate system call prototype. But that +# doesn't have to be true, maybe ltrace is already installed on the +# system with the right prefix. So first compile a wrapper that we +# use to redirect fopen calls. + +set libfopen_so [ltraceCompile libfopen.so -ldl [ltraceSource c { + #define _GNU_SOURCE + #include + #include + #include + + FILE * + fopen(const char *path, const char *mode) + { + if (strncmp(path, "/usr/share", 10) == 0) + path = "/dev/null"; + + return ((FILE *(*)(const char *, const char *)) + dlsym(RTLD_NEXT, "fopen")) (path, mode); + } +}]] +setenv LD_PRELOAD $libfopen_so ltraceMatch1 [ltraceRun -L -S -F $conf -- $bin] {^open@SYS\("/some/path"} == 0 +unsetenv LD_PRELOAD # On the other hand, if -F somedir/ is given, we want to accept # syscalls.conf found there. -- 2.1.0