diff options
author | Alexis Christoforides <alexis@thenull.net> | 2020-06-17 04:01:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-17 04:01:51 +0300 |
commit | d45ff3af75b1fa9098004a73869edde06dfc4f2a (patch) | |
tree | 6fb3d89f4c258e436e9fe043ccba5349b6955ad8 | |
parent | bc1dd071a71cbba2fd7b8d8307ec737cdce2daaa (diff) |
[merp] Add tests for crashing via POSIX signal (#19977)
-rw-r--r-- | mono/tests/libtest.c | 59 | ||||
-rw-r--r-- | mono/tests/merp-crash-test.cs | 60 |
2 files changed, 119 insertions, 0 deletions
diff --git a/mono/tests/libtest.c b/mono/tests/libtest.c index 7a90aa99ce8..3f14636bb25 100644 --- a/mono/tests/libtest.c +++ b/mono/tests/libtest.c @@ -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 diff --git a/mono/tests/merp-crash-test.cs b/mono/tests/merp-crash-test.cs index 93e1beb142e..a33010e59cf 100644 --- a/mono/tests/merp-crash-test.cs +++ b/mono/tests/merp-crash-test.cs @@ -59,6 +59,12 @@ class C Crashers.Add(new Crasher ("MerpCrashSnprintf", MerpCrashSnprintf)); Crashers.Add(new Crasher ("MerpCrashDomainUnload", MerpCrashDomainUnload)); Crashers.Add(new Crasher ("MerpCrashUnbalancedGCSafe", MerpCrashUnbalancedGCSafe)); + Crashers.Add(new Crasher ("MerpCrashSignalTerm", MerpCrashSignalTerm)); + Crashers.Add(new Crasher ("MerpCrashSignalTerm", MerpCrashSignalAbrt)); + Crashers.Add(new Crasher ("MerpCrashSignalKill", MerpCrashSignalFpe)); + Crashers.Add(new Crasher ("MerpCrashSignalKill", MerpCrashSignalBus)); + Crashers.Add(new Crasher ("MerpCrashSignalSegv", MerpCrashSignalSegv)); + Crashers.Add(new Crasher ("MerpCrashSignalIll", MerpCrashSignalIll)); } public static void @@ -149,6 +155,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 () { |