[merp] Add tests for crashing via POSIX signal (#2163)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 7 Feb 2020 06:28:00 +0000 (01:28 -0500)
committerGitHub <noreply@github.com>
Fri, 7 Feb 2020 06:28:00 +0000 (07:28 +0100)
Co-authored-by: Alexis Christoforides <alexis@thenull.net>
src/mono/mono/tests/libtest.c
src/mono/mono/tests/merp-crash-test.cs

index 7a90aa9..3f14636 100644 (file)
@@ -8,6 +8,7 @@
 #include <time.h>
 #include <math.h>
 #include <setjmp.h>
+#include <signal.h>
 #include "../utils/mono-errno.h"
 #include "../utils/mono-compiler.h"
 
@@ -8011,6 +8012,64 @@ mono_test_MerpCrashUnhandledExceptionHook (void)
        g_assert_not_reached ();
 }
 
+LIBTEST_API void STDCALL
+mono_test_MerpCrashSignalTerm (void)
+{
+       raise (SIGTERM);
+}
+
+// for the rest of the signal tests, we use SIGTERM as a fallback
+
+LIBTEST_API void STDCALL
+mono_test_MerpCrashSignalAbrt (void)
+{
+#if defined (SIGABRT)
+       raise (SIGABRT);
+#else
+       raise (SIGTERM);
+#endif
+}
+
+LIBTEST_API void STDCALL
+mono_test_MerpCrashSignalFpe (void)
+{
+#if defined (SIGFPE)
+       raise (SIGFPE);
+#else
+       raise (SIGTERM);
+#endif
+}
+
+LIBTEST_API void STDCALL
+mono_test_MerpCrashSignalBus (void)
+{
+#if defined (SIGBUS)
+       raise (SIGBUS);
+#else
+       raise (SIGTERM);
+#endif
+}
+
+LIBTEST_API void STDCALL
+mono_test_MerpCrashSignalSegv (void)
+{
+#if defined (SIGSEGV)
+       raise (SIGSEGV);
+#else
+       raise (SIGTERM);
+#endif
+}
+
+LIBTEST_API void STDCALL
+mono_test_MerpCrashSignalIll (void)
+{
+#if defined (SIGILL)
+       raise (SIGILL);
+#else
+       raise (SIGTERM);
+#endif
+}
+
 #ifdef __cplusplus
 } // extern C
 #endif
index d04f814..db13331 100644 (file)
@@ -38,6 +38,12 @@ class C
                        Crashers.Add(new Tuple<String, Action> ("MerpCrashSnprintf", MerpCrashSnprintf));
                        Crashers.Add(new Tuple<String, Action> ("MerpCrashDomainUnload", MerpCrashDomainUnload));
                        Crashers.Add(new Tuple<String, Action> ("MerpCrashUnbalancedGCSafe", MerpCrashUnbalancedGCSafe));
+                       Crashers.Add(new Tuple<String,Action>  ("MerpCrashSignalTerm", MerpCrashSignalTerm));
+                       Crashers.Add(new Tuple<String,Action>  ("MerpCrashSignalTerm", MerpCrashSignalAbrt));
+                       Crashers.Add(new Tuple<String,Action>  ("MerpCrashSignalKill", MerpCrashSignalFpe));
+                       Crashers.Add(new Tuple<String,Action>  ("MerpCrashSignalKill", MerpCrashSignalBus));
+                       Crashers.Add(new Tuple<String,Action>  ("MerpCrashSignalSegv", MerpCrashSignalSegv));
+                       Crashers.Add(new Tuple<String,Action>  ("MerpCrashSignalIll", MerpCrashSignalIll));
                }
 
                public static void 
@@ -113,6 +119,60 @@ class C
                [DllImport("libtest")]
                public static extern void mono_test_MerpCrashUnhandledExceptionHook ();
 
+               [DllImport("libtest")]
+               public static extern void mono_test_MerpCrashSignalTerm ();
+
+               public static void
+               MerpCrashSignalTerm ()
+               {
+                       mono_test_MerpCrashSignalTerm ();
+               }
+
+               [DllImport("libtest")]
+               public static extern void mono_test_MerpCrashSignalAbrt ();
+
+               public static void
+               MerpCrashSignalAbrt ()
+               {
+                       mono_test_MerpCrashSignalAbrt ();
+               }
+
+               [DllImport("libtest")]
+               public static extern void mono_test_MerpCrashSignalFpe ();
+
+               public static void
+               MerpCrashSignalFpe ()
+               {
+                       mono_test_MerpCrashSignalFpe ();
+               }
+
+               [DllImport("libtest")]
+               public static extern void mono_test_MerpCrashSignalBus ();
+
+               public static void
+               MerpCrashSignalBus ()
+               {
+                       mono_test_MerpCrashSignalBus ();
+               }
+
+               [DllImport("libtest")]
+               public static extern void mono_test_MerpCrashSignalSegv ();
+
+               public static void
+               MerpCrashSignalSegv ()
+               {
+                       mono_test_MerpCrashSignalSegv ();
+               }
+
+               [DllImport("libtest")]
+               public static extern void mono_test_MerpCrashSignalIll ();
+
+               public static void
+               MerpCrashSignalIll ()
+               {
+                       mono_test_MerpCrashSignalIll ();
+               }
+
                public static void 
                MerpCrashUnhandledExceptionHook ()
                {