Skip to content

Commit 947524d

Browse files
author
Martin Baulig
committed
X
1 parent cfbcf6c commit 947524d

19 files changed

+239
-78
lines changed

tests/mono-native/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
mono-native-compat.csproj
2-
extra-linker-defs-*.xml
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using NUnit.Framework;
3+
using Mono;
4+
5+
namespace Mono.Native.Tests
6+
{
7+
[TestFixture]
8+
public class NativePlatformConfig
9+
{
10+
static bool ShouldUseCompat {
11+
get {
12+
#if MONO_NATIVE_COMPAT
13+
return true;
14+
#elif MONO_NATIVE_UNIFIED
15+
return false;
16+
#else
17+
Assert.Fail ("Missing `MONO_NATIVE_COMPAT` or `MONO_NATIVE_UNIFIED`");
18+
throw new NotImplementedException ();
19+
#endif
20+
}
21+
}
22+
[Test]
23+
public void PlatformType ()
24+
{
25+
var type = MonoNativePlatform.GetPlatformType ();
26+
Assert.That ((int)type, Is.GreaterThan (0), "platform type");
27+
28+
Console.Error.WriteLine ($"NATIVE PLATFORM TYPE: {type}");
29+
30+
var usingCompat = (type & MonoNativePlatformType.MONO_NATIVE_PLATFORM_TYPE_COMPAT) != 0;
31+
Assert.AreEqual (ShouldUseCompat, usingCompat, "using compatibility layer");
32+
}
33+
}
34+
}

tests/mono-native/NativePlatformTest.cs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,53 @@ namespace Mono.Native.Tests
1111
public class NativePlatformTest
1212
{
1313
[Test]
14-
public void Test ()
14+
public void PlatformType ()
1515
{
1616
var type = MonoNativePlatform.GetPlatformType ();
1717
Assert.That ((int)type, Is.GreaterThan (0), "platform type");
18-
19-
Console.Error.WriteLine ($"NATIVE PLATFORM TYPE: {type}");
20-
21-
// var usingCompat = (type & MonoNativePlatformType.MONO_NATIVE_PLATFORM_TYPE_COMPAT) != 0;
22-
// Assert.AreEqual (MonoNativeConfig.UsingCompat, usingCompat, "using compatibility layer");
2318
}
2419

2520
[Test]
2621
public void TestInitialize ()
2722
{
2823
MonoNativePlatform.Initialize ();
24+
var initialized = MonoNativePlatform.IsInitialized ();
25+
Assert.IsTrue (initialized, "MonoNativePlatform.IsInitialized()");
2926
}
3027

3128
[Test]
32-
public void MartinTest ()
29+
public void TestReflectionInitialize ()
3330
{
34-
MonoNativePlatform.Initialize ();
35-
3631
var asm = typeof (string).Assembly;
3732
var type = asm.GetType ("Mono.MonoNativePlatform");
38-
Console.Error.WriteLine ($"TEST: {type}");
33+
Assert.IsNotNull (type, "MonoNativePlatform");
3934

4035
var method = type.GetMethod ("Initialize", BindingFlags.Static | BindingFlags.Public);
36+
Assert.IsNotNull (method, "MonoNativePlatform.Initialize");
37+
38+
var method2 = type.GetMethod ("IsInitialized", BindingFlags.Static | BindingFlags.Public);
39+
Assert.IsNotNull (method2, "MonoNativePlatform.IsInitialized");
40+
4141
method.Invoke (null, null);
42-
Console.Error.WriteLine ($"CALLED INITIALIZE!");
4342

44-
var method2 = type.GetMethod ("Test", BindingFlags.Static | BindingFlags.Public);
45-
method2.Invoke (null, null);
43+
var result = (bool)method2.Invoke (null, null);
44+
Assert.IsTrue (result, "MonoNativePlatform.IsInitialized()");
45+
}
46+
47+
[Test]
48+
public void TestInternalCounter ()
49+
{
50+
MonoNativePlatform.Initialize ();
51+
52+
var asm = typeof (string).Assembly;
53+
var type = asm.GetType ("Mono.MonoNativePlatform");
54+
Assert.IsNotNull (type, "MonoNativePlatform");
55+
56+
var method = type.GetMethod ("TestInternalCounter", BindingFlags.Static | BindingFlags.NonPublic);
57+
Assert.IsNotNull (method, "MonoNativePlatform.TestInternalCounter");
58+
var result = method.Invoke (null, null);
4659

47-
Console.Error.WriteLine ($"CALLED TEST!");
60+
Assert.That (result, Is.GreaterThan (0), "MonoNativePlatform.TestInternalCounter()");
4861
}
4962
}
5063
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<linker>
3+
<assembly fullname="mscorlib">
4+
<type fullname="Mono.MonoNativePlatform" preserve="all" />
5+
<type fullname="Mono.MonoNativePlatformType" preserve="all" />
6+
</assembly>
7+
</linker>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<linker>
3+
<assembly fullname="mscorlib">
4+
<type fullname="Mono.MonoNativePlatform" preserve="all" />
5+
<type fullname="Mono.MonoNativePlatformType" preserve="all" />
6+
</assembly>
7+
</linker>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<linker>
3+
<assembly fullname="mscorlib">
4+
<type fullname="Mono.MonoNativePlatform" preserve="all" />
5+
<type fullname="Mono.MonoNativePlatformType" preserve="all" />
6+
</assembly>
7+
</linker>

