Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -33,11 +33,13 @@ using System.Net.Sockets;
namespace Mono.Posix
{
#pragma warning disable 649
internal struct PeerCredData {
public int pid;
public int uid;
public int gid;
}
#pragma warning restore 649
[Obsolete ("Use Mono.Unix.PeerCred")]
public class PeerCred

View File

@@ -426,10 +426,20 @@ namespace Mono.Unix.Native {
public static Errno GetLastError ()
{
int errno = Marshal.GetLastWin32Error ();
return NativeConvert.ToErrno (errno);
if (Environment.OSVersion.Platform != PlatformID.Unix) {
// On Windows Marshal.GetLastWin32Error() doesn't take errno
// into account so we need to call Mono_Posix_Stdlib_GetLastError()
// which returns the value of errno in the C runtime
// libMonoPosixHelper.dll was linked against.
return (Errno) _GetLastError ();
}
return NativeConvert.ToErrno (Marshal.GetLastWin32Error ());
}
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
EntryPoint="Mono_Posix_Stdlib_GetLastError")]
private static extern int _GetLastError ();
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
EntryPoint="Mono_Posix_Stdlib_SetLastError")]
private static extern void SetLastError (int error);
@@ -675,7 +685,8 @@ namespace Mono.Unix.Native {
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
string newpath);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_tmpfile")]
public static extern IntPtr tmpfile ();
private static object tmpnam_lock = new object ();
@@ -704,18 +715,22 @@ namespace Mono.Unix.Native {
}
}
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fclose")]
public static extern int fclose (IntPtr stream);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fflush")]
public static extern int fflush (IntPtr stream);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fopen")]
public static extern IntPtr fopen (
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
string path, string mode);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_freopen")]
public static extern IntPtr freopen (
[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
string path, string mode, IntPtr stream);
@@ -741,8 +756,8 @@ namespace Mono.Unix.Native {
return setvbuf (stream, (IntPtr) buf, mode, size);
}
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
EntryPoint="fprintf")]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
EntryPoint="Mono_Posix_Stdlib_fprintf")]
private static extern int sys_fprintf (IntPtr stream, string format, string message);
public static int fprintf (IntPtr stream, string message)
@@ -846,11 +861,12 @@ namespace Mono.Unix.Native {
* vsscanf(3)
*/
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fgetc")]
public static extern int fgetc (IntPtr stream);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="fgets")]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fgets")]
private static extern IntPtr sys_fgets (StringBuilder sb, int size, IntPtr stream);
public static StringBuilder fgets (StringBuilder sb, int size, IntPtr stream)
@@ -866,22 +882,28 @@ namespace Mono.Unix.Native {
return fgets (sb, sb.Capacity, stream);
}
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fputc")]
public static extern int fputc (int c, IntPtr stream);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_fputs")]
public static extern int fputs (string s, IntPtr stream);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
public static extern int getc (IntPtr stream);
public static int getc (IntPtr stream)
{
return fgetc (stream);
}
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
public static extern int getchar ();
/* SKIP: gets(3) */
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
public static extern int putc (int c, IntPtr stream);
public static int putc (int c, IntPtr stream)
{
return fputc (c, stream);
}
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
public static extern int putchar (int c);
@@ -889,7 +911,8 @@ namespace Mono.Unix.Native {
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
public static extern int puts (string s);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_ungetc")]
public static extern int ungetc (int c, IntPtr stream);
[CLSCompliant (false)]
@@ -993,10 +1016,12 @@ namespace Mono.Unix.Native {
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_clearerr")]
public static extern int clearerr (IntPtr stream);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_feof")]
public static extern int feof (IntPtr stream);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_ferror")]
public static extern int ferror (IntPtr stream);
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
@@ -1050,7 +1075,8 @@ namespace Mono.Unix.Native {
SetLastError=true, EntryPoint="Mono_Posix_Stdlib_calloc")]
public static extern IntPtr calloc (ulong nmemb, ulong size);
[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl)]
[DllImport (MPH, CallingConvention=CallingConvention.Cdecl,
EntryPoint="Mono_Posix_Stdlib_free")]
public static extern void free (IntPtr ptr);
// malloc(3):

View File

@@ -1 +1 @@
cbeb54b0ec2778f87a457f5494c2f349d5ddb223
4ae330d5b46f74420f5ed35603c04f4f6cae15fc

View File

