[ltrace-commits] 01/01: Fix a test case so that it doesn't fail if ltrace config files are installed

Petr Machata pmachata-guest at moszumanska.debian.org
Tue Mar 3 01:06:45 UTC 2015


This is an automated email from the git hooks/post-receive script.

pmachata-guest pushed a commit to branch master
in repository ltrace.

commit bdfb10a776dbecd3028f4a2c523018f86bbcc8d1
Author: Petr Machata <pmachata at redhat.com>
Date:   Tue Mar 3 02:06:27 2015 +0100

    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 <dlfcn.h>
+    #include <stdio.h>
+    #include <string.h>
+
+    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 at SYS\("/some/path"} == 0
+unsetenv LD_PRELOAD
 
 # On the other hand, if -F somedir/ is given, we want to accept
 # syscalls.conf found there.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/ltrace.git



More information about the ltrace-commits mailing list