Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)../Directory.Build.props" />
<Import Project="$(MSBuildThisFileDirectory)../eng/Versions.props" />
<PropertyGroup>
<RootTestsDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RootTestsDirectory>
</PropertyGroup>
</Project>
10 changes: 5 additions & 5 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ build-all:
$(MAKE) build -C dotnet/UnitTests
$(MAKE) build -C rgen
$(MAKE) build -C xtro-sharpie
$(MAKE) build-all -C "linker/ios/dont link/dotnet"
$(MAKE) build-all -C "linker/ios/link all/dotnet"
$(MAKE) build-all -C "linker/ios/link sdk/dotnet"
$(MAKE) build-all -C "linker/ios/trimmode copy/dotnet"
$(MAKE) build-all -C "linker/ios/trimmode link/dotnet"
$(MAKE) build-all -C "linker/dont link/dotnet"
$(MAKE) build-all -C "linker/link all/dotnet"
$(MAKE) build-all -C "linker/link sdk/dotnet"
$(MAKE) build-all -C "linker/trimmode copy/dotnet"
$(MAKE) build-all -C "linker/trimmode link/dotnet"
$(MAKE) build-all -C fsharp/dotnet
$(MAKE) build-all -C interdependent-binding-projects/dotnet
$(MAKE) build-all -C introspection/dotnet
Expand Down
16 changes: 9 additions & 7 deletions tests/common/shared-dotnet-test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,31 @@ include $(TOP)/mk/colors.mk

# this file is meant to be included from tests/<test suite>/dotnet/Makefile

TESTNAME:=$(notdir $(shell dirname "$(CURDIR)"))

build-%:
@echo "Building for $*"
@echo "Building '$(TESTNAME)' for $*"
$(Q) $(MAKE) -C $* build

build-all: $(foreach platform,$(DOTNET_PLATFORMS),build-$(platform))
@echo "Build completed"
@echo "Build of '$(TESTNAME)' completed"

build-desktop: $(foreach platform,$(DOTNET_DESKTOP_PLATFORMS),build-$(platform))
@echo "Build completed"
@echo "Build of '$(TESTNAME)' for desktop platforms completed"

run-%:
@echo "Running for $*"
@echo "Running '$(TESTNAME)' for $*"
$(Q) $(MAKE) -C $* run

run-all: $(foreach platform,$(DOTNET_DESKTOP_PLATFORMS),run-$(platform))
@echo "Run complete"
@echo "Run of '$(TESTNAME)' complete"

remote-%:
@echo "Running remotely for $*"
@echo "Running '$(TESTNAME)' remotely for $*"
$(Q) $(MAKE) -C $* run-remote

run-remote-all: $(foreach platform,$(DOTNET_DESKTOP_PLATFORMS),remote-$(platform))
@echo "Run complete"
@echo "Run of '$(TESTNAME)' complete"

reload:
$(Q) $(MAKE) -C $(TOP)/tests/dotnet reload
2 changes: 1 addition & 1 deletion tests/linker/BaseOptimizeGeneratedCodeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void SetupBlockPerfTest ()
//Console.WriteLine ("Speedup: {0}x", unoptimizedWatch.ElapsedTicks / (double) optimizedWatch.ElapsedTicks);
// My testing found a 12-16x speedup on device and a 15-20x speedup in the simulator/desktop.
// Setting to 6 to have a margin for random stuff happening, but this may still have to be adjusted.
#if NET && __TVOS__
#if __TVOS__
// Our optimization is correct, but the test case runs into https://github.com/dotnet/runtime/issues/58939 which overpowers most of our optimization gains.
var speedup = 1.2; // Seems to be around 1.4/1.5, so let's see if 1.2 is consistently passing.
#else
Expand Down
66 changes: 0 additions & 66 deletions tests/linker/CommonDontLinkTest.cs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/linker/CommonLinkAllTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ public void TypeConverter_BuiltIn ()
Assert.NotNull (TypeDescriptor.GetConverter (new BuiltInConverter ()), "BuiltInConverter");

