Blame SOURCES/ltrace-0.7.91-testsuite-system_call_params.patch

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