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