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
Jan Kratochvil 53edfc5
sources/gdb/testsuite/gdb.base/dump.exp:
Jan Kratochvil 53edfc5
Found on RHEL-5.s390x.
Jan Kratochvil 53edfc5
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
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
Jan Kratochvil 53edfc5
Index: gdb-7.12/gdb/testsuite/gdb.base/fileio.c
Jan Kratochvil 53edfc5
===================================================================
Jan Kratochvil 53edfc5
--- gdb-7.12.orig/gdb/testsuite/gdb.base/fileio.c	2016-08-01 17:50:21.000000000 +0200
Jan Kratochvil 53edfc5
+++ gdb-7.12/gdb/testsuite/gdb.base/fileio.c	2016-10-07 22:49:20.689346914 +0200
Jan Kratochvil 53edfc5
@@ -556,6 +556,28 @@
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 ();
Jan Kratochvil 53edfc5
Index: gdb-7.12/gdb/testsuite/gdb.base/fileio.exp
Jan Kratochvil 53edfc5
===================================================================
Jan Kratochvil 53edfc5
--- gdb-7.12.orig/gdb/testsuite/gdb.base/fileio.exp	2016-08-01 17:50:21.000000000 +0200
Jan Kratochvil 53edfc5
+++ gdb-7.12/gdb/testsuite/gdb.base/fileio.exp	2016-10-07 22:54:44.680071906 +0200
Jan Kratochvil 53edfc5
@@ -24,9 +24,9 @@
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}" \
Jan Kratochvil 53edfc5
@@ -47,7 +47,8 @@
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"]
Jan Kratochvil 53edfc5
@@ -89,7 +90,7 @@
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" \
Jan Kratochvil 53edfc5
@@ -276,9 +277,7 @@
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