Bug 745251 - Implement --jitflags argument for jstests.py. r=terrence
authorPavel Zaichenkov <zaichenkov@gmail.com>
Sun, 05 Aug 2012 17:12:08 +0400
changeset 102008 9808b7c10bc73097b2bfddb18e0b9645d9ad6e4a
parent 102007 08631f0a9b1d617dbff065138ea6475ff037f6ca
child 102009 ccf302e93ca4e9ba38b3b797ad96f4199ea2cb19
push id13271
push userryanvm@gmail.com
push dateThu, 09 Aug 2012 21:36:02 +0000
treeherdermozilla-inbound@ccf302e93ca4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs745251
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 745251 - Implement --jitflags argument for jstests.py. r=terrence
js/src/tests/jstests.py
--- a/js/src/tests/jstests.py
+++ b/js/src/tests/jstests.py
@@ -1,16 +1,17 @@
 #!/usr/bin/env python
 """
 The JS Shell Test Harness.
 
 See the adjacent README.txt for more details.
 """
 
 import os, sys, textwrap
+from copy import copy
 from subprocess import list2cmdline, call
 
 from lib.results import NullTestOutput
 from lib.tests import TestCase
 from lib.results import ResultsSink
 from lib.progressbar import ProgressBar
 
 if (sys.platform.startswith('linux') or
@@ -79,16 +80,18 @@ def parse_args():
 
     harness_og = OptionGroup(op, "Harness Controls", "Control how tests are run.")
     harness_og.add_option('-j', '--worker-count', type=int, default=max(1, get_cpu_count()),
                           help='Number of tests to run in parallel (default %default)')
     harness_og.add_option('-t', '--timeout', type=float, default=150.0,
                           help='Set maximum time a test is allows to run (in seconds).')
     harness_og.add_option('-a', '--args', dest='shell_args', default='',
                           help='Extra args to pass to the JS shell.')
+    harness_og.add_option('--jitflags', default='',
+                          help='Example: --jitflags=m,amd to run each test with -m, -a -m -d [default=%default]')
     harness_og.add_option('-g', '--debug', action='store_true', help='Run a test in debugger.')
     harness_og.add_option('--debugger', default='gdb -q --args', help='Debugger command.')
     harness_og.add_option('--valgrind', action='store_true', help='Run tests in valgrind.')
     harness_og.add_option('--valgrind-args', default='', help='Extra args to pass to valgrind.')
     op.add_option_group(harness_og)
 
     input_og = OptionGroup(op, "Inputs", "Change what tests are run.")
     input_og.add_option('-f', '--file', dest='test_file', action='append',
@@ -183,16 +186,26 @@ def parse_args():
     options.hide_progress = (((options.show_cmd or options.show_output) and
                               options.output_fp == sys.stdout) or
                              options.tinderbox or
                              ProgressBar.conservative_isatty() or
                              options.hide_progress)
 
     return (options, requested_paths, excluded_paths)
 
+def parse_jitflags(op_jitflags):
+    jitflags = [ [ '-' + flag for flag in flags ]
+                 for flags in op_jitflags.split(',') ]
+    for flags in jitflags:
+        for flag in flags:
+            if flag not in ('-m', '-a', '-p', '-d', '-n'):
+                print('Invalid jit flag: "%s"'%flag)
+                sys.exit(1)
+    return jitflags
+
 def load_tests(options, requested_paths, excluded_paths):
     """
     Returns a tuple: (skipped_tests, test_list)
         skip_list: [iterable<Test>] Tests found but skipped.
         test_list: [iterable<Test>] Tests found that should be run.
     """
     import lib.manifest as manifest
 
@@ -210,16 +223,28 @@ def load_tests(options, requested_paths,
     test_dir = os.path.dirname(os.path.abspath(__file__))
     test_list = manifest.load(test_dir, xul_tester)
     skip_list = []
 
     if options.make_manifests:
         manifest.make_manifests(options.make_manifests, test_list)
         sys.exit()
 
+    # Create a new test list. Apply each JIT configuration to every test.
+    if options.jitflags:
+        new_test_list = []
+        jitflags_list = parse_jitflags(options.jitflags)
+        for test in test_list:
+            for jitflags in jitflags_list:
+                tmp_test = copy(test)
+                tmp_test.options = copy(test.options)
+                tmp_test.options.extend(jitflags)
+                new_test_list.append(tmp_test)
+        test_list = new_test_list
+
     if options.test_file:
         paths = set()
         for test_file in options.test_file:
             paths |= set([ line.strip() for line in open(test_file).readlines()])
         test_list = [ _ for _ in test_list if _.path in paths ]
 
     if requested_paths:
         def p(path):