Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -5,7 +5,8 @@ include ../../build/rules.make
LIBRARY = Mono.Posix.dll
# Don't warn about [Obsolete] members, as there are now *lots* of [Obsolete]
# members, generating volumes of output.
LIB_MCS_FLAGS = /unsafe /r:$(corlib) /r:System.dll /nowarn:0618,612
LIB_REFS = System
LIB_MCS_FLAGS = /unsafe /r:$(corlib) /nowarn:0618,612
TEST_MCS_FLAGS = /r:Mono.Posix.dll /r:System.dll /nowarn:0219,0618
LIBRARY_COMPILE = $(BOOT_COMPILE)

View File

@@ -6,5 +6,6 @@ Mono.Unix/UnixMarshalTest.cs
Mono.Unix/UnixPathTest.cs
Mono.Unix/UnixSignalTest.cs
Mono.Unix/UnixUserTest.cs
Mono.Unix.Android/TestHelper.cs
Mono.Unix.Native/RealTimeSignumTests.cs
Mono.Unix.Native/StdlibTest.cs

View File

@@ -34,7 +34,6 @@ using System.Collections;
using System.Runtime.Remoting.Messaging;
using System.IO;
using System.Runtime.Remoting.Channels;
using Mono.Posix;
namespace Mono.Remoting.Channels.Unix
{

View File

@@ -17,10 +17,10 @@ namespace Mono.Unix.Native {
//
// Non-generated exports
//
#if !MONODROID
[DllImport (LIB, EntryPoint="Mono_Posix_FromRealTimeSignum")]
private static extern int FromRealTimeSignum (Int32 offset, out Int32 rval);
#endif
// convert a realtime signal to os signal
public static int FromRealTimeSignum (RealTimeSignum sig)
{

View File

@@ -33,6 +33,12 @@ using System.Net.Sockets;
namespace Mono.Unix
{
internal struct PeerCredData {
public int pid;
public int uid;
public int gid;
}
public class PeerCred
{
/* Make sure this doesn't clash with anything in
@@ -40,14 +46,14 @@ namespace Mono.Unix
* runtime
*/
private const int so_peercred=10001;
private Mono.Posix.PeerCredData data;
private PeerCredData data;
public PeerCred (Socket sock) {
if (sock.AddressFamily != AddressFamily.Unix) {
throw new ArgumentException ("Only Unix sockets are supported", "sock");
}
data = (Mono.Posix.PeerCredData)
data = (PeerCredData)
sock.GetSocketOption (SocketOptionLevel.Socket, (SocketOptionName)so_peercred);
}

View File

@@ -176,6 +176,10 @@ namespace Mono.Unix {
else if (typeof(UnicodeEncoding).IsAssignableFrom (encodingType)) {
len = GetInt16BufferLength (p);
}
// Encodings that will always end with a 0x00000000 32-bit word
else if (typeof(UTF32Encoding).IsAssignableFrom (encodingType)) {
len = GetInt32BufferLength (p);
}
// Some non-public encoding, such as Latin1 or a DBCS charset.
// Look for a sequence of encoding.GetMaxByteCount() bytes that are all
// 0, which should be the terminating null.

View File

@@ -0,0 +1,12 @@
namespace Mono.Unix.Android
{
// Another version of this class is used by the Xamarin.Android test suite
// It is here to keep the test code #ifdef free as much as possible
public class TestHelper
{
public static bool CanUseRealTimeSignals ()
{
return true;
}
}
}

View File

@@ -8,11 +8,14 @@
//
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;
namespace MonoTests.Mono.Unix.Native {
@@ -25,6 +28,8 @@ namespace MonoTests.Mono.Unix.Native {
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void TestRealTimeOutOfRange ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts = new RealTimeSignum (int.MaxValue);
}
@@ -32,12 +37,16 @@ namespace MonoTests.Mono.Unix.Native {
[ExpectedException (typeof (ArgumentOutOfRangeException))]
public void TestRealTimeSignumNegativeOffset ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts1 = new RealTimeSignum (-1);
}
[Test]
public void TestRTSignalEquality ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts1 = new RealTimeSignum (0);
RealTimeSignum rts2 = new RealTimeSignum (0);
Assert.That (rts1 == rts2, Is.True);
@@ -47,6 +56,8 @@ namespace MonoTests.Mono.Unix.Native {
[Test]
public void TestRTSignalInequality ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts1 = new RealTimeSignum (0);
RealTimeSignum rts2 = new RealTimeSignum (1);
Assert.That (rts1 == rts2, Is.False);
@@ -56,6 +67,8 @@ namespace MonoTests.Mono.Unix.Native {
[Test]
public void TestRTSignalGetHashCodeEquality ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts1 = new RealTimeSignum (0);
RealTimeSignum rts2 = new RealTimeSignum (0);
Assert.That (rts1.GetHashCode (), Is.EqualTo(rts2.GetHashCode ()));
@@ -64,6 +77,8 @@ namespace MonoTests.Mono.Unix.Native {
[Test]
public void TestRTSignalGetHashCodeInequality ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts1 = new RealTimeSignum (0);
RealTimeSignum rts2 = new RealTimeSignum (1);
Assert.That (rts1.GetHashCode (), Is.Not.EqualTo(rts2.GetHashCode ()));
@@ -72,6 +87,8 @@ namespace MonoTests.Mono.Unix.Native {
[Test]
public void TestIsRTSignalPropertyForRTSignum ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
UnixSignal signal1 = new UnixSignal(new RealTimeSignum (0));
Assert.That (signal1.IsRealTimeSignal, Is.True);
}
@@ -79,6 +96,8 @@ namespace MonoTests.Mono.Unix.Native {
[Test]
public void TestIsRTSignalPropertyForSignum ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
UnixSignal signal1 = new UnixSignal (Signum.SIGSEGV);
Assert.That (signal1.IsRealTimeSignal, Is.False);
}

View 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);
}
}
@@ -856,7 +857,8 @@ namespace MonoTests.System.IO
[ExpectedException (typeof (NotSupportedException))]
public void SetLengthWithClosedBaseStream ()
{
StdioFileStream fs = new StdioFileStream ("temp", FileMode.Create);
string path = TempFolder + Path.DirectorySeparatorChar + "temp";
StdioFileStream fs = new StdioFileStream (path, FileMode.Create);
BufferedStream bs = new BufferedStream (fs);
fs.Close ();

View File

@@ -25,6 +25,7 @@ namespace MonoTests.Mono.Unix {
public class UnixGroupTest
{
[Test]
[Category ("AndroidNotWorking")] // API 21 conditionally has setgrent in the NDK headers, but bionic doesn't export it
public void ListAllGroups_ToString ()
{
try {
@@ -41,6 +42,7 @@ namespace MonoTests.Mono.Unix {
}
[Test]
[Category ("AndroidNotWorking")] // API 21 conditionally has setgrent in the NDK headers, but bionic doesn't export it
public void ReentrantConstructors ()
{
var seen = new Dictionary<string, object> ();
@@ -65,6 +67,7 @@ namespace MonoTests.Mono.Unix {
}
[Test]
[Category ("AndroidNotWorking")] // API 21 conditionally has setgrent in the NDK headers, but bionic doesn't export it
public void NonReentrantSyscalls ()
{
var seen = new Dictionary<string, object> ();
@@ -95,6 +98,7 @@ namespace MonoTests.Mono.Unix {
}
[Test]
[Category ("AndroidNotWorking")] // API 21 conditionally has getgrnam_r in the NDK headers, but bionic doesn't export it
public void InvalidGroups_Constructor_Name ()
{
string[] badGroups = new string[]{"i'm bad", "so am i", "does-not-exist"};

View File

@@ -8,6 +8,7 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
@@ -87,6 +88,69 @@ namespace MonoTests.Mono.Unix {
string s = UnixMarshal.PtrToString (p);
UnixMarshal.FreeHeap (p);
}
[Test]
public void TestUtf32PtrToString ()
{
var utf32NativeEndianNoBom = new UTF32Encoding(
bigEndian: !BitConverter.IsLittleEndian,
byteOrderMark: false,
throwOnInvalidCharacters: true
);
// assemble a buffer that contains:
// 1. eight garbage bytes
// 2. the native-endian UTF-32 string "Hello, World" without BOM
// 3. four 0 bytes (as a C wide string terminator)
// 4. the native-endian UTF-32 string "broken" without BOM
// 5. eight 0 bytes
// 6. four garbage bytes
var buf = new List<byte>();
for (int i = 0; i < 2; ++i) {
buf.Add((byte)0x12);
buf.Add((byte)0x34);
buf.Add((byte)0x56);
buf.Add((byte)0x78);
}
buf.AddRange(utf32NativeEndianNoBom.GetBytes("Hello, World"));
for (int i = 0; i < 4; ++i) {
buf.Add((byte)0x00);
}
buf.AddRange(utf32NativeEndianNoBom.GetBytes("broken"));
for (int i = 0; i < 8; ++i) {
buf.Add((byte)0x00);
}
buf.Add((byte)0x12);
buf.Add((byte)0x34);
buf.Add((byte)0x56);
buf.Add((byte)0x78);
// get the array version of this
var bufArr = buf.ToArray();
// allocate a buffer that will contain this string
IntPtr bufPtr = UnixMarshal.AllocHeap(bufArr.Length);
string returned;
try
{
// copy it in
Marshal.Copy(bufArr, 0, bufPtr, bufArr.Length);
// try getting it back
returned = UnixMarshal.PtrToString(bufPtr + 8, utf32NativeEndianNoBom);
}
finally
{
UnixMarshal.FreeHeap(bufPtr);
}
Assert.AreEqual("Hello, World", returned);
}
}
}

View File

@@ -37,7 +37,7 @@ namespace MonoTests.Mono.Unix
Assert.AreEqual ("one", path);
path = UnixPath.Combine (current, "one");
expected = current + DSC + "one";
expected = (current == "/" ? String.Empty : current) + DSC + "one";
Assert.AreEqual (expected, path);
path = UnixPath.Combine ("one", current);

View File

@@ -8,15 +8,18 @@
//
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]
@@ -125,6 +128,8 @@ namespace MonoTests.Mono.Unix {
[Category ("NotOnMac")]
public void TestRealTimeCstor ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts = new RealTimeSignum (0);
using (UnixSignal s = new UnixSignal (rts))
{
@@ -138,6 +143,8 @@ namespace MonoTests.Mono.Unix {
[Category ("NotOnMac")]
public void TestSignumPropertyThrows ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
UnixSignal signal1 = new UnixSignal (new RealTimeSignum (0));
Signum s = signal1.Signum;
}
@@ -146,6 +153,8 @@ namespace MonoTests.Mono.Unix {
[Category ("NotOnMac")]
public void TestRealTimeSignumProperty ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts = new RealTimeSignum (0);
UnixSignal signal1 = new UnixSignal (rts);
Assert.That (signal1.RealTimeSignum, Is.EqualTo (rts));
@@ -156,6 +165,8 @@ namespace MonoTests.Mono.Unix {
[Category ("NotOnMac")]
public void TestRealTimePropertyThrows ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
UnixSignal signal1 = new UnixSignal (Signum.SIGSEGV);
RealTimeSignum s = signal1.RealTimeSignum;
}
@@ -164,6 +175,8 @@ namespace MonoTests.Mono.Unix {
[Category ("NotOnMac")]
public void TestRaiseRTMINSignal ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
RealTimeSignum rts = new RealTimeSignum (0);
using (UnixSignal signal = new UnixSignal (rts))
{
@@ -178,6 +191,8 @@ namespace MonoTests.Mono.Unix {
[Category ("NotOnMac")]
public void TestRaiseRTMINPlusOneSignal ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
/*this number is a guestimate, but it's ok*/
for (int i = 1; i < 10; ++i) {
RealTimeSignum rts = new RealTimeSignum (i);
@@ -203,6 +218,8 @@ namespace MonoTests.Mono.Unix {
[Category ("NotOnMac")]
public void TestCanRegisterRTSignalMultipleTimes ()
{
if (!TestHelper.CanUseRealTimeSignals ())
return;
/*this number is a guestimate, but it's ok*/
for (int i = 1; i < 10; ++i) {
RealTimeSignum rts = new RealTimeSignum (i);
@@ -375,6 +392,7 @@ namespace MonoTests.Mono.Unix {
}
[Test]
[Category ("AndroidNotWorking")] // Android 4.4.4 doesn't have signal(2)
public void TestSignalActionInteraction ()
{
using (UnixSignal a = new UnixSignal (Signum.SIGINT)) {

View File

@@ -25,6 +25,7 @@ namespace MonoTests.Mono.Unix {
public class UnixUserTest
{
[Test]
[Category ("AndroidNotWorking")] // setpwent is missing from bionic
public void ListAllUsers_ToString ()
{
try {
@@ -80,6 +81,7 @@ namespace MonoTests.Mono.Unix {
[Test]
[Category ("NotOnMac")]
[Category ("AndroidNotWorking")] // setpwent is missing from bionic
public void NonReentrantSyscalls ()
{
ArrayList user_ids = new ArrayList (4);
@@ -119,6 +121,7 @@ namespace MonoTests.Mono.Unix {
}
[Test]
[Category ("AndroidNotWorking")] // API 21 has getpwnam_r in the NDK headers, but bionic doesn't export it
public void InvalidUsers_Constructor_Name ()
{
string[] badUsers = new string[]{"i'm bad", "so am i", "does-not-exist"};