@@ -33,11 +33,13 @@ using System.Net.Sockets;
namespace Mono.Unix
{
#pragma warning disable 649
internal struct PeerCredData {
public int pid;
public int uid;
public int gid;
}
#pragma warning restore 649
public class PeerCred
{

View File

@@ -60,35 +60,43 @@ namespace Mono.Unix {
public StdioFileStream (string path)
{
if (path == null)
throw new ArgumentNullException ("path");
InitStream (Fopen (path, "rb"), true);
}
public StdioFileStream (string path, string mode)
{
if (path == null)
throw new ArgumentNullException ("path");
InitStream (Fopen (path, mode), true);
}
public StdioFileStream (string path, FileMode mode)
{
if (path == null)
throw new ArgumentNullException ("path");
InitStream (Fopen (path, ToFopenMode (path, mode)), true);
}
public StdioFileStream (string path, FileAccess access)
{
if (path == null)
throw new ArgumentNullException ("path");
InitStream (Fopen (path, ToFopenMode (path, access)), true);
InitCanReadWrite (access);
}
public StdioFileStream (string path, FileMode mode, FileAccess access)
{
if (path == null)
throw new ArgumentNullException ("path");
InitStream (Fopen (path, ToFopenMode (path, mode, access)), true);
InitCanReadWrite (access);
}
private static IntPtr Fopen (string path, string mode)
{
if (path == null)
throw new ArgumentNullException ("path");
if (path.Length == 0)
throw new ArgumentException ("path");
if (mode == null)

View File

@@ -152,11 +152,13 @@ namespace Mono.Unix {
// signum, count, write_fd, pipecnt, and pipelock are read from a signal handler thread
// count and pipelock are both read and written from the signal handler thread
#pragma warning disable 649
[Map]
struct SignalInfo {
public int signum, count, read_fd, write_fd, pipecnt, pipelock, have_handler;
public IntPtr handler; // Backed-up handler to restore when signal unregistered
}
#pragma warning restore 649
#region WaitHandle overrides
protected unsafe override void Dispose (bool disposing)

View File

@@ -8,9 +8,7 @@
//
using NUnit.Framework;
#if !MONODROID
using NUnit.Framework.SyntaxHelpers;
#endif
using System;
using System.Text;
using System.Threading;
@@ -21,7 +19,7 @@ using Mono.Unix.Native;
namespace MonoTests.Mono.Unix.Native {
[TestFixture]
[Category ("NotOnMac")]
[Category ("NotOnMac"), Category ("NotOnWindows")]
public class RealTimeSignumTest
{
[Test]

View File

@@ -20,7 +20,7 @@ using NUnit.Framework;
namespace MonoTests.Mono.Unix.Native
{
[TestFixture, Category ("NotDotNet")]
[TestFixture, Category ("NotDotNet"), Category ("NotOnWindows")]
public class SocketTest {
string TempFolder;

View File

@@ -17,7 +17,7 @@ using Mono.Unix.Native;
namespace MonoTests.Mono.Unix.Native {
[TestFixture]
[TestFixture, Category ("NotOnWindows")]
public class StdlibTest
{
private class SignalTest {

View File

@@ -18,7 +18,7 @@ using NUnit.Framework;
namespace MonoTests.Mono.Unix
{
[TestFixture, Category ("NotDotNet")]
[TestFixture, Category ("NotDotNet"), Category ("NotOnWindows")]
public class ReadlinkTest {
static string[] Targets = {
@@ -173,7 +173,7 @@ namespace MonoTests.Mono.Unix
long r = Syscall.readlink (link, buf);
if (r < 0)
UnixMarshal.ThrowExceptionForLastError ();
Assert.GreaterOrEqual (buf.Length, r);
Assert.That(buf.Length, Is.GreaterThanOrEqualTo(r));
if (r == buf.Length)
buf = new byte[checked (buf.Length * 2)];
else
@@ -199,7 +199,7 @@ namespace MonoTests.Mono.Unix
long r = Syscall.readlinkat (TempFD, "link", buf);
if (r < 0)
UnixMarshal.ThrowExceptionForLastError ();
Assert.GreaterOrEqual (buf.Length, r);
Assert.That(buf.Length, Is.GreaterThanOrEqualTo(r));
if (r == buf.Length)
buf = new byte[checked (buf.Length * 2)];
else
@@ -226,7 +226,7 @@ namespace MonoTests.Mono.Unix
if (r < 0)
UnixMarshal.ThrowExceptionForLastError ();
Assert.AreEqual (r, sb.Length);
Assert.GreaterOrEqual (sb.Capacity, r);
Assert.That(sb.Capacity, Is.GreaterThanOrEqualTo(r));
if (r == sb.Capacity)
checked { sb.Capacity *= 2; }
else
@@ -255,7 +255,7 @@ namespace MonoTests.Mono.Unix
if (r < 0)
UnixMarshal.ThrowExceptionForLastError ();
Assert.AreEqual (r, sb.Length);
Assert.GreaterOrEqual (sb.Capacity, r);
Assert.That(sb.Capacity, Is.GreaterThanOrEqualTo(r));
if (r == sb.Capacity)
checked { sb.Capacity *= 2; }
else

View File

@@ -21,25 +21,43 @@ namespace MonoTests.System.IO
[TestFixture]
public class StdioFileStreamTest {
string TempFolder = Path.Combine (Path.GetTempPath (), "MonoTests.Mono.Unix.Tests");
static string BaseTempFolder = Path.Combine (Path.GetTempPath (),
"MonoTests.Mono.Unix.Tests");
static string TempFolder;
static readonly char DSC = Path.DirectorySeparatorChar;
[TearDown]
public void TearDown()
[TestFixtureSetUp]
public void FixtureSetUp ()
{
if (Directory.Exists (TempFolder))
Directory.Delete (TempFolder, true);
try {
// Try to cleanup from any previous NUnit run.
Directory.Delete (BaseTempFolder, true);
} catch (Exception) {
}
}
[SetUp]
public void SetUp ()
{
if (Directory.Exists (TempFolder))
Directory.Delete (TempFolder, true);
int i = 0;
do {
TempFolder = Path.Combine (BaseTempFolder, (++i).ToString());
} while (Directory.Exists (TempFolder));
Directory.CreateDirectory (TempFolder);
}
[TearDown]
public void TearDown ()
{
try {
// This might throw an exception on Windows
// since the directory may contain open files.
Directory.Delete (TempFolder, true);
} catch (Exception e) {
Console.WriteLine (e);
}
}
public void TestCtr ()
{
string path = TempFolder + DSC + "testfilestream.tmp.1";
@@ -226,7 +244,7 @@ namespace MonoTests.System.IO
{
StdioFileStream fs = null;
StdioFileStream fs2 = null;
string tempPath = Path.Combine (Path.GetTempPath (), "temp");
string tempPath = Path.Combine (TempFolder, "temp");
try {
if (!File.Exists (tempPath)) {
TextWriter tw = File.CreateText (tempPath);
@@ -240,8 +258,6 @@ namespace MonoTests.System.IO
fs.Close ();
if (fs2 != null)
fs2.Close ();
if (File.Exists (tempPath))
File.Delete (tempPath);
}
}
@@ -273,8 +289,9 @@ namespace MonoTests.System.IO
stream.Write (outbytes, 7, 7);
stream.Write (outbytes, 14, 1);
stream.Read (bytes, 0, 15);
stream.Seek (15, SeekOrigin.Begin);
Array.Clear (bytes, 0, bytes.Length);
stream.Read (bytes, 0, 15);
for (int i = 0; i < 15; ++i)
Assert.AreEqual (i + 1, bytes [i]);
stream.Close ();

View File

@@ -17,7 +17,7 @@ using Mono.Unix;
namespace MonoTests.Mono.Unix {
[TestFixture]
[TestFixture, Category ("NotOnWindows")]
public class UnixEndPointTest {
// Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=35004

View File

@@ -21,7 +21,7 @@ using Syscall = Mono.Unix.Native.Syscall;
namespace MonoTests.Mono.Unix {
[TestFixture, Category ("NotDotNet")]
[TestFixture, Category ("NotDotNet"), Category ("NotOnWindows")]
public class UnixGroupTest
{
[Test]

View File

@@ -14,7 +14,7 @@ using Mono.Unix;
namespace MonoTests.Mono.Unix {
[TestFixture]
[TestFixture, Category ("NotOnWindows")]
public class UnixListenerTest {
// test that a socket file is created and deleted by the UnixListener

View File

@@ -28,7 +28,7 @@ namespace MonoTests.Mono.Unix {
}
}
[TestFixture]
[TestFixture, Category ("NotOnWindows")]
public class UnixMarshalTest {
#if false
public static void Main ()

View File

@@ -16,7 +16,7 @@ using Mono.Unix;
namespace MonoTests.Mono.Unix
{
[TestFixture, Category ("NotDotNet")]
[TestFixture, Category ("NotDotNet"), Category ("NotOnWindows")]
public class UnixPathTest {
private static readonly char DSC = UnixPath.DirectorySeparatorChar;

View File

@@ -8,21 +8,17 @@
//
using NUnit.Framework;
#if !MONODROID
using NUnit.Framework.SyntaxHelpers;
#endif
using System;
using System.Text;
using System.Threading;
using Mono.Unix;
using Mono.Unix.Android;
using Mono.Unix.Native;
#if !MONODROID
namespace NUnit.Framework.SyntaxHelpers { class Dummy {} }
#endif
namespace MonoTests.Mono.Unix {
[TestFixture]
[TestFixture, Category ("NotOnWindows")]
public class UnixSignalTest {
// helper method to create a thread waiting on a UnixSignal

View File

@@ -21,7 +21,7 @@ using Syscall = Mono.Unix.Native.Syscall;
namespace MonoTests.Mono.Unix {
[TestFixture, Category ("NotDotNet")]
[TestFixture, Category ("NotDotNet"), Category ("NotOnWindows")]
public class UnixUserTest
{
[Test]