[tests] Don't assume CWD is writable
authorMarek Habersack <grendel@twistedcode.net>
Tue, 21 Jul 2015 21:37:38 +0000 (23:37 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Tue, 21 Jul 2015 22:15:47 +0000 (00:15 +0200)
Use temporary path instead. CWD is / on Android and is not writable

mcs/class/Mono.Posix/Test/Mono.Unix/StdioFileStreamTest.cs

index 1b0df494a7749bed531d88f739422ac5efe86675..23e26ea05cb91847b072a734cb21a369b52829f8 100644 (file)
@@ -226,21 +226,22 @@ namespace MonoTests.System.IO
                {
                        StdioFileStream fs = null;
                        StdioFileStream fs2 = null;
+                       string tempPath = Path.Combine (Path.GetTempPath (), "temp");
                        try {
-                               if (!File.Exists ("temp")) {
-                                       TextWriter tw = File.CreateText ("temp");
+                               if (!File.Exists (tempPath)) {
+                                       TextWriter tw = File.CreateText (tempPath);
                                        tw.Write ("FOO");
                                        tw.Close ();
                                }
-                               fs = new StdioFileStream ("temp", FileMode.Open, FileAccess.Read);
-                               fs2 = new StdioFileStream ("temp", FileMode.Open, FileAccess.Read);
+                               fs = new StdioFileStream (tempPath, FileMode.Open, FileAccess.Read);
+                               fs2 = new StdioFileStream (tempPath, FileMode.Open, FileAccess.Read);
                        } finally {
                                if (fs != null)
                                        fs.Close ();
                                if (fs2 != null)
                                        fs2.Close ();
-                               if (File.Exists ("temp"))
-                                       File.Delete ("temp");
+                               if (File.Exists (tempPath))
+                                       File.Delete (tempPath);
                        }
                }