if HOST_WIN32
test-unhandled-exception-2:
else
-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 --testsuite-name $@ --expected-exit-code 1 $<
-test-unhandled-exception-2-2: unhandled-exception-2.exe test-runner.exe
- @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 0 $<
-test-unhandled-exception-2-3: unhandled-exception-3.exe test-runner.exe
- @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 255 $<
-test-unhandled-exception-2-4: unhandled-exception-4.exe test-runner.exe
- @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 0 $<
-test-unhandled-exception-2-5: unhandled-exception-5.exe test-runner.exe
- @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 255 $<
-test-unhandled-exception-2-6: unhandled-exception-6.exe test-runner.exe
- @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 255 $<
-test-unhandled-exception-2-7: unhandled-exception-7.exe test-runner.exe
- @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 255 $<
-test-unhandled-exception-2-8: unhandled-exception-8.exe test-runner.exe
- @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 3 $<
+
+# tests that expect a 1 exit code
+UNHANDLED_EXCEPTION_1_TESTS = \
+ unhandled-exception-1.exe
+
+# tests that expect a 255 exit code
+UNHANDLED_EXCEPTION_255_TESTS = \
+ unhandled-exception-2.exe \
+ unhandled-exception-3.exe \
+ unhandled-exception-4.exe \
+ unhandled-exception-5.exe \
+ unhandled-exception-6.exe \
+ unhandled-exception-7.exe
+
+test-unhandled-exception-2: $(UNHANDLED_EXCEPTION_1_TESTS) $(UNHANDLED_EXCEPTION_255_TESTS)
+ $(MAKE) test-unhandled-exception-2-1-with-managed-handler
+ $(MAKE) test-unhandled-exception-2-1-without-managed-handler
+ $(MAKE) test-unhandled-exception-2-255-with-managed-handler
+ $(MAKE) test-unhandled-exception-2-255-without-managed-handler
+
+test-unhandled-exception-2-1-with-managed-handler: $(UNHANDLED_EXCEPTION_1_TESTS) test-runner.exe
+ $(RUNTIME) ./test-runner.exe -j a --testsuite-name $@ --expected-exit-code 1 $(UNHANDLED_EXCEPTION_1_TESTS)
+test-unhandled-exception-2-1-without-managed-handler: $(UNHANDLED_EXCEPTION_1_TESTS) test-runner.exe
+ TEST_UNHANDLED_EXCEPTION_HANDLER=1 $(RUNTIME) ./test-runner.exe -j a --testsuite-name $@ --expected-exit-code 1 $(UNHANDLED_EXCEPTION_1_TESTS)
+test-unhandled-exception-2-255-with-managed-handler: $(UNHANDLED_EXCEPTION_255_TESTS) test-runner.exe
+ $(RUNTIME) ./test-runner.exe -j a --testsuite-name $@ --expected-exit-code 255 $(UNHANDLED_EXCEPTION_255_TESTS)
+test-unhandled-exception-2-255-without-managed-handler: $(UNHANDLED_EXCEPTION_255_TESTS) test-runner.exe
+ TEST_UNHANDLED_EXCEPTION_HANDLER=1 $(RUNTIME) ./test-runner.exe -j a --testsuite-name $@ --expected-exit-code 255 $(UNHANDLED_EXCEPTION_255_TESTS)
+
endif
EXTRA_DIST += appdomain-loader.cs appdomain-tester.cs
/* Expected exit code: 1 */
static void Main (string[] args)
{
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
ManualResetEvent mre = new ManualResetEvent (false);
var t = new Thread (new ThreadStart (() => { try { throw new CustomException (); } finally { mre.Set (); } }));
if (!mre.WaitOne (5000))
Environment.Exit (2);
- t.Join ();
+ /* Give a chance to the thread to finish executing the exception unwinding
+ * after the finally, before we exit with status 0 on the current thread */
+ Thread.Sleep (1000);
Environment.Exit (0);
}
class Driver
{
- /* expected exit code: 0 */
+ /* expected exit code: 255 */
static void Main (string[] args)
{
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
ManualResetEvent mre = new ManualResetEvent (false);
var a = new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } });
a.EndInvoke (ares);
Environment.Exit (4);
} catch (CustomException) {
+ /* expected behaviour */
+ Environment.Exit (255);
} catch (Exception ex) {
Console.WriteLine (ex);
Environment.Exit (3);
}
- Environment.Exit (0);
+ Environment.Exit (5);
}
}
class Driver
{
- /* expected exit code: 0 */
+ /* expected exit code: 255 */
static void Main (string[] args)
{
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
ManualResetEvent mre = new ManualResetEvent (false);
ThreadPool.QueueUserWorkItem (_ => { try { throw new CustomException (); } finally { mre.Set (); } });
if (!mre.WaitOne (5000))
Environment.Exit (2);
- /* Give a chance to the threadpool thread to finish executing the exception
- * unwinding after the finally, before we exit with status 0 on the current thread */
+ /* Give a chance to the threadpool thread to finish executing the exception unwinding
+ * after the finally, before we exit with status 0 on the current thread */
Thread.Sleep (1000);
Environment.Exit (0);
class Driver
{
- /* expected exit code: 0 */
+ /* expected exit code: 255 */
static void Main (string[] args)
{
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
ManualResetEvent mre = new ManualResetEvent (false);
var t = Task.Factory.StartNew (new Action (() => { try { throw new CustomException (); } finally { mre.Set (); } }));
t.Wait ();
Environment.Exit (5);
} catch (AggregateException ae) {
- if (!(ae.InnerExceptions [0] is CustomException))
- Environment.Exit (4);
+ Console.WriteLine (ae);
+ if (ae.InnerExceptions [0] is CustomException) {
+ /* expected behaviour */
+ Environment.Exit (255);
+ }
} catch (Exception ex) {
Console.WriteLine (ex);
Environment.Exit (3);
}
- Environment.Exit (0);
+ Environment.Exit (6);
}
}
/* expected exit code: 255 */
static void Main (string[] args)
{
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
new FinalizedClass();
GC.Collect ();
if (!mre.WaitOne (5000))
Environment.Exit (2);
+ /* Give a chance to the finalizer thread to finish executing the exception unwinding
+ * after the finally, before we exit with status 0 on the current thread */
+ Thread.Sleep (1000);
+
Environment.Exit (0);
}
}
class Driver
{
- /* expected exit code: 0 */
+ /* expected exit code: 255 */
static void Main (string[] args)
{
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
var action = new Action (Delegate);
var ares = action.BeginInvoke (Callback, null);
class Driver
{
- /* expected exit code: 0 */
+ /* expected exit code: 255 */
static void Main (string[] args)
{
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ AppDomain.CurrentDomain.UnhandledException += (s, e) => {};
+
ManualResetEvent mre = new ManualResetEvent (false);
- var cd = (CrossDomain) AppDomain.CreateDomain ("ad").CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
+ var ad = AppDomain.CreateDomain ("ad");
+
+ if (Environment.GetEnvironmentVariable ("TEST_UNHANDLED_EXCEPTION_HANDLER") != null)
+ ad.UnhandledException += (s, e) => {};
+
+ var cd = (CrossDomain) ad.CreateInstanceAndUnwrap (typeof(CrossDomain).Assembly.FullName, "CrossDomain");
var action = cd.NewDelegateWithoutTarget ();
var ares = action.BeginInvoke (Callback, null);
+++ /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);
- }
-}