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

d5c145
diff -rup a/testsuite/Makefile.am b/testsuite/Makefile.am
d5c145
--- a/testsuite/Makefile.am	2012-12-16 20:53:45.000000000 -0500
d5c145
+++ b/testsuite/Makefile.am	2019-06-28 16:59:19.935602953 -0400
d5c145
@@ -39,6 +39,7 @@ env.exp: Makefile
d5c145
 	rm -f env.exp
d5c145
 	echo set libelf_LD_LIBRARY_PATH '"$(libelf_LD_LIBRARY_PATH)"' >> $@
d5c145
 	echo set libunwind_LD_LIBRARY_PATH '"$(libunwind_LD_LIBRARY_PATH)"' >> $@
d5c145
+	echo set PREFIX '"$(prefix)"' >> $@
d5c145
 
d5c145
 CLEANFILES = *.o *.so *.log *.sum *.ltrace site.bak setval.tmp site.exp env.exp
d5c145
 
d5c145
diff -rup a/testsuite/Makefile.in b/testsuite/Makefile.in
d5c145
--- a/testsuite/Makefile.in	2013-11-04 20:22:47.000000000 -0500
d5c145
+++ b/testsuite/Makefile.in	2019-06-28 16:59:12.075602806 -0400
d5c145
@@ -648,6 +648,7 @@ env.exp: Makefile
d5c145
 	rm -f env.exp
d5c145
 	echo set libelf_LD_LIBRARY_PATH '"$(libelf_LD_LIBRARY_PATH)"' >> $@
d5c145
 	echo set libunwind_LD_LIBRARY_PATH '"$(libunwind_LD_LIBRARY_PATH)"' >> $@
d5c145
+	echo set PREFIX '"$(prefix)"' >> $@
d5c145
 
d5c145
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
d5c145
 # Otherwise a system limit (for SysV at least) may be exceeded.
d5c145
diff -rup a/testsuite/ltrace.main/system_call_params.exp b/testsuite/ltrace.main/system_call_params.exp
d5c145
--- a/testsuite/ltrace.main/system_call_params.exp	2019-06-28 16:44:07.542584754 -0400
d5c145
+++ b/testsuite/ltrace.main/system_call_params.exp	2019-06-28 17:00:35.811604355 -0400
d5c145
@@ -1,5 +1,5 @@
d5c145
 # This file is part of ltrace.
d5c145
-# Copyright (C) 2013, 2014 Petr Machata, Red Hat Inc.
d5c145
+# Copyright (C) 2013, 2014, 2015 Petr Machata, Red Hat Inc.
d5c145
 #
d5c145
 # This program is free software; you can redistribute it and/or
d5c145
 # modify it under the terms of the GNU General Public License as
d5c145
@@ -60,8 +60,35 @@ set conf [ltraceNamedSource "$dir/syscal
d5c145
 # somelib.conf is passed, and syscalls.conf is not available, or
d5c145
 # doesn't list readdir, that would be taken from somelib.conf with a
d5c145
 # wrong prototype.
d5c145
+#
d5c145
+# This test relies on the fact that there is no global config file
d5c145
+# that would provide legitimate system call prototypes.  But that
d5c145
+# doesn't have to be true, maybe ltrace is already installed on the
d5c145
+# system with the right prefix.  So first compile a wrapper that we
d5c145
+# use to redirect fopen calls.
d5c145
+
d5c145
+set libfopen_so [ltraceCompile libfopen.so -ldl \
d5c145
+		     [ltraceSource c [string map [list "@PREFIX@" "$PREFIX"] {
d5c145
+    #define _GNU_SOURCE
d5c145
+    #include <dlfcn.h>
d5c145
+    #include <stdio.h>
d5c145
+    #include <string.h>
d5c145
+
d5c145
+    FILE *
d5c145
+    fopen(const char *path, const char *mode)
d5c145
+    {
d5c145
+	#define PATH "@PREFIX@/share"
d5c145
+	if (strncmp(path, PATH, sizeof(PATH) - 1) == 0)
d5c145
+	    path = "/dev/null";
d5c145
 
d5c145
+	return ((FILE *(*)(const char *, const char *))
d5c145
+		dlsym(RTLD_NEXT, "fopen")) (path, mode);
d5c145
+    }
d5c145
+}]]]
d5c145
+ 
d5c145
+setenv LD_PRELOAD $libfopen_so
d5c145
 ltraceMatch1 [ltraceRun -L -S -F $conf -- $bin] {^open@SYS\("/some/path", 0\)} == 0
d5c145
+unsetenv LD_PRELOAD
d5c145
 
d5c145
 # On the other hand, if -F somedir/ is given, we want to accept
d5c145
 # syscalls.conf found there.