Blame SOURCES/gdb-6.7-testsuite-stable-results.patch

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