1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Reflection;
using NUnitLite.Runner;
using NUnit.Framework.Internal;
using NUnit.Framework.Api;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public class Driver {
static void Main () {
Console.WriteLine ("hello");
Send ("run", "mini");
}
static int step_count, tp_pump_count;
static Task cur_task;
static void TPStart () {
var l = new List<Task> ();
for (int i = 0; i < 5; ++i) {
l.Add (Task.Run (() => {
++step_count;
}));
l.Add (Task.Factory.StartNew (() => {
++step_count;
}, TaskCreationOptions.LongRunning));
}
cur_task = Task.WhenAll (l).ContinueWith (t => {
});
}
static bool TPPump () {
if (tp_pump_count > 10) {
Console.WriteLine ("Pumped the TP test 10 times and no progress <o> giving up");
latest_test_result = "FAIL";
return false;
}
tp_pump_count++;
latest_test_result = "PASS";
return !cur_task.IsCompleted;
}
static Action dele;
static IAsyncResult dele_result;
static void BeginSomething () {
}
static void DeleStart ()
{
dele = new Action (BeginSomething);
dele_result = dele.BeginInvoke (null, null);
}
static bool DelePump ()
{
if (dele_result.IsCompleted) {
dele.EndInvoke (dele_result);
return false;
}
return true;
}
static int fin_count;
interface IFoo {}
class Foo : IFoo {
~Foo () {
++fin_count;
}
}
static void GcStart ()
{
IFoo[] arr = new IFoo [10];
Volatile.Write (ref arr [1], new Foo ());
for (int i = 0; i < 100; ++i) {
var x = new Foo ();
}
}
static bool GcPump ()
{
GC.Collect ();
return fin_count < 100;
}
static bool timer_called;
static int pump_count;
static void TimerStart () {
Timer t = new Timer ((_) => {
timer_called = true;
});
t.Change (10, Timeout.Infinite);
latest_test_result = "EITA";
}
static bool TimerPump () {
++pump_count;
if (pump_count > 5 || timer_called) {
latest_test_result = timer_called ? "PASS" : "FAIL";
return false;
}
return true;
}
static int run_count;
static string excludes = "";
public static string Send (string key, string val) {
if (key == "--exclude") {
excludes += val + ",";
}
if (key == "start-test") {
StartTest (val);
return "SUCCESS";
}
if (key == "pump-test") {
return PumpTest (val) ? "IN-PROGRESS" : "DONE" ;
}
if (key == "test-result") {
return latest_test_result;
}
return "INVALID-KEY";
}
public class TestSuite {
public string Name { get; set; }
public string File { get; set; }
}
static TestSuite[] suites = new TestSuite [] {
new TestSuite () { Name = "mini", File = "managed/mini_tests.dll" },
new TestSuite () { Name = "binding", File = "managed/binding_tests.dll" },
new TestSuite () { Name = "corlib", File = "managed/wasm_corlib_test.dll" },
new TestSuite () { Name = "System", File = "managed/wasm_System_test.dll" },
new TestSuite () { Name = "System.Core", File = "managed/wasm_System.Core_test.dll" },
};
static IncrementalTestRunner testRunner;
static string latest_test_result;
public static bool PumpTest (string name) {
if (name == "tp")
return TPPump ();
if (name == "dele")
return DelePump ();
if (name == "gc")
return GcPump ();
if (name == "timer")
return TimerPump ();
if (testRunner == null)
return false;
try {
bool res = testRunner.Step ();
if (!res) {
latest_test_result = testRunner.Status;
testRunner = null;
}
return res;
} catch (Exception e) {
Console.WriteLine (e);
latest_test_result = "FAIL";
return true;
}
}
public static void StartTest (string name) {
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
if (testRunner != null)
throw new Exception ("Test in progress");
if (name == "tp") {
TPStart ();
return;
}
if (name == "dele") {
DeleStart ();
return;
}
if (name == "gc") {
GcStart ();
return;
}
if (name == "timer") {
TimerStart ();
return;
}
string extra_disable = "";
latest_test_result = "IN-PROGRESS";
string[] args = name.Split (',');
var testsuite_name = suites.Where (ts => ts.Name == args [0]).Select (ts => ts.File).FirstOrDefault ();
if (testsuite_name == null)
throw new Exception ("NO SUITE NAMED " + args [0]);
string test_name = null;
int? range = null;
for (int i = 1; i < args.Length; ++i) {
int r;
if (int.TryParse (args [i], out r))
range = r;
else
test_name = args [i];
}
testRunner = new IncrementalTestRunner ();
// testRunner.PrintLabels ();
// if (test_name != null)
// testRunner.RunTest (test_name);
testRunner.Exclude ("NotWasm,WASM,NotWorking,CAS,InetAccess,NotWorkingRuntimeInterpreter,MultiThreaded,StackWalk,GetCallingAssembly,LargeFileSupport,MobileNotWorking,ManagedCollator," + excludes);
testRunner.Add (Assembly.LoadFrom (baseDir + "/" + testsuite_name));
// testRunner.RunOnly ("MonoTests.System.Threading.AutoResetEventTest.MultipleSet");
// This is useful if you need to skip to the middle of a huge test suite like corlib.
// testRunner.SkipFirst (4550);
testRunner.Start (10);
}
}
|