Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@ -155,8 +155,12 @@ namespace MonoTests.System.IO
static bool RunningAsRoot // FIXME?
{
get {
#if WASM
return false;
#else
//return RunningOnUnix && System.Security.WindowsIdentity.GetCurrentToken () == IntPtr.Zero;
return RunningOnUnix && geteuid () == 0;
#endif
}
}
@ -352,7 +356,6 @@ namespace MonoTests.System.IO
Assert.Fail ("#1");
} catch (FileNotFoundException ex) {
Assert.AreEqual (typeof (FileNotFoundException), ex.GetType (), "#2");
Assert.AreEqual ("doesnotexist", ex.FileName, "#3");
Assert.IsNull (ex.InnerException, "#4");
Assert.IsNotNull (ex.Message, "#5");
}
@ -483,7 +486,6 @@ namespace MonoTests.System.IO
try {
File.Delete (path);
Assert.Fail ("#1");
} catch (DirectoryNotFoundException ex) {
// Could not find a part of the path "..."
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#2");
@ -845,7 +847,6 @@ namespace MonoTests.System.IO
Assert.AreEqual (typeof (DirectoryNotFoundException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsFalse (ex.Message.IndexOf (destFile) != -1, "#5");
}
} finally {
DeleteFile (sourceFile);
@ -853,6 +854,7 @@ namespace MonoTests.System.IO
}
[Test]
[Category("NotWasm")]
public void Move_DestFileName_AlreadyExists ()
{
string sourceFile = tmpFolder + Path.DirectorySeparatorChar + "foo";
@ -869,7 +871,6 @@ namespace MonoTests.System.IO
Assert.IsNull (ex.InnerException, "#A3");
Assert.IsNotNull (ex.Message, "#A4");
Assert.IsFalse (ex.Message.IndexOf (sourceFile) != -1, "#A5");
Assert.IsFalse (ex.Message.IndexOf (tmpFolder) != -1, "#A6");
} finally {
DeleteFile (sourceFile);
}
@ -887,7 +888,6 @@ namespace MonoTests.System.IO
Assert.IsNull (ex.InnerException, "#B3");
Assert.IsNotNull (ex.Message, "#B4");
Assert.IsFalse (ex.Message.IndexOf (sourceFile) != -1, "#B5");
Assert.IsFalse (ex.Message.IndexOf (destFile) != -1, "#B6");
} finally {
DeleteFile (sourceFile);
DeleteFile (destFile);
@ -906,7 +906,6 @@ namespace MonoTests.System.IO
Assert.IsNull (ex.InnerException, "#C3");
Assert.IsNotNull (ex.Message, "#C4");
Assert.IsFalse (ex.Message.IndexOf (sourceFile) != -1, "#C5");
Assert.IsFalse (ex.Message.IndexOf (destFile) != -1, "#C6");
} finally {
DeleteFile (sourceFile);
DeleteDirectory (destFile);
@ -1193,6 +1192,7 @@ namespace MonoTests.System.IO
}
[Test]
[Category ("NotWasm")]
public void LastAccessTime ()
{
string path = tmpFolder + Path.DirectorySeparatorChar + "lastAccessTime";
@ -1316,6 +1316,10 @@ namespace MonoTests.System.IO
[Test]
public void LastWriteTimeSubMsCopy ()
{
#if MONOTOUCH
if (Version.TryParse (Environment.GetEnvironmentVariable ("SIMULATOR_RUNTIME_VERSION"), out Version simulatorVersion) && simulatorVersion.Major < 11 && new DriveInfo("/").DriveFormat == "apfs")
Assert.Inconclusive ("This test doesn't work on old iOS Simulator versions running on newer macOS with APFS.");
#endif
string path = tmpFolder + Path.DirectorySeparatorChar + "lastWriteTimeSubMs";
if (File.Exists (path))
File.Delete (path);
@ -1904,32 +1908,6 @@ namespace MonoTests.System.IO
// }
// }
[Test]
public void SetCreationTime_FileLock ()
{
string path = tmpFolder + Path.DirectorySeparatorChar + "CreationTimeIOException1";
DeleteFile (path);
FileStream stream = null;
try {
stream = File.Create (path);
try {
File.SetCreationTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
Assert.Fail ("#1");
} catch (IOException ex) {
// The process cannot access the file '...'
// because it is being used by another process
Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5");
}
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
[Test]
public void SetCreationTimeUtc_Path_Null ()
{
@ -2028,32 +2006,6 @@ namespace MonoTests.System.IO
// }
// }
[Test]
public void SetCreationTimeUtc_FileLock ()
{
string path = tmpFolder + Path.DirectorySeparatorChar + "SetCreationTimeUtcIOException1";
DeleteFile (path);
FileStream stream = null;
try {
stream = File.Create (path);
try {
File.SetCreationTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
Assert.Fail ("#1");
} catch (IOException ex) {
// The process cannot access the file "..."
// because it is being used by another process
Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5");
}
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
// SetLastAccessTime and SetLastAccessTimeUtc exceptions
[Test]
@ -2154,32 +2106,6 @@ namespace MonoTests.System.IO
// }
// }
[Test]
public void SetLastAccessTime_FileLock ()
{
string path = tmpFolder + Path.DirectorySeparatorChar + "LastAccessIOException1";
DeleteFile (path);
FileStream stream = null;
try {
stream = File.Create (path);
try {
File.SetLastAccessTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
Assert.Fail ("#1");
} catch (IOException ex) {
// The process cannot access the file "..."
// because it is being used by another process
Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5");
}
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
[Test]
public void SetLastAccessTimeUtc_Path_Null ()
{
@ -2278,32 +2204,6 @@ namespace MonoTests.System.IO
// }
// }
[Test]
public void SetLastAccessTimeUtc_FileLock ()
{
string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastAccessTimeUtcIOException1";
DeleteFile (path);
FileStream stream = null;
try {
stream = File.Create (path);
try {
File.SetLastAccessTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
Assert.Fail ("#1");
} catch (IOException ex) {
// The process cannot access the file "..."
// because it is being used by another process
Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5");
}
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
// SetLastWriteTime and SetLastWriteTimeUtc exceptions
[Test]
@ -2404,32 +2304,6 @@ namespace MonoTests.System.IO
// }
// }
[Test]
public void SetLastWriteTime_FileLock ()
{
string path = tmpFolder + Path.DirectorySeparatorChar + "LastWriteTimeIOException1";
DeleteFile (path);
FileStream stream = null;
try {
stream = File.Create (path);
try {
File.SetLastWriteTime (path, new DateTime (1000, 12, 12, 11, 59, 59));
Assert.Fail ("#1");
} catch (IOException ex) {
// The process cannot access the file '...'
// because it is being used by another process
Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5");
}
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
[Test]
public void SetLastWriteTimeUtc_Path_Null ()
{
@ -2528,32 +2402,6 @@ namespace MonoTests.System.IO
// }
// }
[Test]
public void SetLastWriteTimeUtc_FileLock ()
{
string path = tmpFolder + Path.DirectorySeparatorChar + "SetLastWriteTimeUtcIOException1";
DeleteFile (path);
FileStream stream = null;
try {
stream = File.Create (path);
try {
File.SetLastWriteTimeUtc (path, new DateTime (1000, 12, 12, 11, 59, 59));
Assert.Fail ("#1");
} catch (IOException ex) {
// The process cannot access the file '...'
// because it is being used by another process
Assert.AreEqual (typeof (IOException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsTrue (ex.Message.IndexOf (path) != -1, "#5");
}
} finally {
if (stream != null)
stream.Close ();
DeleteFile (path);
}
}
[Test]
public void OpenAppend ()
{
@ -2658,6 +2506,7 @@ namespace MonoTests.System.IO
}
[Test]
[Category("NotWasm")]
public void ReplaceTest ()
{
string tmp = Path.Combine (tmpFolder, "ReplaceTest");
@ -2740,43 +2589,70 @@ namespace MonoTests.System.IO
}
}
[Test]
public void MoveTest ()
{
MoveTest (FileAccess.Read, FileShare.None, false);
MoveTest (FileAccess.Read, FileShare.Read, false);
MoveTest (FileAccess.Read, FileShare.Write, false);
MoveTest (FileAccess.Read, FileShare.ReadWrite, false);
MoveTest (FileAccess.Read, FileShare.Delete, true);
MoveTest (FileAccess.Read, FileShare.Read | FileShare.Delete, true);
MoveTest (FileAccess.Read, FileShare.Write | FileShare.Delete, true);
MoveTest (FileAccess.Read, FileShare.ReadWrite | FileShare.Delete, true);
MoveTest (FileAccess.Write, FileShare.None, false);
MoveTest (FileAccess.Write, FileShare.Read, false);
MoveTest (FileAccess.Write, FileShare.Write, false);
MoveTest (FileAccess.Write, FileShare.ReadWrite, false);
MoveTest (FileAccess.Write, FileShare.Delete, true);
MoveTest (FileAccess.Write, FileShare.Read | FileShare.Delete, true);
MoveTest (FileAccess.Write, FileShare.Write | FileShare.Delete, true);
MoveTest (FileAccess.Write, FileShare.ReadWrite | FileShare.Delete, true);
MoveTest (FileAccess.ReadWrite, FileShare.None, false);
MoveTest (FileAccess.ReadWrite, FileShare.Read, false);
MoveTest (FileAccess.ReadWrite, FileShare.Write, false);
MoveTest (FileAccess.ReadWrite, FileShare.ReadWrite, false);
MoveTest (FileAccess.ReadWrite, FileShare.Delete, true);
MoveTest (FileAccess.ReadWrite, FileShare.Read | FileShare.Delete, true);
MoveTest (FileAccess.ReadWrite, FileShare.Write | FileShare.Delete, true);
MoveTest (FileAccess.ReadWrite, FileShare.ReadWrite | FileShare.Delete, true);
}
[DllImport ("libc", SetLastError=true)]
public static extern int symlink (string oldpath, string newpath);
[Test]
[Category ("NotWasm")]
public void SymLinkStats() {
if (!RunningOnUnix)
Assert.Ignore ("Symlink are hard on windows");
var name1 = Path.GetRandomFileName ();
var name2 = Path.GetRandomFileName ();
var path1 = Path.Combine (Path.GetTempPath (), name1);
var path2 = Path.Combine (Path.GetTempPath (), name2);
File.Delete (path1);
File.Delete (path2);
try {
using (var f = File.Create(path1)) {
Assert.IsNotNull (f, "Path1 must be created for symlink stats");
}
if (symlink (path1, path2) != 0)
Assert.Fail ("symlink #1 failed with errno={0}", Marshal.GetLastWin32Error ());
Assert.IsTrue (File.Exists (path1), "File.Exists must return true for path1 symlink stats");
Assert.IsTrue (File.Exists (path2), "File.Exists must return true for path2 symlink stats");
try {
File.SetLastWriteTime (path1, DateTime.Now.AddMinutes(-5));
File.SetCreationTime (path1, DateTime.Now.AddMinutes(-5));
File.SetLastAccessTime (path1, DateTime.Now.AddMinutes(-5));
Assert.AreNotEqual (File.GetLastWriteTime(path1), File.GetLastWriteTime (path2), "Path1 and Path2 should not have the same last write times");
Assert.AreNotEqual (File.GetCreationTime(path1), File.GetCreationTime (path2), "Path1 and Path2 should not have the same creation times");
Assert.AreNotEqual (File.GetLastAccessTime(path1), File.GetLastAccessTime (path2), "Path1 and Path2 should not have the same last access times");
}
catch(IOException e) {
Assert.Fail ("Symlink stats should allow setting/getting time on file");
}
File.Delete (path2);
Assert.IsTrue (File.Exists(path1), "Original file must still exist for symlink stats");
Assert.IsFalse (File.Exists(path2), "File.Delete must delete symlink only for symlink stats");
File.Delete (path1);
Assert.IsFalse (File.Exists (path1), "File.Delete must delete symlink stats");
} finally {
try {
File.Delete (path1);
File.Delete (path2);
} catch (IOException) {
//Don't double fault any exception from the tests.
}
}
}
[Test]
#if MONOTOUCH_TV
[Ignore ("See bug #59239")]
#endif
[Category ("NotWasm")]
public void SymLinkLoop ()
{
if (!RunningOnUnix)