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 public static string Send (string key
, string val
) {
117 if (key
== "start-test") {
121 if (key
== "pump-test") {
122 return PumpTest (val
) ? "IN-PROGRESS" : "DONE" ;
124 if (key
== "test-result") {
125 return latest_test_result
;
128 return "INVALID-KEY";
131 public class TestSuite
{
132 public string Name { get; set; }
133 public string File { get; set; }
136 static TestSuite
[] suites
= new TestSuite
[] {
137 new TestSuite () { Name = "mini", File = "managed/mini_tests.dll" }
,
138 new TestSuite () { Name = "binding", File = "managed/binding_tests.dll" }
,
139 new TestSuite () { Name = "corlib", File = "managed/wasm_corlib_test.dll" }
,
140 new TestSuite () { Name = "system", File = "managed/wasm_System_test.dll" }
,
141 new TestSuite () { Name = "system-core", File = "managed/wasm_System.Core_test.dll" }
,
144 static IncrementalTestRunner testRunner
;
145 static string latest_test_result
;
147 public static bool PumpTest (string name
) {
157 if (testRunner
== null)
160 bool res
= testRunner
.Step ();
162 latest_test_result
= testRunner
.Status
;
166 } catch (Exception e
) {
167 Console
.WriteLine (e
);
168 latest_test_result
= "FAIL";
173 public static void StartTest (string name
) {
174 var baseDir
= AppDomain
.CurrentDomain
.BaseDirectory
;
175 if (testRunner
!= null)
176 throw new Exception ("Test in progress");
182 if (name
== "dele") {
190 if (name
== "timer") {
195 string extra_disable
= "";
196 latest_test_result
= "IN-PROGRESS";
198 string[] args
= name
.Split (',');
199 var testsuite_name
= suites
.Where (ts
=> ts
.Name
== args
[0]).Select (ts
=> ts
.File
).FirstOrDefault ();
200 if (testsuite_name
== null)
201 throw new Exception ("NO SUITE NAMED " + args
[0]);
203 string test_name
= null;
205 for (int i
= 1; i
< args
.Length
; ++i
) {
207 if (int.TryParse (args
[i
], out r
))
210 test_name
= args
[i
];
213 testRunner
= new IncrementalTestRunner ();
214 // testRunner.PrintLabels ();
215 // if (test_name != null)
216 // testRunner.RunTest (test_name);
218 testRunner
.Exclude ("NotWasm,WASM,NotWorking,ValueAdd,CAS,InetAccess,NotWorkingRuntimeInterpreter,MultiThreaded");
219 testRunner
.Add (Assembly
.LoadFrom (baseDir
+ "/" + testsuite_name
));
220 // testRunner.RunOnly ("MonoTests.System.Threading.AutoResetEventTest.MultipleSet");
222 // This is useful if you need to skip to the middle of a huge test suite like corlib.
223 // testRunner.SkipFirst (4550);
224 testRunner
.Start (10);