string name = (typeof (BuiltInConverter).GetCustomAttributes (false) [0] as TypeConverterAttribute).ConverterTypeName;
#if NET
var typename = $"System.ComponentModel.BooleanConverter, System.ComponentModel.TypeConverter, Version={typeof (int).Assembly.GetName ().Version}, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
#else
var typename = "System.ComponentModel.BooleanConverter, System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e";
#endif
Assert.That (name, Is.EqualTo (typename), "ConverterTypeName");
}

Expand All @@ -91,11 +87,7 @@ public void TypeConverter_Custom ()
Assert.NotNull (TypeDescriptor.GetConverter (new TypeDescriptorTest ()), "TypeDescriptorTest");

string name = (typeof (TypeDescriptorTest).GetCustomAttributes (false) [0] as TypeConverterAttribute).ConverterTypeName;
#if NET
var typename = "LinkAll.CustomConverter, link all, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
#else
var typename = "LinkAll.CustomConverter, link all, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null";
#endif
Assert.That (name, Is.EqualTo (typename), "ConverterTypeName");
}

Expand Down
75 changes: 69 additions & 6 deletions tests/linker/CommonLinkAnyTest.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if NET
using System.Security.Cryptography;
using System.Text.Json;
#endif
using System.Threading;
using System.Threading.Tasks;

using Foundation;
using ObjCRuntime;

using NUnit.Framework;

using MonoTests.System.Net.Http;

namespace LinkAnyTest {
// This test is included in both the LinkAll and LinkSdk projects for both iOS and macOS.
[TestFixture]
Expand Down Expand Up @@ -46,15 +52,13 @@ public static void Bug7114 ([CallerFilePath] string filePath = null)
Assert.IsNotNull (filePath, "CallerFilePath");
}

#if NET
[Test]
public void AppContextGetData ()
{
// https://github.com/dotnet/runtime/issues/50290
Assert.IsNotNull (AppContext.GetData ("APP_PATHS"), "APP_PATHS");
Assert.IsNotNull (AppContext.GetData ("PINVOKE_OVERRIDE"), "PINVOKE_OVERRIDE");
}
#endif

[Test]
public void BackingFieldInGenericType ()
Expand All @@ -68,7 +72,6 @@ public void BackingFieldInGenericType ()
GC.KeepAlive (view.HeightAnchor);
}

#if NET
[Test]
public void JsonSerializer_Serialize ()
{
Expand All @@ -88,6 +91,66 @@ public void JsonSerializer_Deserialize ()
var b = JsonSerializer.Deserialize<int []> ("[42,3,14,15]");
CollectionAssert.AreEqual (new int [] { 42, 3, 14, 15 }, b, "deserialized array");
}
#endif

[Test]
public void AES ()
{
Assert.NotNull (Aes.Create (), "AES");
}

static bool waited;
static bool requestError;
static HttpStatusCode statusCode;

void TimedWait (Task task)
{
try {
var rv = task.Wait (TimeSpan.FromMinutes (1));
if (rv)
return;
} catch (AggregateException ae) {
throw ae.InnerExceptions [0];
}

TestRuntime.IgnoreInCI ("This test times out randomly in CI due to bad network.");
Assert.Fail ("Test timed out");
}

// http://blogs.msdn.com/b/csharpfaq/archive/2012/06/26/understanding-a-simple-async-program.aspx
// ref: https://bugzilla.xamarin.com/show_bug.cgi?id=7114
static async Task GetWebPageAsync ()
{
// do not use GetStringAsync, we are going to miss useful data, such as the result code
using (var client = new HttpClient ()) {
HttpResponseMessage response = await client.GetAsync (NetworkResources.MicrosoftUrl);
if (!response.IsSuccessStatusCode) {
requestError = true;
statusCode = response.StatusCode;
} else {
string content = await response.Content.ReadAsStringAsync ();
waited = true;
bool success = !String.IsNullOrEmpty (content);
Assert.IsTrue (success, $"received {content.Length} bytes");
}
}
}

[Test]
public void GetWebPageAsyncTest ()
{
var current_sc = SynchronizationContext.Current;
try {
// we do not want the async code to get back to the AppKit thread, hanging the process
SynchronizationContext.SetSynchronizationContext (null);
TimedWait (GetWebPageAsync ());
if (requestError) {
Assert.Inconclusive ($"Test cannot be trusted. Issues performing the request. Status code '{statusCode}'");
} else {
Assert.IsTrue (waited, "async/await worked");
}
} finally {
SynchronizationContext.SetSynchronizationContext (current_sc);
}
}
}
}
10 changes: 10 additions & 0 deletions tests/linker/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TOP = ../..

