a8767b3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
f524ac5
From: Jan Kratochvil <jan.kratochvil@redhat.com>
f524ac5
Date: Fri, 27 Oct 2017 21:07:50 +0200
f524ac5
Subject: gdb-6.7-testsuite-stable-results.patch
f524ac5
f637971
;; Testsuite fixes for more stable/comparable results.
f637971
;;=fedoratest
f524ac5
Jan Kratochvil 53edfc5
gdb/testsuite/gdb.base/fileio.c:
Jan Kratochvil 53edfc5
gdb/testsuite/gdb.base/fileio.exp:
Jan Kratochvil 53edfc5
2007-12-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
Jan Kratochvil 53edfc5
Jan Kratochvil 53edfc5
	* gdb.base/fileio.c (ROOTSUBDIR): New macro.
Jan Kratochvil 53edfc5
	(main): CHDIR into ROOTSUBDIR.  CHOWN ROOTSUBDIR and CHDIR into
Jan Kratochvil 53edfc5
	ROOTSUBDIR if we are being run as root.
Jan Kratochvil 53edfc5
	* gdb.base/fileio.exp: Change the startup and finish cleanup.
Jan Kratochvil 53edfc5
	Change the test file reference to be into the `fileio.dir' directory.
Jan Kratochvil 53edfc5
Jan Kratochvil 53edfc5
sources/gdb/testsuite/gdb.base/dump.exp:
Jan Kratochvil 53edfc5
Found on RHEL-5.s390x.
Jan Kratochvil 53edfc5
Jan Kratochvil 53edfc5
gdb-6.8.50.20090209/gdb/testsuite/gdb.base/auxv.exp:
Jan Kratochvil 53edfc5
random FAIL: gdb.base/auxv.exp: matching auxv data from live and gcore
Jan Kratochvil 53edfc5
Jan Kratochvil 53edfc5
gdb-6.8.50.20090209/gdb/testsuite/gdb.base/annota1.exp:
Jan Kratochvil 53edfc5
frames-invalid can happen asynchronously.
Jan Kratochvil 53edfc5
f637971
diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c
f637971
--- a/gdb/testsuite/gdb.base/fileio.c
f637971
+++ b/gdb/testsuite/gdb.base/fileio.c
f637971
@@ -560,6 +560,28 @@ strerrno (int err)
Jan Kratochvil 53edfc5
 int
Jan Kratochvil 53edfc5
 main ()
Jan Kratochvil 53edfc5
 {
Jan Kratochvil 53edfc5
+  /* These tests
Jan Kratochvil 53edfc5
+       Open for write but no write permission returns EACCES
Jan Kratochvil 53edfc5
+       Unlinking a file in a directory w/o write access returns EACCES
Jan Kratochvil 53edfc5
+     fail if we are being run as root - drop the privileges here.  */
Jan Kratochvil 53edfc5
+
Jan Kratochvil 53edfc5
+  if (geteuid () == 0)
Jan Kratochvil 53edfc5
+    {
Jan Kratochvil 53edfc5
+      uid_t uid = 99;
Jan Kratochvil 53edfc5
+
Jan Kratochvil 53edfc5
+      if (chown (OUTDIR, uid, uid) != 0)
Jan Kratochvil 53edfc5
+	{
Jan Kratochvil 53edfc5
+	  printf ("chown %d.%d %s: %s\n", (int) uid, (int) uid,
Jan Kratochvil 53edfc5
+		  OUTDIR, strerror (errno));
Jan Kratochvil 53edfc5
+	  exit (1);
Jan Kratochvil 53edfc5
+	}
Jan Kratochvil 53edfc5
+      if (setuid (uid) || geteuid () == 0)
Jan Kratochvil 53edfc5
+	{
Jan Kratochvil 53edfc5
+	  printf ("setuid %d: %s\n", (int) uid, strerror (errno));
Jan Kratochvil 53edfc5
+	  exit (1);
Jan Kratochvil 53edfc5
+	}
Jan Kratochvil 53edfc5
+    }
Jan Kratochvil 53edfc5
+
Jan Kratochvil 53edfc5
   /* Don't change the order of the calls.  They partly depend on each other */
Jan Kratochvil 53edfc5
   test_open ();
Jan Kratochvil 53edfc5
   test_write ();
f637971
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
f637971
--- a/gdb/testsuite/gdb.base/fileio.exp
f637971
+++ b/gdb/testsuite/gdb.base/fileio.exp
f637971
@@ -24,9 +24,9 @@ if [target_info exists gdb,nofileio] {
Jan Kratochvil 53edfc5
 standard_testfile
Jan Kratochvil 53edfc5
 
Jan Kratochvil 53edfc5
 if {[is_remote host]} {
Jan Kratochvil 53edfc5
-    set outdir .
Jan Kratochvil 53edfc5
+    set outdir "fileio.dir"
Jan Kratochvil 53edfc5
 } else {
Jan Kratochvil 53edfc5
-    set outdir [standard_output_file {}]
Jan Kratochvil 53edfc5
+    set outdir [standard_output_file "fileio.dir"]
Jan Kratochvil 53edfc5
 }
Jan Kratochvil 53edfc5
 
Jan Kratochvil 53edfc5
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
f637971
@@ -47,7 +47,8 @@ set dir2 [standard_output_file dir2.fileio.test]
Jan Kratochvil 53edfc5
 if {[file exists $dir2] && ![file writable $dir2]} {
Jan Kratochvil 53edfc5
     system "chmod +w $dir2"
Jan Kratochvil 53edfc5
 }
Jan Kratochvil 53edfc5
-system "rm -rf [standard_output_file *.fileio.test]"
Jan Kratochvil 53edfc5
+system "rm -rf [standard_output_file fileio.dir]"
Jan Kratochvil 53edfc5
+system "mkdir -m777 [standard_output_file fileio.dir]"
Jan Kratochvil 53edfc5
 
Jan Kratochvil 53edfc5
 set oldtimeout $timeout
Jan Kratochvil 53edfc5
 set timeout [expr "$timeout + 60"]
f637971
@@ -89,7 +90,7 @@ gdb_test continue \
Jan Kratochvil 53edfc5
 
Jan Kratochvil 53edfc5
 gdb_test "continue" ".*" ""
Jan Kratochvil 53edfc5
 
Jan Kratochvil 53edfc5
-catch "system \"chmod -f -w [standard_output_file nowrt.fileio.test]\""
Jan Kratochvil 53edfc5
+catch "system \"chmod -f -w [standard_output_file fileio.dir/nowrt.fileio.test]\""
Jan Kratochvil 53edfc5
 
Jan Kratochvil 53edfc5
 gdb_test continue \
Jan Kratochvil 53edfc5
 "Continuing\\..*open 5:.*EACCES$stop_msg" \
f637971
@@ -276,9 +277,7 @@ gdb_test continue \
Jan Kratochvil 53edfc5
 gdb_exit
Jan Kratochvil 53edfc5
 
Jan Kratochvil 53edfc5
 # Make dir2 writable again so rm -rf of a build tree Just Works.
Jan Kratochvil 53edfc5
-if {[file exists $dir2] && ![file writable $dir2]} {
Jan Kratochvil 53edfc5
-    system "chmod +w $dir2"
Jan Kratochvil 53edfc5
-}
Jan Kratochvil 53edfc5
+system "chmod -R +w $outdir"
Jan Kratochvil 53edfc5
 
Jan Kratochvil 53edfc5
 set timeout $oldtimeout
Jan Kratochvil 53edfc5
 return 0