a8767b3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
f524ac5
From: Fedora GDB patches <invalid@email.com>
f524ac5
Date: Fri, 27 Oct 2017 21:07:50 +0200
f524ac5
Subject: gdb-rhbz1156192-recursive-dlopen-test.patch
f524ac5
f637971
;; Testcase for '[SAP] Recursive dlopen causes SAP HANA installer to
f637971
;; crash.' (RH BZ 1156192).
f637971
;;=fedoratest
f637971
f637971
diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libbar.c b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libbar.c
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libbar.c
Jan Kratochvil 29d49d9
@@ -0,0 +1,30 @@
Jan Kratochvil 29d49d9
+/* Testcase for recursive dlopen calls.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   Copyright (C) 2014 Free Software Foundation, Inc.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This file is part of GDB.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is free software; you can redistribute it and/or modify
Jan Kratochvil 29d49d9
+   it under the terms of the GNU General Public License as published by
Jan Kratochvil 29d49d9
+   the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 29d49d9
+   (at your option) any later version.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is distributed in the hope that it will be useful,
Jan Kratochvil 29d49d9
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 29d49d9
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 29d49d9
+   GNU General Public License for more details.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   You should have received a copy of the GNU General Public License
Jan Kratochvil 29d49d9
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+/* This test was copied from glibc's testcase called
Jan Kratochvil 29d49d9
+   <dlfcn/tst-rec-dlopen.c> and related files.  */
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+#include <stdio.h>
Jan Kratochvil 29d49d9
+#include <stdlib.h>
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+void
Jan Kratochvil 29d49d9
+bar (void)
Jan Kratochvil 29d49d9
+{
Jan Kratochvil 29d49d9
+  printf ("Called bar.\n");
Jan Kratochvil 29d49d9
+}
f637971
diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libfoo.c b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libfoo.c
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen-libfoo.c
Jan Kratochvil 29d49d9
@@ -0,0 +1,30 @@
Jan Kratochvil 29d49d9
+/* Testcase for recursive dlopen calls.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   Copyright (C) 2014 Free Software Foundation, Inc.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This file is part of GDB.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is free software; you can redistribute it and/or modify
Jan Kratochvil 29d49d9
+   it under the terms of the GNU General Public License as published by
Jan Kratochvil 29d49d9
+   the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 29d49d9
+   (at your option) any later version.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is distributed in the hope that it will be useful,
Jan Kratochvil 29d49d9
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 29d49d9
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 29d49d9
+   GNU General Public License for more details.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   You should have received a copy of the GNU General Public License
Jan Kratochvil 29d49d9
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+/* This test was copied from glibc's testcase called
Jan Kratochvil 29d49d9
+   <dlfcn/tst-rec-dlopen.c> and related files.  */
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+#include <stdio.h>
Jan Kratochvil 29d49d9
+#include <stdlib.h>
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+void
Jan Kratochvil 29d49d9
+foo (void)
Jan Kratochvil 29d49d9
+{
Jan Kratochvil 29d49d9
+  printf ("Called foo.\n");
Jan Kratochvil 29d49d9
+}
f637971
diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c
Jan Kratochvil 29d49d9
@@ -0,0 +1,124 @@
Jan Kratochvil 29d49d9
+/* Testcase for recursive dlopen calls.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   Copyright (C) 2014 Free Software Foundation, Inc.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This file is part of GDB.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is free software; you can redistribute it and/or modify
Jan Kratochvil 29d49d9
+   it under the terms of the GNU General Public License as published by
Jan Kratochvil 29d49d9
+   the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 29d49d9
+   (at your option) any later version.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   This program is distributed in the hope that it will be useful,
Jan Kratochvil 29d49d9
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 29d49d9
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 29d49d9
+   GNU General Public License for more details.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+   You should have received a copy of the GNU General Public License
Jan Kratochvil 29d49d9
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+/* This test was copied from glibc's testcase called
Jan Kratochvil 29d49d9
+   <dlfcn/tst-rec-dlopen.c> and related files.  */
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+#include <stdio.h>
Jan Kratochvil 29d49d9
+#include <stdlib.h>
Jan Kratochvil 29d49d9
+#include <malloc.h>
Jan Kratochvil 29d49d9
+#include <dlfcn.h>
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+#define DSO "gdb-rhbz1156192-recursive-dlopen-libfoo.so"
Jan Kratochvil 29d49d9
+#define FUNC "foo"
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+#define DSO1 "gdb-rhbz1156192-recursive-dlopen-libbar.so"
Jan Kratochvil 29d49d9
+#define FUNC1 "bar"
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+/* Prototype for my hook.  */
Jan Kratochvil 29d49d9
+void *custom_malloc_hook (size_t, const void *);
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+/* Pointer to old malloc hooks.  */
Jan Kratochvil 29d49d9
+void *(*old_malloc_hook) (size_t, const void *);
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+/* Call function func_name in DSO dso_name via dlopen.  */
Jan Kratochvil 29d49d9
+void
Jan Kratochvil 29d49d9
+call_func (const char *dso_name, const char *func_name)
Jan Kratochvil 29d49d9
+{
Jan Kratochvil 29d49d9
+  int ret;
Jan Kratochvil 29d49d9
+  void *dso;
Jan Kratochvil 29d49d9
+  void (*func) (void);
Jan Kratochvil 29d49d9
+  char *err;
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+  /* Open the DSO.  */
Jan Kratochvil 29d49d9
+  dso = dlopen (dso_name, RTLD_NOW|RTLD_GLOBAL);
Jan Kratochvil 29d49d9
+  if (dso == NULL)
Jan Kratochvil 29d49d9
+    {
Jan Kratochvil 29d49d9
+      err = dlerror ();
Jan Kratochvil 29d49d9
+      fprintf (stderr, "%s\n", err);
Jan Kratochvil 29d49d9
+      exit (1);
Jan Kratochvil 29d49d9
+    }
Jan Kratochvil 29d49d9
+  /* Clear any errors.  */
Jan Kratochvil 29d49d9
+  dlerror ();
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+  /* Lookup func.  */
Jan Kratochvil 29d49d9
+  *(void **) (&func) = dlsym (dso, func_name);
Jan Kratochvil 29d49d9
+  if (func == NULL)
Jan Kratochvil 29d49d9
+    {
Jan Kratochvil 29d49d9
+      err = dlerror ();
Jan Kratochvil 29d49d9
+      if (err != NULL)
Jan Kratochvil 29d49d9
+        {
Jan Kratochvil 29d49d9
+  fprintf (stderr, "%s\n", err);
Jan Kratochvil 29d49d9
+  exit (1);
Jan Kratochvil 29d49d9
+        }
Jan Kratochvil 29d49d9
+    }
Jan Kratochvil 29d49d9
+  /* Call func twice.  */
Jan Kratochvil 29d49d9
+  (*func) ();
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+  /* Close the library and look for errors too.  */
Jan Kratochvil 29d49d9
+  ret = dlclose (dso);
Jan Kratochvil 29d49d9
+  if (ret != 0)
Jan Kratochvil 29d49d9
+    {
Jan Kratochvil 29d49d9
+      err = dlerror ();
Jan Kratochvil 29d49d9
+      fprintf (stderr, "%s\n", err);
Jan Kratochvil 29d49d9
+      exit (1);
Jan Kratochvil 29d49d9
+    }
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+/* Empty hook that does nothing.  */
Jan Kratochvil 29d49d9
+void *
Jan Kratochvil 29d49d9
+custom_malloc_hook (size_t size, const void *caller)
Jan Kratochvil 29d49d9
+{
Jan Kratochvil 29d49d9
+  void *result;
Jan Kratochvil 29d49d9
+  /* Restore old hooks.  */
Jan Kratochvil 29d49d9
+  __malloc_hook = old_malloc_hook;
Jan Kratochvil 29d49d9
+  /* First call a function in another library via dlopen.  */
Jan Kratochvil 29d49d9
+  call_func (DSO1, FUNC1);
Jan Kratochvil 29d49d9
+  /* Called recursively.  */
Jan Kratochvil 29d49d9
+  result = malloc (size);
Jan Kratochvil 29d49d9
+  /* Restore new hooks.  */
Jan Kratochvil 29d49d9
+  __malloc_hook = custom_malloc_hook;
Jan Kratochvil 29d49d9
+  return result;
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+int
Jan Kratochvil 29d49d9
+main (void)
Jan Kratochvil 29d49d9
+{
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+  /* Save old hook.  */
Jan Kratochvil 29d49d9
+  old_malloc_hook = __malloc_hook;
Jan Kratochvil 29d49d9
+  /* Install new hook.  */
Jan Kratochvil 29d49d9
+  __malloc_hook = custom_malloc_hook;
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+  /* Attempt to dlopen a shared library. This dlopen will
Jan Kratochvil 29d49d9
+     trigger an access to the ld.so.cache, and that in turn
Jan Kratochvil 29d49d9
+     will require a malloc to duplicate data in the cache.
Jan Kratochvil 29d49d9
+     The malloc will call our malloc hook which calls dlopen
Jan Kratochvil 29d49d9
+     recursively, and upon return of this dlopen the non-ref
Jan Kratochvil 29d49d9
+     counted ld.so.cache mapping will be unmapped. We will
Jan Kratochvil 29d49d9
+     return to the original dlopen and crash trying to access
Jan Kratochvil 29d49d9
+     dlopened data.  */
Jan Kratochvil 29d49d9
+  call_func (DSO, FUNC);
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+  /* Restore old hook.  */
Jan Kratochvil 29d49d9
+  __malloc_hook = old_malloc_hook;
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+  return 0;
Jan Kratochvil 29d49d9
+}
f637971
diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp
Jan Kratochvil b513153
@@ -0,0 +1,137 @@
Jan Kratochvil 29d49d9
+# Copyright 2014 Free Software Foundation, Inc.
Jan Kratochvil 29d49d9
+#
Jan Kratochvil 29d49d9
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil 29d49d9
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil 29d49d9
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil 29d49d9
+# (at your option) any later version.
Jan Kratochvil 29d49d9
+#
Jan Kratochvil 29d49d9
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil 29d49d9
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 29d49d9
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 29d49d9
+# GNU General Public License for more details.
Jan Kratochvil 29d49d9
+#
Jan Kratochvil 29d49d9
+# You should have received a copy of the GNU General Public License
Jan Kratochvil 29d49d9
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+if { [skip_shlib_tests] } {
Jan Kratochvil 29d49d9
+  return 0
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+# Library foo
Jan Kratochvil 29d49d9
+set libname1 "gdb-rhbz1156192-recursive-dlopen-libfoo"
Jan Kratochvil 29d49d9
+set srcfile_lib1 ${srcdir}/${subdir}/${libname1}.c
Jan Kratochvil 29d49d9
+set binfile_lib1 [standard_output_file ${libname1}.so]
Jan Kratochvil 29d49d9
+# Library bar
Jan Kratochvil 29d49d9
+set libname2 "gdb-rhbz1156192-recursive-dlopen-libbar"
Jan Kratochvil 29d49d9
+set srcfile_lib2 ${srcdir}/${subdir}/${libname2}.c
Jan Kratochvil 29d49d9
+set binfile_lib2 [standard_output_file ${libname2}.so]
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+set testfile "gdb-rhbz1156192-recursive-dlopen"
Jan Kratochvil 43d7d2a
+set srcfile ${testfile}.c
Jan Kratochvil 29d49d9
+set executable ${testfile}
Jan Kratochvil 29d49d9
+set binfile [standard_output_file ${executable}]
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+if { [gdb_compile_shlib ${srcfile_lib1} ${binfile_lib1} \
Jan Kratochvil 29d49d9
+	{ debug "additional_flags=-fPIC" }] != "" } {
Jan Kratochvil 29d49d9
+    untested "Could not compile ${binfile_lib1}"
Jan Kratochvil 29d49d9
+    return -1
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+if { [gdb_compile_shlib ${srcfile_lib2} ${binfile_lib2} \
Jan Kratochvil 29d49d9
+	{ debug "additional_flags=-fPIC" }] != "" } {
Jan Kratochvil 29d49d9
+    untested "Could not compile ${binfile_lib2}"
Jan Kratochvil 29d49d9
+    return -1
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+if { [prepare_for_testing ${testfile}.exp ${executable} ${srcfile} \
Jan Kratochvil b513153
+	[ list debug shlib_load "additional_flags=-Wno-deprecated-declarations" ]] } {
Jan Kratochvil 29d49d9
+    untested "Could not compile ${executable}"
Jan Kratochvil 29d49d9
+    return -1
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil b513153
+proc do_test { has_libfoo has_libbar } {
Jan Kratochvil 29d49d9
+  global hex binfile_lib2 binfile_lib1 gdb_prompt
Jan Kratochvil 29d49d9
+  set libbar_match "[string_to_regexp $binfile_lib2]"
Jan Kratochvil 29d49d9
+  set libfoo_match "[string_to_regexp $binfile_lib1]"
Jan Kratochvil 29d49d9
+
Jan Kratochvil b513153
+  gdb_test_multiple "info shared" "info shared" {
Jan Kratochvil b513153
+    -re ".*$libfoo_match\r\n.*$libbar_match\(\r\n.*Shared library is missing\)?.*\r\n${gdb_prompt} $" {
Jan Kratochvil b513153
+      if { $has_libfoo && $has_libbar } {
Jan Kratochvil b513153
+	pass "matched libfoo and libbar"
Jan Kratochvil b513153
+      } else {
Jan Kratochvil b513153
+	fail "matched libfoo and libbar (has_libfoo = $has_libfoo, has_libbar = $has_libbar)"
Jan Kratochvil 29d49d9
+      }
Jan Kratochvil b513153
+    }
Jan Kratochvil b513153
+    -re ".*$libfoo_match\(\r\n.*Shared library is missing\)?.*\r\n${gdb_prompt} $" {
Jan Kratochvil b513153
+      if { $has_libfoo && !$has_libbar } {
Jan Kratochvil b513153
+	pass "matched libfoo"
Jan Kratochvil b513153
+      } else {
Jan Kratochvil b513153
+	fail "matched libfoo (has_libfoo = $has_libfoo, has_libbar = $has_libbar)"
Jan Kratochvil 29d49d9
+      }
Jan Kratochvil b513153
+    }
Jan Kratochvil b513153
+    -re ".*$libbar_match\(\r\n.*Shared library is missing\)?.*\r\n${gdb_prompt} $" {
Jan Kratochvil b513153
+      if { $has_libbar && !$has_libfoo } {
Jan Kratochvil b513153
+	pass "matched libbar"
Jan Kratochvil b513153
+      } else {
Jan Kratochvil b513153
+	fail "matched libbar (has_libfoo = $has_libfoo, has_libbar = $has_libbar)"
Jan Kratochvil 29d49d9
+      }
Jan Kratochvil b513153
+    }
Jan Kratochvil b513153
+    "\r\n${gdb_prompt} $" {
Jan Kratochvil b513153
+      if { !$has_libfoo && !$has_libbar } {
Jan Kratochvil b513153
+	pass "did not match libfoo nor libbar"
Jan Kratochvil b513153
+      } else {
Jan Kratochvil b513153
+	fail "did not match libfoo nor libbar (has_libfoo = $has_libfoo, has_libbar = $has_libbar)"
Jan Kratochvil 29d49d9
+      }
Jan Kratochvil 29d49d9
+    }
Jan Kratochvil 29d49d9
+  }
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+proc test_stop_on_solib_events { } {
Jan Kratochvil 29d49d9
+  set pass 0
Jan Kratochvil 29d49d9
+  # This variable holds the information about whether libfoo and
Jan Kratochvil 29d49d9
+  # libbar (respectively) are expected in the "info shared" output.
Jan Kratochvil b513153
+  set solib_event_order { { 0 0 } { 0 0   } { 0 0   } { 0 1 } \
Jan Kratochvil b513153
+			  { 0 1 } { 0 0   } { 0 0   } { 0 1 } \
Jan Kratochvil b513153
+			  { 0 1 } { 0 0   } { 0 0   } { 0 1 } \
Jan Kratochvil b513153
+			  { 0 1 } { 0 0   } { 0 0 1 } { 1 1 } \
Jan Kratochvil b513153
+			  { 1 1 } { 1 0   } { 1 0   } { 1 1 } \
Jan Kratochvil b513153
+			  { 1 1 } { 1 0 1 } { 1 0   } { 1 0 } }
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+  with_test_prefix "stop-on-solib-events" {
Jan Kratochvil 29d49d9
+    gdb_test_no_output "set stop-on-solib-events 1" "setting stop-on-solib-events"
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+    gdb_run_cmd
Jan Kratochvil 29d49d9
+    foreach l $solib_event_order {
Jan Kratochvil 29d49d9
+      incr pass
Jan Kratochvil b513153
+      with_test_prefix "pass #$pass" {
Jan Kratochvil b513153
+	set should_be_corrupted [expr 0+0[lindex $l 2]]
Jan Kratochvil b513153
+	do_test [lindex $l 0] [lindex $l 1]
Jan Kratochvil b513153
+	set test "continue"
Jan Kratochvil b513153
+	global gdb_prompt
Jan Kratochvil b513153
+	gdb_test_multiple $test $test {
Jan Kratochvil b513153
+	  -re "\r\nwarning: Corrupted shared library list:.*\r\nStopped due to shared library event.*\r\n$gdb_prompt $" {
Jan Kratochvil b513153
+	    set corrupted 1
Jan Kratochvil b513153
+	    pass $test
Jan Kratochvil b513153
+	  }
Jan Kratochvil b513153
+	  -re "\r\nStopped due to shared library event.*\r\n$gdb_prompt $" {
Jan Kratochvil b513153
+	    set corrupted 0
Jan Kratochvil b513153
+	    pass $test
Jan Kratochvil b513153
+	  }
Jan Kratochvil b513153
+	}
Jan Kratochvil b513153
+	set test "corrupted=$corrupted but should_be_corrupted=$should_be_corrupted"
Jan Kratochvil b513153
+	if {$corrupted == $should_be_corrupted} {
Jan Kratochvil b513153
+	  pass $test
Jan Kratochvil b513153
+	} else {
Jan Kratochvil b513153
+	  fail $test
Jan Kratochvil b513153
+	}
Jan Kratochvil b513153
+      }
Jan Kratochvil 29d49d9
+    }
Jan Kratochvil 29d49d9
+    # In the last pass we do not expect to see libfoo or libbar.
Jan Kratochvil 29d49d9
+    incr pass
Jan Kratochvil b513153
+    with_test_prefix "pass #$pass" {
Jan Kratochvil b513153
+      do_test 0 0
Jan Kratochvil b513153
+    }
Jan Kratochvil 29d49d9
+  }
Jan Kratochvil 29d49d9
+}
Jan Kratochvil 29d49d9
+
Jan Kratochvil 29d49d9
+test_stop_on_solib_events