81783d0
gdb/testsuite/gdb.base/fileio.c:
81783d0
gdb/testsuite/gdb.base/fileio.exp:
4a93050
2007-12-08  Jan Kratochvil  <jan.kratochvil@redhat.com>
4a93050
4a93050
	* gdb.base/fileio.c (ROOTSUBDIR): New macro.
4a93050
	(main): CHDIR into ROOTSUBDIR.  CHOWN ROOTSUBDIR and CHDIR into
4a93050
	ROOTSUBDIR if we are being run as root.
4a93050
	* gdb.base/fileio.exp: Change the startup and finish cleanup.
4a93050
	Change the test file reference to be into the `fileio.dir' directory.
4a93050
81783d0
81783d0
sources/gdb/testsuite/gdb.base/dump.exp:
81783d0
Found on RHEL-5.s390x.
81783d0
81783d0
81783d0
gdb-6.8.50.20090209/gdb/testsuite/gdb.base/auxv.exp:
81783d0
random FAIL: gdb.base/auxv.exp: matching auxv data from live and gcore
81783d0
81783d0
81783d0
gdb-6.8.50.20090209/gdb/testsuite/gdb.base/annota1.exp:
81783d0
frames-invalid can happen asynchronously.
81783d0
Jan Kratochvil 254f0e9
Index: gdb-7.4.50.20120103/gdb/testsuite/gdb.base/fileio.c
dd46ae6
===================================================================
Jan Kratochvil 254f0e9
--- gdb-7.4.50.20120103.orig/gdb/testsuite/gdb.base/fileio.c	2009-10-01 17:39:13.000000000 +0200
Jan Kratochvil 254f0e9
+++ gdb-7.4.50.20120103/gdb/testsuite/gdb.base/fileio.c	2012-01-03 15:21:28.122729249 +0100
4a93050
@@ -58,6 +58,8 @@ system (const char * string);
4a93050
 1) Invalid string/command. -  returns 127.  */
4a93050
 static const char *strerrno (int err);
4a93050
 
4a93050
+#define ROOTSUBDIR "fileio.dir"
4a93050
+
4a93050
 #define FILENAME    "foo.fileio.test"
4a93050
 #define RENAMED     "bar.fileio.test"
4a93050
 #define NONEXISTANT "nofoo.fileio.test"
4a93050
@@ -542,6 +544,37 @@ strerrno (int err)
4a93050
 int
4a93050
 main ()
4a93050
 {
4a93050
+  /* ROOTSUBDIR is already prepared by fileio.exp.  We use it for easy cleanup
4a93050
+     (by fileio.exp) if we are run by multiple users in the same directory.  */
4a93050
+
4a93050
+  if (chdir (ROOTSUBDIR) != 0)
4a93050
+    {
4a93050
+      printf ("chdir " ROOTSUBDIR ": %s\n", strerror (errno));
4a93050
+      exit (1);
4a93050
+    }
4a93050
+
4a93050
+  /* These tests
4a93050
+       Open for write but no write permission returns EACCES
4a93050
+       Unlinking a file in a directory w/o write access returns EACCES
4a93050
+     fail if we are being run as root - drop the privileges here.  */
4a93050
+
4a93050
+  if (geteuid () == 0)
4a93050
+    {
4a93050
+      uid_t uid = 99;
4a93050
+
4a93050
+      if (chown (".", uid, uid) != 0)
4a93050
+	{
4a93050
+	  printf ("chown %d.%d " ROOTSUBDIR ": %s\n", (int) uid, (int) uid,
4a93050
+		  strerror (errno));
4a93050
+	  exit (1);
4a93050
+	}
4a93050
+      if (setuid (uid) || geteuid () == 0)
4a93050
+	{
4a93050
+	  printf ("setuid %d: %s\n", (int) uid, strerror (errno));
4a93050
+	  exit (1);
4a93050
+	}
4a93050
+    }
4a93050
+
4a93050
   /* Don't change the order of the calls.  They partly depend on each other */
4a93050
   test_open ();
4a93050
   test_write ();
Jan Kratochvil 254f0e9
Index: gdb-7.4.50.20120103/gdb/testsuite/gdb.base/fileio.exp
dd46ae6
===================================================================
Jan Kratochvil 254f0e9
--- gdb-7.4.50.20120103.orig/gdb/testsuite/gdb.base/fileio.exp	2011-12-26 12:24:55.000000000 +0100
Jan Kratochvil 254f0e9
+++ gdb-7.4.50.20120103/gdb/testsuite/gdb.base/fileio.exp	2012-01-03 15:22:02.716601956 +0100
dd46ae6
@@ -42,8 +42,8 @@ if [get_compiler_info ${binfile}] {
4a93050
     return -1;
4a93050
 }
4a93050
 
4a93050
-remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test}
4a93050
-remote_exec build {sh -xc rm\ -rf\ *.fileio.test}
4a93050
+remote_exec build {sh -xc rm\ -rf\ fileio.dir}
4a93050
+remote_exec build {sh -xc mkdir\ -m777\ fileio.dir}
4a93050
 
4a93050
 set oldtimeout $timeout
4a93050
 set timeout [expr "$timeout + 60"]
dd46ae6
@@ -85,7 +85,7 @@ gdb_test continue \
dd46ae6
 
dd46ae6
 gdb_test "continue" ".*" ""
4a93050
 
4a93050
-catch "system \"chmod -f -w nowrt.fileio.test\""
4a93050
+catch "system \"chmod -f -w fileio.dir/nowrt.fileio.test\""
4a93050
 
4a93050
 gdb_test continue \
4a93050
 "Continuing\\..*open 5:.*EACCES$stop_msg" \
Jan Kratochvil 254f0e9
@@ -251,8 +251,8 @@ gdb_exit
Jan Kratochvil 254f0e9
 # Wait till GDB really exits.
Jan Kratochvil 254f0e9
 sleep 1
4a93050
 
4a93050
-remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test}
4a93050
-remote_exec build {sh -xc rm\ -rf\ *.fileio.test}
4a93050
+remote_exec build {sh -xc test\ -r\ fileio.dir/dir2.fileio.test\ &&\ chmod\ -f\ +w\ fileio.dir/dir2.fileio.test}
4a93050
+remote_exec build {sh -xc rm\ -rf\ fileio.dir}
4a93050
 
4a93050
 set timeout $oldtimeout
4a93050
 return 0