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

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