[CI] ignore appdomain-unload-asmload.exe on interp and full-aot
[mono.git] / mono / tests / bug-17590.cs
1 /*
2  * The string portion of this test crashes on Boehm (and there might
3  * not be much we can do about that - I haven't looked into it), and
4  * the array portions are unbearably slow, so it's only run on SGen.
5  */
6
7 using System;
8
9 class X
10 {
11         public static void Test (Action<int> allocator)
12         {
13                 for (int i = 0; i < 1000; ++i)
14                 {
15                         bool caught = false;
16                         try
17                         {
18                                 //Console.WriteLine ("allocating with " + i);
19                                 allocator (i);
20                         }
21                         catch (OutOfMemoryException)
22                         {
23                                 caught = true;
24                         }
25                         /*
26                         if (!caught)
27                         {
28                                 Console.WriteLine ("WTF?");
29                                 //Environment.Exit (1);
30                         }
31                         */
32                 }
33         }
34
35         public static void Ignore<T> (T x)
36         {
37         }
38
39         public static void ProbeArray<T> (T[] a)
40         {
41                 if (a == null)
42                         return;
43
44                 for (int i = 0; i < 1000; ++i)
45                 {
46                         a [i] = default (T);
47                         a [a.Length - i - 1] = default (T);
48                 }
49         }
50
51         public static void ProbeString (string s)
52         {
53                 for (int i = 0; i < 1000; ++i)
54                 {
55                         if (s [s.Length - i - 1] != ' ')
56                                 Environment.Exit (1);
57                 }
58         }
59
60         public static int Main ()
61         {
62                 Console.WriteLine ("byte arrays");
63                 Test (i => ProbeArray (new byte [int.MaxValue - i]));
64                 Test (i => ProbeArray (new byte [int.MaxValue - i * 100]));
65
66                 Console.WriteLine ("int arrays");
67                 Test (i => ProbeArray (new int [int.MaxValue / 4 - i]));
68                 Test (i => ProbeArray (new int [int.MaxValue / 4 - i * 100]));
69
70                 Console.WriteLine ("large int arrays");
71                 Test (i => ProbeArray (new int [int.MaxValue - i]));
72                 Test (i => ProbeArray (new int [int.MaxValue - i * 100]));
73
74                 // FIXME: This commit 4gb of memory
75                 /*
76                 Console.WriteLine ("strings");
77                 Test (i => ProbeString ("abcd".PadRight(int.MaxValue - i)));
78                 Test (i => ProbeString ("abcd".PadRight(int.MaxValue - i * 100)));
79                 */
80
81                 //Console.WriteLine ("no objects allocated - all good");
82                 return 0;
83         }
84 }