tests/mono-native/mono-native.csproj.template

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,16 @@
168168
<ItemGroup>
169169
<Compile Include="Main.cs" />
170170
<Compile Include="AppDelegate.cs" />
171-
<Compile Include="NativePlatformTest.cs" />
171+
<Compile Include="NativePlatformConfig.cs" />
172172
<Compile Include="..\..\external\mono\mcs\class\corlib\Mono\MonoNativePlatform.cs">
173173
<Link>MonoNativePlatform.cs</Link>
174174
</Compile>
175175
<Compile Include="..\..\external\mono\mcs\class\corlib\Mono\MonoNativePlatformType.cs">
176176
<Link>MonoNativePlatformType.cs</Link>
177177
</Compile>
178+
<Compile Include="..\..\external\mono\mcs\class\corlib\Test\Mono\NativePlatformTest.cs">
179+
<Link>NativePlatformTest.cs</Link>
180+
</Compile>
178181
</ItemGroup>
179182
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
180183
</Project>

tests/xharness/AppRunner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ public async Task<int> RunAsync ()
467467
args.Append (" -setenv=NUNIT_AUTOEXIT=true");
468468
args.Append (" -argument=-app-arg:-enablenetwork");
469469
args.Append (" -setenv=NUNIT_ENABLE_NETWORK=true");
470+
args.Append (" -setenv=MONO_LOG_LEVEL=debug");
471+
args.Append (" -setenv=MONO_LOG_MASK=dll,asm");
470472
// detect if we are using a jenkins bot.
471473
var useXmlOutput = Harness.InJenkins;
472474
if (useXmlOutput) {

tests/xharness/Harness.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ void ConfigureIOS ()
503503

504504
foreach (var proj in IOSTestProjects) {
505505
var file = proj.Path;
506+
if (proj.MonoNativeInfo != null)
507+
file = proj.MonoNativeInfo.TemplatePath;
508+
506509
if (!File.Exists (file))
507510
throw new FileNotFoundException (file);
508511

tests/xharness/Jenkins.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ IEnumerable<RunSimulatorTask> CreateRunSimulatorTaskAsync (XBuildTask buildTask)
126126
targets = new AppRunnerTarget [] { AppRunnerTarget.Simulator_iOS32, AppRunnerTarget.Simulator_iOS64 };
127127
platforms = new TestPlatform [] { TestPlatform.iOS_Unified32, TestPlatform.iOS_Unified64 };
128128
break;
129+
case TestPlatform.iOS_TodayExtension64:
130+
targets = new AppRunnerTarget[] { AppRunnerTarget.Simulator_iOS64 };
131+
platforms = new TestPlatform[] { TestPlatform.iOS_TodayExtension64 };
132+
break;
129133
default:
130134
throw new NotImplementedException ();
131135
}
@@ -204,6 +208,22 @@ IEnumerable<TestData> GetTestData (RunTestTask test)
204208
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = false, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL" };
205209
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all,-remove-uithread-checks", Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL", Ignored = !IncludeAll };
206210
break;
211+
case "mono-native-compat":
212+
case "mono-native-unified":
213+
yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = false };
214+
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = false };
215+
216+
yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug, profiling)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = true };
217+
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug, profiling)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = true };
218+
219+
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (release)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = false, Profiling = false };
220+
221+
yield return new TestData { Variation = "Release", MTouchExtraArgs = "", Debug = false, Profiling = false };
222+
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = false, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL" };
223+
224+
yield return new TestData { Variation = "Debug (static registrar)", MTouchExtraArgs = "--registrar:static", Debug = true, Profiling = false };
225+
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL" };
226+
break;
207227
}
208228
break;
209229
case "AnyCPU":
@@ -330,6 +350,8 @@ IEnumerable<TestTask> CreateRunSimulatorTasks ()
330350
var ps = new List<Tuple<TestProject, TestPlatform, bool>> ();
331351
if (!project.SkipiOSVariation)
332352
ps.Add (new Tuple<TestProject, TestPlatform, bool> (project, TestPlatform.iOS_Unified, ignored || !IncludeiOS));
353+
if (project.MonoNativeInfo != null)
354+
ps.Add (new Tuple<TestProject, TestPlatform, bool> (project, TestPlatform.iOS_TodayExtension64, ignored || !IncludeiOS));
333355
if (!project.SkiptvOSVariation)
334356
ps.Add (new Tuple<TestProject, TestPlatform, bool> (project.AsTvOSProject (), TestPlatform.tvOS, ignored || !IncludetvOS));
335357
if (!project.SkipwatchOSVariation)

0 commit comments

Comments
 (0)