[interp] disable some tests that fail on CI only
[mono.git] / mono / tests / generic-special2.2.cs
1 using System;
2 using System.Reflection;
3 using System.IO;
4 using System.Collections.Generic;
5 using System.Threading;
6
7 internal class GenericType<T> {
8         [ThreadStatic]
9         internal static object static_var;
10
11         public static void AccessStaticVar ()
12         {
13                 if (static_var != null && static_var.GetType () != typeof (List<T>))
14                         throw new Exception ("Corrupted static var");
15                 GenericType<T>.static_var = new List<T> ();
16         }
17 }
18
19 public static class Program {
20         private static bool stress;
21
22         /* Create a lot of static vars */
23         private static void CreateVTables ()
24         {
25                 Type[] nullArgs = new Type[0];
26                 Assembly ass = Assembly.GetAssembly (typeof (int));
27                 foreach (Type type in ass.GetTypes ()) {
28                         try {
29                                 Type inst = typeof (GenericType<>).MakeGenericType (type);
30                                 Activator.CreateInstance (inst);
31                         } catch {
32                         }
33                 }
34         }
35
36         private static void StressStaticFieldAddr ()
37         {
38                 while (stress) {
39                         GenericType<object>.AccessStaticVar ();
40                 }
41         }
42
43         public static void Main (string[] args)
44         {
45                 Thread thread = new Thread (StressStaticFieldAddr);
46
47                 stress = true;
48                 thread.Start ();
49                 CreateVTables ();
50                 stress = false;
51
52                 thread.Join ();
53         }
54 }