Skip to content

Commit

Permalink
[runtime] Use temp folders for merp tests (mono#12830)
Browse files Browse the repository at this point in the history
The 2018-10 lane seemed to be failing some tests because the merp-json-valid.exe test left behind the crash log file. I fixed that in this PR, but also move the tests into their separate folders so they can run at the same time safely.
  • Loading branch information
alexanderkyte authored and akoeplinger committed Feb 7, 2019
1 parent 321e0b5 commit 0e65799
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
51 changes: 26 additions & 25 deletions mono/tests/merp-crash-test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static void HandleException (object sender, UnhandledExceptionEventArgs e
}
}

static string configDir = "./";
static string configDir = "./merp-crash-test/";

public static void
CrashWithMerp (int testNum)
Expand Down Expand Up @@ -161,7 +161,7 @@ public static void
}

public static void
TestValidateAndCleanup (string configDir, bool silent)
TestValidate (string configDir, bool silent)
{
DumpLogCheck ();

Expand All @@ -180,13 +180,17 @@ public static void
if (!silent)
Console.WriteLine ("Xml file {0}", text);
File.Delete (xmlFilePath);
} else {
Console.WriteLine ("Xml file {0} missing", xmlFilePath);
}

if (paramsFileExists) {
var text = File.ReadAllText (paramsFilePath);
if (!silent)
Console.WriteLine ("Params file {0}", text);
File.Delete (paramsFilePath);
} else {
Console.WriteLine ("Params file {0} missing", paramsFilePath);
}

if (crashFileExists) {
Expand All @@ -206,6 +210,8 @@ public static void

File.Delete (crashFilePath);
// Assert it has the required merp fields
} else {
Console.WriteLine ("Crash file {0} missing", crashFilePath);
}

if (!xmlFileExists)
Expand All @@ -221,24 +227,7 @@ public static void
public static void
Cleanup (string configDir)
{
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);

// Fixme: Maybe parse these json files rather than
// just checking they exist
var xmlFileExists = File.Exists (xmlFilePath);
var paramsFileExists = File.Exists (paramsFilePath);
var crashFileExists = File.Exists (crashFilePath);

if (xmlFileExists)
File.Delete (xmlFilePath);

if (paramsFileExists)
File.Delete (paramsFilePath);

if (crashFileExists)
File.Delete (crashFilePath);
Directory.Delete (configDir, true);
}

static void DumpLogSet ()
Expand Down Expand Up @@ -281,13 +270,26 @@ public static void
pi.Arguments = String.Format ("{0} {1}", asm, testNum);;
pi.Environment ["MONO_PATH"] = env;

if (!silent)
if (!silent) {
Console.WriteLine ("Running {0}", CrasherClass.Crashers [testNum].Item1);
Console.WriteLine ("MONO_PATH={0} {1} {2} {3}", env, runtime, asm, testNum);
}

if (Directory.Exists (configDir)) {
Console.WriteLine ("Cleaning up left over configDir {0}", configDir);
Cleanup (configDir);
}

var process = Diag.Process.Start (pi);
process.WaitForExit ();
Directory.CreateDirectory (configDir);

TestValidateAndCleanup (configDir, silent);
try {
var process = Diag.Process.Start (pi);
process.WaitForExit ();

TestValidate (configDir, silent);
} finally {
Cleanup (configDir);
}
}

public static void Main (string [] args)
Expand Down Expand Up @@ -344,7 +346,6 @@ public static void Main (string [] args)
SpawnCrashingRuntime (processExe, CrasherClass.StresserIndex, true);
} catch (Exception e) {
Console.WriteLine ("Stress test caught failure. Shutting down after {1} iterations.\n {0} \n\n", e.InnerException, iter);
Cleanup (configDir);
throw;
}
}
Expand Down
16 changes: 10 additions & 6 deletions mono/tests/merp-json-valid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void
}

public static void
JsonValidateMerp ()
JsonValidateMerp (string configDir)
{
var monoType = Type.GetType ("Mono.Runtime", false);
var m = monoType.GetMethod("EnableMicrosoftTelemetry", BindingFlags.NonPublic | BindingFlags.Static);
Expand All @@ -32,7 +32,6 @@ public static void
var appVersion = "123456";
var eventType = "AppleAppCrash";
var appPath = "/where/mono/lives";
var configDir = "./";

var m_params = new object[] { appBundleId, appSignature, appVersion, merpGUIPath, eventType, appPath, configDir };

Expand Down Expand Up @@ -63,8 +62,6 @@ public static void
var paramsFilePath = String.Format("{0}MERP.uploadparams.txt", configDir);
var crashFilePath = String.Format("{0}lastcrashlog.txt", configDir);

// Fixme: Maybe parse these json files rather than
// just checking they exist
var xmlFileExists = File.Exists (xmlFilePath);
var paramsFileExists = File.Exists (paramsFilePath);
var crashFileExists = File.Exists (crashFilePath);
Expand All @@ -81,7 +78,7 @@ public static void

if (crashFileExists) {
var crashFile = File.ReadAllText (crashFilePath);
//File.Delete (crashFilePath);
File.Delete (crashFilePath);

var checker = new JavaScriptSerializer ();

Expand All @@ -103,6 +100,13 @@ public static void
public static void Main ()
{
JsonValidateState ();
JsonValidateMerp ();

var configDir = "./merp-json-valid/";
Directory.CreateDirectory (configDir);
try {
JsonValidateMerp (configDir);
} finally {
Directory.Delete (configDir, true);
}
}
}

0 comments on commit 0e65799

Please sign in to comment.