3 using System
.Collections
.Generic
;
5 using System
.Threading
;
6 using System
.Threading
.Tasks
;
7 using System
.Reflection
;
8 using NUnitLite
.Runner
;
9 using NUnit
.Framework
.Internal
;
10 using NUnit
.Framework
.Api
;
11 using System
.Runtime
.InteropServices
;
12 using System
.Runtime
.CompilerServices
;
16 Console
.WriteLine ("hello");
21 static int step_count
, tp_pump_count
;
24 static void TPStart () {
25 var l
= new List
<Task
> ();
26 for (int i
= 0; i
< 5; ++i
) {
27 l
.Add (Task
.Run (() => {
30 l
.Add (Task
.Factory
.StartNew (() => {
32 }, TaskCreationOptions
.LongRunning
));
34 cur_task
= Task
.WhenAll (l
).ContinueWith (t
=> {
38 static bool TPPump () {
39 if (tp_pump_count
> 10) {
40 Console
.WriteLine ("Pumped the TP test 10 times and no progress <o> giving up");
41 latest_test_result
= "FAIL";
46 latest_test_result
= "PASS";
47 return !cur_task
.IsCompleted
;
52 static IAsyncResult dele_result
;
53 static void BeginSomething () {
56 static void DeleStart ()
58 dele
= new Action (BeginSomething
);
59 dele_result
= dele
.BeginInvoke (null, null);
62 static bool DelePump ()
64 if (dele_result
.IsCompleted
) {
65 dele
.EndInvoke (dele_result
);
79 static void GcStart ()
81 IFoo
[] arr
= new IFoo
[10];
82 Volatile
.Write (ref arr
[1], new Foo ());
83 for (int i
= 0; i
< 100; ++i
) {
91 return fin_count
< 100;
94 static bool timer_called
;
95 static int pump_count
;
97 static void TimerStart () {
98 Timer t
= new Timer ((_
) => {
101 t
.Change (10, Timeout
.Infinite
);
102 latest_test_result
= "EITA";
105 static bool TimerPump () {
107 if (pump_count
> 5 || timer_called
) {
108 latest_test_result
= timer_called
? "PASS" : "FAIL";
115 static int run_count
;
116 static string excludes
= "";
118 public static string Send (string key
, string val
) {
119 if (key
== "--exclude") {
120 excludes
+= val
+ ",";
122 if (key
== "start-test") {
126 if (key
== "pump-test") {
127 return PumpTest (val
) ? "IN-PROGRESS" : "DONE" ;
129 if (key
== "test-result") {
130 return latest_test_result
;
133 return "INVALID-KEY";
136 public class TestSuite
{
137 public string Name { get; set; }
138 public string File { get; set; }
141 static TestSuite
[] suites
= new TestSuite
[] {
142 new TestSuite () { Name = "mini", File = "managed/mini_tests.dll" }
,
143 new TestSuite () { Name = "binding", File = "managed/binding_tests.dll" }
,
144 new TestSuite () { Name = "corlib", File = "managed/wasm_corlib_test.dll" }
,
145 new TestSuite () { Name = "system", File = "managed/wasm_System_test.dll" }
,
146 new TestSuite () { Name = "system-core", File = "managed/wasm_System.Core_test.dll" }
,
149 static IncrementalTestRunner testRunner
;
150 static string latest_test_result
;
152 public static bool PumpTest (string name
) {
162 if (testRunner
== null)
165 bool res
= testRunner
.Step ();
167 latest_test_result
= testRunner
.Status
;
171 } catch (Exception e
) {
172 Console
.WriteLine (e
);
173 latest_test_result
= "FAIL";
178 public static void StartTest (string name
) {
179 var baseDir
= AppDomain
.CurrentDomain
.BaseDirectory
;
180 if (testRunner
!= null)
181 throw new Exception ("Test in progress");
187 if (name
== "dele") {
195 if (name
== "timer") {
200 string extra_disable
= "";
201 latest_test_result
= "IN-PROGRESS";
203 string[] args
= name
.Split (',');
204 var testsuite_name
= suites
.Where (ts
=> ts
.Name
== args
[0]).Select (ts
=> ts
.File
).FirstOrDefault ();
205 if (testsuite_name
== null)
206 throw new Exception ("NO SUITE NAMED " + args
[0]);
208 string test_name
= null;
210 for (int i
= 1; i
< args
.Length
; ++i
) {
212 if (int.TryParse (args
[i
], out r
))
215 test_name
= args
[i
];
218 testRunner
= new IncrementalTestRunner ();
219 // testRunner.PrintLabels ();
220 // if (test_name != null)
221 // testRunner.RunTest (test_name);
223 testRunner
.Exclude ("NotWasm,WASM,NotWorking,ValueAdd,CAS,InetAccess,NotWorkingRuntimeInterpreter,MultiThreaded,StackWalk,GetCallingAssembly,LargeFileSupport,MobileNotWorking,ManagedCollator," + excludes
);
224 testRunner
.Add (Assembly
.LoadFrom (baseDir
+ "/" + testsuite_name
));
225 // testRunner.RunOnly ("MonoTests.System.Threading.AutoResetEventTest.MultipleSet");
227 // This is useful if you need to skip to the middle of a huge test suite like corlib.
228 // testRunner.SkipFirst (4550);
229 testRunner
.Start (10);