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