include $(TOP)/Make.config

build-all:
$(Q) $(MAKE) build-all -C "dont link/dotnet"
$(Q) $(MAKE) build-all -C "link all/dotnet"
$(Q) $(MAKE) build-all -C "link sdk/dotnet"
$(Q) $(MAKE) build-all -C "trimmode copy/dotnet"
$(Q) $(MAKE) build-all -C "trimmode link/dotnet"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,14 @@ public class CalendarTest {
public void UmAlQura ()
{
var ci = CultureInfo.GetCultureInfo ("ar");
#if NET // https://github.com/dotnet/runtime/issues/50859
Assert.That (ci.Calendar.ToString (), Is.EqualTo ("System.Globalization.GregorianCalendar"), "Calendar");
#else
Assert.That (ci.Calendar.ToString (), Is.EqualTo ("System.Globalization.UmAlQuraCalendar"), "Calendar");
#endif
}

[Test]
public void Hijri ()
{
var ci = CultureInfo.GetCultureInfo ("ps");
#if NET // https://github.com/dotnet/runtime/issues/50859
Assert.That (ci.Calendar.ToString (), Is.EqualTo ("System.Globalization.PersianCalendar"), "Calendar");
#else
Assert.That (ci.Calendar.ToString (), Is.EqualTo ("System.Globalization.HijriCalendar"), "Calendar");
#endif
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@
using NUnit.Framework;

namespace DontLink {

#if !NET
[FileIOPermission (SecurityAction.LinkDemand, AllLocalFiles = FileIOPermissionAccess.AllAccess)]
public class SecurityDeclarationDecoratedUserCode {

[FileIOPermission (SecurityAction.Assert, AllLocalFiles = FileIOPermissionAccess.NoAccess)]
static public bool Check ()
{
return true;
}
}
#endif

[TestFixture]
public class DontLinkRegressionTests {

Expand All @@ -61,16 +48,6 @@ public void RemovedAttributes ()
Assert.NotNull (Type.GetType ("ObjCRuntime.ThreadSafeAttribute, " + fullname), "ThreadSafeAttribute");
}

[Test]
#if NET
[Ignore ("MulticastDelegate.BeginInvoke isn't supported in .NET (https://github.com/dotnet/runtime/issues/16312)")]
#endif
public void Bug5354 ()
{
Action<string> testAction = (string s) => { s.ToString (); };
testAction.BeginInvoke ("Teszt", null, null);
}

#if !__MACOS__
[Test]
public void Autorelease ()
Expand All @@ -88,19 +65,6 @@ public void Autorelease ()
}
#endif // !__MACOS__

#if !NET
[Test]
public void SecurityDeclaration ()
{
// note: security declarations != custom attributes
// we ensure that we can create the type / call the code
Assert.True (SecurityDeclarationDecoratedUserCode.Check (), "call");
// we ensure that both the permission and the flag are part of the final (non-linked) binary
Assert.NotNull (Type.GetType ("System.Security.Permissions.FileIOPermissionAttribute, mscorlib"), "FileIOPermissionAttribute");
Assert.NotNull (Type.GetType ("System.Security.Permissions.FileIOPermissionAccess, mscorlib"), "FileIOPermissionAccess");
}
#endif

[Test]
public void DefaultEncoding ()
{
Expand Down Expand Up @@ -152,11 +116,7 @@ public void ProcessStart_NotSupported ()
}

var all_properties = type.GetProperties ();
var notsupported_properties = new string [] { "StandardError", "StandardInput", "StandardOutput",
#if !NET
"StartInfo"
#endif
};
var notsupported_properties = new string [] { "StandardError", "StandardInput", "StandardOutput", };
foreach (var notsupported_property in notsupported_properties) {
foreach (var property in all_properties.Where ((v) => v.Name == notsupported_property)) {
if (property.GetGetMethod () is not null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TOP=../../../../..
TOP=../../../..
include $(TOP)/tests/common/shared-dotnet-test.mk
Loading
Loading