2009-01-11 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sun, 11 Jan 2009 17:54:27 +0000 (17:54 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sun, 11 Jan 2009 17:54:27 +0000 (17:54 -0000)
* TestDriver.cs: Add an --iter argument to run tests multiple times.

svn path=/trunk/mono/; revision=122996

mono/mini/ChangeLog
mono/mini/TestDriver.cs

index 5eb88e7b1232b69a3a6889251c333265c1828e6e..e8ba88437d9ca15fe757464702884dcd58cbdf89 100644 (file)
@@ -1,5 +1,7 @@
 2009-01-11  Zoltan Varga  <vargaz@gmail.com>
 
+       * TestDriver.cs: Add an --iter argument to run tests multiple times.
+
        * tramp-amd64.c (mono_arch_create_trampoline_code_full): Emit debug info for
        trampolines.
 
index 05facbab37795bd1845b656a50baceb3c5c57fc6..58f59b97d502b27336c296f64b44ef153002ca8a 100644 (file)
@@ -1,13 +1,13 @@
 using System;
 using System.Reflection;
-
+using System.Collections.Generic;
 
 public class TestDriver {
 
        static public int RunTests (Type type, string[] args) {
                int failed = 0, ran = 0;
                int result, expected, elen;
-               int i, j;
+               int i, j, iterations;
                string name;
                MethodInfo[] methods;
                bool do_timings = false;
@@ -15,72 +15,73 @@ public class TestDriver {
                int tms = 0;
                DateTime start, end = DateTime.Now;
 
+               iterations = 1;
+
+               List<string> new_args = new List<string> ();
                if (args != null && args.Length > 0) {
                        for (j = 0; j < args.Length; j++) {
                                bool found = false;
                                if (args [j] == "--time") {
                                        do_timings = true;
                                        found = true;
-                               }
-                               if ((args [j] == "-v") || (args [j] == "--verbose")) {
+                                       j ++;
+                               } else if (args [j] == "--iter") {
+                                       iterations = Int32.Parse (args [j + 1]);
+                                       j += 2;
+                                       found = true;
+                               } else if ((args [j] == "-v") || (args [j] == "--verbose")) {
                                        verbose = true;
                                        found = true;
-                               }
-
-                               if (found) {
-                                       string[] new_args = new string [args.Length - 1];
-                                       for (i = 0; i < j; ++i)
-                                               new_args [i] = args [i];
-                                       j++;
-                                       for (; j < args.Length; ++i, ++j)
-                                               new_args [i] = args [j];
-                                       args = new_args;
-                                       break;
+                               } else {
+                                       new_args.Add (args [j]);
                                }
                        }
                }
                methods = type.GetMethods (BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static);
-               for (i = 0; i < methods.Length; ++i) {
-                       name = methods [i].Name;
-                       if (!name.StartsWith ("test_"))
-                               continue;
-                       if (args != null && args.Length > 0) {
-                               bool found = false;
-                               for (j = 0; j < args.Length; j++) {
-                                       if (name.EndsWith (args [j])) {
-                                               found = true;
-                                               break;
+               for (int iter = 0; iter < iterations; ++iter) {
+                       for (i = 0; i < methods.Length; ++i) {
+                               name = methods [i].Name;
+                               if (!name.StartsWith ("test_"))
+                                       continue;
+                               if (new_args.Count > 0) {
+                                       bool found = false;
+                                       for (j = 0; j < new_args.Count; j++) {
+                                               if (name.EndsWith (new_args [j])) {
+                                                       found = true;
+                                                       break;
+                                               }
                                        }
+                                       if (!found)
+                                               continue;
+                               }
+                               for (j = 5; j < name.Length; ++j)
+                                       if (!Char.IsDigit (name [j]))
+                                               break;
+                               if (verbose)
+                                       Console.WriteLine ("Running '{0}' ...", name);
+                               expected = Int32.Parse (name.Substring (5, j - 5));
+                               start = DateTime.Now;
+                               result = (int)methods [i].Invoke (null, null);
+                               if (do_timings) {
+                                       end = DateTime.Now;
+                                       long tdiff = end.Ticks - start.Ticks;
+                                       int mdiff = (int)tdiff/10000;
+                                       tms += mdiff;
+                                       Console.WriteLine ("{0} took {1} ms", name, mdiff);
+                               }
+                               ran++;
+                               if (result != expected) {
+                                       failed++;
+                                       Console.WriteLine ("{0} failed: got {1}, expected {2}", name, result, expected);
                                }
-                               if (!found)
-                                       continue;
                        }
-                       for (j = 5; j < name.Length; ++j)
-                               if (!Char.IsDigit (name [j]))
-                                       break;
-                       if (verbose)
-                               Console.WriteLine ("Running '{0}' ...", name);
-                       expected = Int32.Parse (name.Substring (5, j - 5));
-                       start = DateTime.Now;
-                       result = (int)methods [i].Invoke (null, null);
+               
                        if (do_timings) {
-                               end = DateTime.Now;
-                               long tdiff = end.Ticks - start.Ticks;
-                               int mdiff = (int)tdiff/10000;
-                               tms += mdiff;
-                               Console.WriteLine ("{0} took {1} ms", name, mdiff);
+                               Console.WriteLine ("Total ms: {0}", tms);
                        }
-                       ran++;
-                       if (result != expected) {
-                               failed++;
-                               Console.WriteLine ("{0} failed: got {1}, expected {2}", name, result, expected);
-                       }
-               }
-               
-               if (do_timings) {
-                       Console.WriteLine ("Total ms: {0}", tms);
+                       Console.WriteLine ("Regression tests: {0} ran, {1} failed in {2}", ran, failed, type);
                }
-               Console.WriteLine ("Regression tests: {0} ran, {1} failed in {2}", ran, failed, type);
+
                //Console.WriteLine ("Regression tests: {0} ran, {1} failed in [{2}]{3}", ran, failed, type.Assembly.GetName().Name, type);
                return failed;
        }