Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / sgen-domain-unload.cs
1 using System;
2 using System.Collections.Generic;
3
4 public class Bar {
5         public object a, b, c;
6         
7 }
8 class Driver {
9         static void ProduceSimpleHeapWithLOS () {
10                 Console.WriteLine ("running in {0}", AppDomain.CurrentDomain);
11                 byte[] a = new byte [4 * 1000 * 1000];
12                 byte[] b = new byte [4 * 1000 * 1000];
13                 byte[] c = new byte [4 * 1000 * 1000];
14                 var lst = new List<object> ();
15
16                 Bar la, lb, lc;
17                 la = lb = lc = null;
18                 for (int i = 0; i < 1000 * 200; ++i) {
19                         var ba = new Bar ();
20                         var bb = new Bar ();
21                         var bc = new Bar ();
22                         ba.a = la;
23                         ba.b = bb;
24                         ba.c = a;
25
26                         bb.a = bc;
27                         ba.b = b;
28                         bb.c = lb;
29                         
30                         bc.a = c;
31                         bc.b = lc;
32                         bc.c = ba;
33
34                         la = ba;
35                         lb = bb;
36                         lc = bc;
37
38                         lst.Add (ba);
39                 }
40                 
41         }
42
43         static void SimpleHeapWithLOS () {
44                 ProduceSimpleHeapWithLOS ();
45         }
46
47         static void CrossDomainTest (string name, CrossAppDomainDelegate dele) {
48                 TestTimeout timeout = TestTimeout.Start (TimeSpan.FromSeconds(TestTimeout.IsStressTest ? 60 : 5));
49                 Console.WriteLine ("----Testing {0}----", name);
50                 for (int i = 0; timeout.HaveTimeLeft; ++i) {
51                         var ad = AppDomain.CreateDomain (string.Format ("domain-{0}-{1}", name, i));
52                         ad.DoCallBack (dele);
53                         AppDomain.Unload (ad);
54                 }
55         }
56
57         static void Main () {
58                 CrossDomainTest ("simple-heap-with-los", Driver.SimpleHeapWithLOS);
59         }
60 }