Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Christoforides <alexis@thenull.net>2020-06-12 05:45:12 +0300
committerGitHub <noreply@github.com>2020-06-12 05:45:12 +0300
commit540da38191e5889a3d5d2316e4e45750c0d29c44 (patch)
tree3d3859ec1b443982ac3ec2899034d79b93602b36 /mono/tests
parente51b4af9cd87b1a36022d7d774d7c1e98b65bdfd (diff)
[merp] Add API methods for getting hashcode/reason of last crash (#19901)
* [merp] Add API methods for getting hashcode/reason of last crash * Add test * Review feedback and cleanup
Diffstat (limited to 'mono/tests')
-rw-r--r--mono/tests/merp-crash-test.cs38
1 files changed, 35 insertions, 3 deletions
diff --git a/mono/tests/merp-crash-test.cs b/mono/tests/merp-crash-test.cs
index 82cc3513e2e..ef12ddc7c44 100644
--- a/mono/tests/merp-crash-test.cs
+++ b/mono/tests/merp-crash-test.cs
@@ -65,6 +65,7 @@ class C
Crashers.Add(new Crasher ("MerpCrashSignalKill", MerpCrashSignalBus));
Crashers.Add(new Crasher ("MerpCrashSignalSegv", MerpCrashSignalSegv));
Crashers.Add(new Crasher ("MerpCrashSignalIll", MerpCrashSignalIll));
+ Crashers.Add(new Crasher ("MerpCrashTestBreadcrumbs", MerpCrashTestBreadcrumbs, validator: ValidateBreadcrumbs));
}
public static void
@@ -88,6 +89,22 @@ class C
throw new ValidationException (String.Format ("incorrect fail fast message (expected: {0}, got: {1})", failfastMsg, s));
}
+ public static void ValidateBreadcrumbs (object json)
+ {
+ var monoType = Type.GetType ("Mono.Runtime", false);
+ var m = monoType.GetMethod ("CheckCrashReportReason", BindingFlags.NonPublic | BindingFlags.Static);
+ var m_params = new object [] { "./", false };
+ string o = (string)m.Invoke(null, m_params);
+ if (o != "segv")
+ throw new Exception ("Crash report reason should be 'segv'");
+
+ m = monoType.GetMethod ("CheckCrashReportHash", BindingFlags.NonPublic | BindingFlags.Static);
+ long hash = (long)m.Invoke (null, m_params);
+
+ if (hash == 0)
+ throw new Exception ("Crash hash should not be zero");
+ }
+
[DllImport("libtest")]
public static extern void mono_test_MerpCrashSnprintf ();
@@ -222,6 +239,12 @@ class C
mono_test_MerpCrashUnhandledExceptionHook ();
}
+ public static void
+ MerpCrashTestBreadcrumbs ()
+ {
+ mono_test_MerpCrashSignalSegv ();
+ }
+
private static object jsonGetKey (object o, string key) => (o as Dictionary<string,object>)[key];
private static object jsonGetKeys (object o, params string[] keys) {
@@ -273,8 +296,6 @@ class C
public static void
TestValidate (string configDir, bool silent, Action<object> validator = null)
{
- DumpLogCheck (expected_level: "MerpInvoke"); // we are expecting merp invoke to fail
-
var xmlFilePath = String.Format("{0}CustomLogsMetadata.xml", configDir);
var paramsFilePath = String.Format("{0}MERP.uploadparams.txt", configDir);
var crashFilePath = String.Format("{0}lastcrashlog.txt", configDir);
@@ -319,7 +340,7 @@ class C
} catch (CrasherClass.ValidationException e) {
throw new Exception (String.Format ("Validation failed '{0}', json: {1}", e.Message, crashFile));
} catch (Exception e) {
- throw new Exception (String.Format ("Invalid json: {0}", crashFile));
+ throw new Exception (String.Format ("Invalid json ({0}:{1}): {2}", e.GetType(), e.Message, crashFile));
}
File.Delete (crashFilePath);
@@ -328,6 +349,8 @@ class C
Console.WriteLine ("Crash file {0} missing", crashFilePath);
}
+ DumpLogCheck (expected_level: "MerpInvoke"); // we are expecting merp invoke to fail
+
if (!xmlFileExists)
throw new Exception (String.Format ("Did not produce {0}", xmlFilePath));
@@ -368,6 +391,15 @@ class C
if (expected_level != levels [result])
throw new Exception (String.Format ("Crash level {0} does not match expected {1}", levels [result], expected_level));
+
+ // also clear hash and reason breadcrumbs
+ convert = monoType.GetMethod("CheckCrashReportHash", BindingFlags.NonPublic | BindingFlags.Static);
+ var hash_result = (long) convert.Invoke(null, new object[] { "./", true });
+ convert = monoType.GetMethod("CheckCrashReportReason", BindingFlags.NonPublic | BindingFlags.Static);
+ var reason_result = (string) convert.Invoke(null, new object[] { "./", true });
+
+ if (reason_result == string.Empty)
+ throw new Exception("Crash reason should not be an empty string");
}