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

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