[mobile_static] Make test runner aot each assembly individually
authorAlexander Kyte <alexmkyte@fastmail.com>
Thu, 16 Jun 2016 21:38:55 +0000 (17:38 -0400)
committerAlexander Kyte <alexmkyte@gmail.com>
Mon, 18 Jul 2016 19:03:44 +0000 (15:03 -0400)
mono/tests/Makefile.am
mono/tests/test-runner.cs

index cc95243bbb6f30cfa30d42ef25f1b666479f29a5..627252457c3e99dee5e68133c007c3f090cd420b 100644 (file)
@@ -59,9 +59,9 @@ MCS = $(MCS_NO_LIB) -lib:$(CLASS)
 ILASM = $(RUNTIME) $(CLASS)/ilasm.exe
 
 if INSTALL_MOBILE_STATIC
-TEST_RUNNER = ./test-runner.exe --runtime $(RUNTIME) --mono-path "$(CLASS)" --aot-run-flags "$(AOT_RUN_FLAGS)" --aot-build-flags "$(AOT_BUILD_FLAGS)"
+TEST_RUNNER = ./test-runner.exe --runtime $(top_builddir)/runtime/mono-wrapper --mono-path "$(CLASS)" --aot-run-flags "$(AOT_RUN_FLAGS)" --aot-build-flags "$(AOT_BUILD_FLAGS)"
 else
-TEST_RUNNER = ./test-runner.exe --runtime $(RUNTIME) --mono-path "$(CLASS)"
+TEST_RUNNER = ./test-runner.exe --runtime $(top_builddir)/runtime/mono-wrapper --mono-path "$(CLASS)"
 endif
 
 
index 4e2827424c8e620af0197eb22db1298ccf08a80d..8b456247222e6be7165641cad4b58f1ddb5b4b42 100644 (file)
@@ -218,39 +218,66 @@ public class TestRunner
                                output_width = Math.Min (120, ti.test.Length);
                }
 
-               List<Thread> threads = new List<Thread> (concurrency);
+               if (aot_build_flags != null)  {
+                       Console.WriteLine("AOT compiling tests");
 
-               DateTime test_start_time = DateTime.UtcNow;
+                       object aot_monitor = new object ();
+                       var aot_queue = new Queue<String> (tests); 
 
-               if (aot_build_flags != null)  {
-                       var allTests = new StringBuilder();
-                       foreach (string test in tests) {
-                               allTests.Append(test);
-                               allTests.Append(" ");
-                       }
+                       List<Thread> build_threads = new List<Thread> (concurrency);
 
-                       string aot_args = aot_build_flags + " " + allTests.ToString();
+                       for (int j = 0; j < concurrency; ++j) {
+                               Thread thread = new Thread (() => {
+                                       while (true) {
+                                               String test_name;
 
-                       ProcessStartInfo job = new ProcessStartInfo (runtime, aot_args);
-                       job.UseShellExecute = false;
-                       job.EnvironmentVariables[ENV_TIMEOUT] = timeout.ToString();
-                       job.EnvironmentVariables[MONO_PATH] = mono_path;
-                       Process compiler = new Process ();
-                       compiler.StartInfo = job;
+                                               lock (aot_monitor) {
+                                                       if (aot_queue.Count == 0)
+                                                               break;
+                                                       test_name = aot_queue.Dequeue ();
+                                               }
 
-                       compiler.Start ();
+                                               string test_bitcode_output = test_name + "_bitcode_tmp";
+                                               string test_bitcode_arg = ",temp-path=" + test_bitcode_output;
+                                               string aot_args = aot_build_flags + test_bitcode_arg + " " + test_name;
+
+                                               ProcessStartInfo job = new ProcessStartInfo (runtime, aot_args);
+                                               job.UseShellExecute = false;
+                                               job.EnvironmentVariables[ENV_TIMEOUT] = timeout.ToString();
+                                               job.EnvironmentVariables[MONO_PATH] = mono_path;
+                                               Process compiler = new Process ();
+                                               compiler.StartInfo = job;
+
+                                               compiler.Start ();
+
+                                               if (!compiler.WaitForExit (timeout * 1000)) {
+                                                       try {
+                                                               compiler.Kill ();
+                                                       } catch {
+                                                       }
+                                                       throw new Exception(String.Format("Timeout AOT compiling tests"));
+                                               } else if (compiler.ExitCode != 0) {
+                                                       throw new Exception(String.Format("Error AOT compiling tests"));
+                                               } else {
+                                                       File.Delete (test_bitcode_output);
+                                               }
+                                       }
+                               });
 
-                       if (!compiler.WaitForExit (timeout * 1000)) {
-                               try {
-                                       compiler.Kill ();
-                               } catch {
-                               }
-                               throw new Exception(String.Format("Timeout AOT compiling tests"));
-                       } else if (compiler.ExitCode != 0) {
-                               throw new Exception(String.Format("Error AOT compiling tests"));
+                               thread.Start ();
+
+                               build_threads.Add (thread);
                        }
+
+                       for (int j = 0; j < build_threads.Count; ++j)
+                               build_threads [j].Join ();
+
+                       Console.WriteLine("Done compiling");
                }
 
+               List<Thread> threads = new List<Thread> (concurrency);
+
+               DateTime test_start_time = DateTime.UtcNow;
 
                for (int j = 0; j < concurrency; ++j) {
                        Thread thread = new Thread (() => {