if HOST_WIN32
test-unhandled-exception-2:
else
-test-unhandled-exception-2: unhandled-exception.exe
- @echo "Testing unhandled-exception_1 ..."; $(RUNTIME) $+ 1 1> unhandled-exception_1.exe.stdout 2> unhandled-exception_1.exe.stderr; if test "x$$?" != "x1"; then exit 1; fi; \
- echo "Testing unhandled-exception_2 ..."; $(RUNTIME) $+ 2 1> unhandled-exception_2.exe.stdout 2> unhandled-exception_2.exe.stderr; if test "x$$?" != "x0"; then exit 2; fi; \
- echo "Testing unhandled-exception_3 ..."; $(RUNTIME) $+ 3 1> unhandled-exception_3.exe.stdout 2> unhandled-exception_3.exe.stderr; if test "x$$?" != "x0"; then exit 3; fi; \
- echo "Testing unhandled-exception_4 ..."; $(RUNTIME) $+ 4 1> unhandled-exception_4.exe.stdout 2> unhandled-exception_4.exe.stderr; if test "x$$?" != "x0"; then exit 4; fi; \
- echo "Testing unhandled-exception_5 ..."; $(RUNTIME) $+ 5 1> unhandled-exception_5.exe.stdout 2> unhandled-exception_5.exe.stderr; if test "x$$?" != "x255"; then exit 5; fi; \
- echo "Testing unhandled-exception_6 ..."; $(RUNTIME) $+ 6 1> unhandled-exception_6.exe.stdout 2> unhandled-exception_6.exe.stderr; if test "x$$?" != "x0"; then exit 6; fi; \
- echo "Testing unhandled-exception_7 ..."; $(RUNTIME) $+ 7 1> unhandled-exception_7.exe.stdout 2> unhandled-exception_7.exe.stderr; if test "x$$?" != "x0"; then exit 7; fi; \
- echo "Testing unhandled-exception_8 ..."; $(RUNTIME) $+ 8 1> unhandled-exception_8.exe.stdout 2> unhandled-exception_8.exe.stderr; if test "x$$?" != "x3"; then exit 8; fi
+test-unhandled-exception-2: test-unhandled-exception-2-1 test-unhandled-exception-2-2 test-unhandled-exception-2-3 test-unhandled-exception-2-4 \
+ test-unhandled-exception-2-5 test-unhandled-exception-2-6 test-unhandled-exception-2-7 test-unhandled-exception-2-8
+
+test-unhandled-exception-2-1: unhandled-exception-1.exe test-runner.exe
+ @$(RUNTIME) ./test-runner.exe --expected-exit-code 1 $<
+test-unhandled-exception-2-2: unhandled-exception-2.exe test-runner.exe
+ @$(RUNTIME) ./test-runner.exe --expected-exit-code 0 $<
+test-unhandled-exception-2-3: unhandled-exception-3.exe test-runner.exe
+ @$(RUNTIME) ./test-runner.exe --expected-exit-code 255 $<
+test-unhandled-exception-2-4: unhandled-exception-4.exe test-runner.exe
+ @$(RUNTIME) ./test-runner.exe --expected-exit-code 0 $<
+test-unhandled-exception-2-5: unhandled-exception-5.exe test-runner.exe
+ @$(RUNTIME) ./test-runner.exe --expected-exit-code 255 $<
+test-unhandled-exception-2-6: unhandled-exception-6.exe test-runner.exe
+ @$(RUNTIME) ./test-runner.exe --expected-exit-code 0 $<
+test-unhandled-exception-2-7: unhandled-exception-7.exe test-runner.exe
+ @$(RUNTIME) ./test-runner.exe --expected-exit-code 0 $<
+test-unhandled-exception-2-8: unhandled-exception-8.exe test-runner.exe
+ @$(RUNTIME) ./test-runner.exe --expected-exit-code 3 $<
endif
EXTRA_DIST += appdomain-loader.cs appdomain-tester.cs
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class CustomException : Exception
+{
+}
+
+class Driver
+{
+ /* Expected exit code: 1 */
+ static void Main (string[] args)
+ {
+ ManualResetEvent mre = new ManualResetEvent (false);
+
+ var t = new Thread (new ThreadStart (() => { try { throw new CustomException (); } finally { mre.Set (); } }));
+ t.Start ();
+
+ if (!mre.WaitOne (5000))
+ Environment.Exit (2);
+
+ t.Join ();
+
+ Environment.Exit (0);
+ }
+}
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class CustomException : Exception
+{
+}
+
+class Driver
+{
+ /* expected exit code: 0 */
+ static void Main (string[] args)
+ {
+ ManualResetEvent mre = new ManualResetEvent (false);
+
+ var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
+ var ares = a.BeginInvoke (null, null);
+
+ if (!mre.WaitOne (5000))
+ Environment.Exit (2);
+
+ try {
+ a.EndInvoke (ares);
+ Environment.Exit (4);
+ } catch (CustomException) {
+ } catch (Exception ex) {
+ Console.WriteLine (ex);
+ Environment.Exit (3);
+ }
+
+ Environment.Exit (0);
+ }
+}
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class CustomException : Exception
+{
+}
+
+class Driver
+{
+ /* expected exit code: 0 */
+ static void Main (string[] args)
+ {
+ ManualResetEvent mre = new ManualResetEvent (false);
+
+ ThreadPool.QueueUserWorkItem (_ => { try { throw new CustomException (); } finally { mre.Set (); } });
+
+ if (!mre.WaitOne (5000))
+ Environment.Exit (2);
+
+ Environment.Exit (0);
+ }
+}
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class CustomException : Exception
+{
+}
+
+class Driver
+{
+ /* expected exit code: 0 */
+ static void Main (string[] args)
+ {
+ ManualResetEvent mre = new ManualResetEvent (false);
+
+ var t = Task.Factory.StartNew (new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } }));
+
+ if (!mre.WaitOne (5000))
+ Environment.Exit (2);
+
+ try {
+ t.Wait ();
+ Environment.Exit (5);
+ } catch (AggregateException ae) {
+ if (!(ae.InnerExceptions [0] is CustomException))
+ Environment.Exit (4);
+ } catch (Exception ex) {
+ Console.WriteLine (ex);
+ Environment.Exit (3);
+ }
+
+ Environment.Exit (0);
+ }
+}
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class CustomException : Exception
+{
+}
+
+class Driver
+{
+ static ManualResetEvent mre = new ManualResetEvent (false);
+
+ class FinalizedClass
+ {
+ ~FinalizedClass ()
+ {
+ try {
+ throw new CustomException ();
+ } finally {
+ mre.Set ();
+ }
+ }
+ }
+
+ /* expected exit code: 255 */
+ static void Main (string[] args)
+ {
+ new FinalizedClass();
+
+ GC.Collect ();
+ GC.WaitForPendingFinalizers ();
+
+ if (!mre.WaitOne (5000))
+ Environment.Exit (2);
+
+ Environment.Exit (0);
+ }
+}
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class CustomException : Exception
+{
+}
+
+class CustomException2 : Exception
+{
+}
+
+class Driver
+{
+ /* expected exit code: 0 */
+ static void Main (string[] args)
+ {
+ ManualResetEvent mre = new ManualResetEvent (false);
+ ManualResetEvent mre2 = new ManualResetEvent (false);
+
+ var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
+ var ares = a.BeginInvoke (_ => { mre2.Set (); throw new CustomException2 (); }, null);
+
+ if (!mre.WaitOne (5000))
+ Environment.Exit (2);
+ if (!mre2.WaitOne (5000))
+ Environment.Exit (22);
+
+ try {
+ a.EndInvoke (ares);
+ Environment.Exit (4);
+ } catch (CustomException) {
+ } catch (Exception ex) {
+ Console.WriteLine (ex);
+ Environment.Exit (3);
+ }
+
+ Environment.Exit (0);
+ }
+}
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class CustomException : Exception
+{
+}
+
+class CustomException2 : Exception
+{
+}
+
+class CrossDomain : MarshalByRefObject
+{
+ public Action NewDelegateWithTarget ()
+ {
+ return new Action (Bar);
+ }
+
+ public Action NewDelegateWithoutTarget ()
+ {
+ return () => { throw new CustomException (); };
+ }
+
+ public void Bar ()
+ {
+ throw new CustomException ();
+ }
+}
+
+class Driver
+{
+ /* expected exit code: 0 */
+ static void Main (string[] args)
+ {
+ ManualResetEvent mre = new ManualResetEvent (false);
+
+ var cd = (CrossDomain) AppDomain.CreateDomain ("ad").CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
+
+ var a = cd.NewDelegateWithoutTarget ();
+ var ares = a.BeginInvoke (delegate { throw new CustomException2 (); }, null);
+
+ try {
+ a.EndInvoke (ares);
+ Environment.Exit (4);
+ } catch (CustomException) {
+ } catch (Exception ex) {
+ Console.WriteLine (ex);
+ Environment.Exit (3);
+ }
+
+ Environment.Exit (0);
+ }
+}
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+
+class CustomException : Exception
+{
+}
+
+class CustomException2 : Exception
+{
+}
+
+class CrossDomain : MarshalByRefObject
+{
+ public Action NewDelegateWithTarget ()
+ {
+ return new Action (Bar);
+ }
+
+ public Action NewDelegateWithoutTarget ()
+ {
+ return () => { throw new CustomException (); };
+ }
+
+ public void Bar ()
+ {
+ throw new CustomException ();
+ }
+}
+
+class Driver
+{
+ /* expected exit code: 3 */
+ static void Main (string[] args)
+ {
+ ManualResetEvent mre = new ManualResetEvent (false);
+
+ var cd = (CrossDomain) AppDomain.CreateDomain ("ad").CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
+
+ var a = cd.NewDelegateWithTarget ();
+ var ares = a.BeginInvoke (delegate { throw new CustomException2 (); }, null);
+
+ try {
+ a.EndInvoke (ares);
+ Environment.Exit (4);
+ } catch (CustomException) {
+ } catch (Exception ex) {
+ Console.WriteLine (ex);
+ Environment.Exit (3);
+ }
+
+ Environment.Exit (0);
+ }
+}
+++ /dev/null
-using System;
-using System.Diagnostics;
-using System.Threading;
-using System.Threading.Tasks;
-
-class CustomException : Exception
-{
-}
-
-class CustomException2 : Exception
-{
-}
-
-
-class CrossDomain : MarshalByRefObject
-{
- public Action NewDelegateWithTarget ()
- {
- return new Action (Bar);
- }
-
- public Action NewDelegateWithoutTarget ()
- {
- return () => { throw new CustomException (); };
- }
-
- public void Bar ()
- {
- throw new CustomException ();
- }
-}
-
-class Driver {
- static ManualResetEvent mre = new ManualResetEvent (false);
-
- static void DoTest1 ()
- {
- mre.Reset ();
-
- var t = new Thread (new ThreadStart (() => { try { throw new CustomException (); } finally { mre.Set (); } }));
- t.Start ();
-
- if (!mre.WaitOne (5000))
- Environment.Exit (2);
-
- t.Join ();
- }
-
- static void DoTest2 ()
- {
- mre.Reset ();
-
- var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
- var ares = a.BeginInvoke (null, null);
-
- if (!mre.WaitOne (5000))
- Environment.Exit (2);
-
- try {
- a.EndInvoke (ares);
- throw new Exception ();
- } catch (CustomException) {
- } catch (Exception) {
- Environment.Exit (3);
- }
- }
-
- static void DoTest3 ()
- {
- mre.Reset ();
-
- ThreadPool.QueueUserWorkItem (_ => { try { throw new CustomException (); } finally { mre.Set (); } });
-
- if (!mre.WaitOne (5000))
- Environment.Exit (2);
- }
-
- static void DoTest4 ()
- {
- mre.Reset ();
-
- var t = Task.Factory.StartNew (new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } }));
-
- if (!mre.WaitOne (5000))
- Environment.Exit (2);
-
- try {
- t.Wait ();
- throw new Exception ();
- } catch (AggregateException ae) {
- if (!(ae.InnerExceptions [0] is CustomException))
- Environment.Exit (4);
- } catch (Exception) {
- Environment.Exit (3);
- }
- }
-
- class FinalizedClass
- {
- ~FinalizedClass ()
- {
- try {
- throw new CustomException ();
- } finally {
- mre.Set ();
- }
- }
- }
-
- static void DoTest5 ()
- {
- mre.Reset ();
-
- new FinalizedClass();
-
- GC.Collect ();
- GC.WaitForPendingFinalizers ();
-
- if (!mre.WaitOne (5000))
- Environment.Exit (2);
- }
-
- static void DoTest6 ()
- {
- ManualResetEvent mre2 = new ManualResetEvent (false);
-
- mre.Reset ();
-
- var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
- var ares = a.BeginInvoke (_ => { mre2.Set (); throw new CustomException2 (); }, null);
-
- if (!mre.WaitOne (5000))
- Environment.Exit (2);
- if (!mre2.WaitOne (5000))
- Environment.Exit (22);
-
- try {
- a.EndInvoke (ares);
- throw new Exception ();
- } catch (CustomException) {
- } catch (Exception) {
- Environment.Exit (3);
- }
- }
-
- static void DoTest7 ()
- {
- var cd = (CrossDomain) AppDomain.CreateDomain ("ad").CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
-
- var a = cd.NewDelegateWithoutTarget ();
- var ares = a.BeginInvoke (delegate { throw new CustomException2 (); }, null);
-
- try {
- a.EndInvoke (ares);
- throw new Exception ();
- } catch (CustomException) {
- } catch (Exception) {
- Environment.Exit (3);
- }
- }
-
- static void DoTest8 ()
- {
- var cd = (CrossDomain) AppDomain.CreateDomain ("ad").CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
-
- var a = cd.NewDelegateWithTarget ();
- var ares = a.BeginInvoke (delegate { throw new CustomException2 (); }, null);
-
- try {
- a.EndInvoke (ares);
- throw new Exception ();
- } catch (CustomException) {
- } catch (Exception) {
- Environment.Exit (3);
- }
- }
-
- static void Main (string[] args)
- {
- switch (int.Parse (args [0])) {
- case 1: DoTest1 (); break;
- case 2: DoTest2 (); break;
- case 3: DoTest3 (); break;
- case 4: DoTest4 (); break;
- case 5: DoTest5 (); break;
- case 6: DoTest6 (); break;
- case 7: DoTest7 (); break;
- case 8: DoTest8 (); break;
- default: throw new ArgumentOutOfRangeException ();
- }
- Environment.Exit (0);
- }
-}