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

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