Changeset 72149 in webkit


Ignore:
Timestamp:
Nov 16, 2010 4:36:06 PM (13 years ago)
Author:
dpranke@chromium.org
Message:

2010-11-16 Dirk Pranke <dpranke@chromium.org>

Reviewed by Ojan Vafai.

new-run-webkit-tests: rename TestInfo to TestInput, move image hash to work thread

Rename the TestInfo class to TestInput to be clearer about its
function, and move the checksum-reading code into dump_render_tree_thread
to avoid cross-thread access.

https://bugs.webkit.org/show_bug.cgi?id=49573

  • Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
  • Scripts/webkitpy/layout_tests/run_webkit_tests.py:
  • Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r72147 r72149  
     12010-11-16  Dirk Pranke  <dpranke@chromium.org>
     2
     3        Reviewed by Ojan Vafai.
     4
     5        new-run-webkit-tests: rename TestInfo to TestInput, move image hash to work thread
     6
     7        Rename the TestInfo class to TestInput to be clearer about its
     8        function, and move the checksum-reading code into dump_render_tree_thread
     9        to avoid cross-thread access.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=49573
     12
     13        * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
     14        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
     15        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
     16
    1172010-11-16  Dave Hyatt  <hyatt@apple.com>
    218
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py

    r71527 r72149  
    7575
    7676
    77 def _process_output(port, options, test_info, test_types, test_args,
     77def _process_output(port, options, test_input, test_types, test_args,
    7878                    crash, timeout, test_run_time, actual_checksum,
    7979                    output, error):
     
    8585      options: command line options argument from optparse
    8686      proc: an active DumpRenderTree process
    87       test_info: Object containing the test filename, uri and timeout
     87      test_input: Object containing the test filename, uri and timeout
    8888      test_types: list of test types to subject the output to
    8989      test_args: arguments to be passed to each test
     
    105105
    106106    if crash:
    107         _log.debug("Stacktrace for %s:\n%s" % (test_info.filename, error))
     107        _log.debug("Stacktrace for %s:\n%s" % (test_input.filename, error))
    108108        # Strip off "file://" since RelativeTestFilename expects
    109109        # filesystem paths.
    110110        filename = os.path.join(options.results_directory,
    111111                                port.relative_test_filename(
    112                                 test_info.filename))
     112                                test_input.filename))
    113113        filename = os.path.splitext(filename)[0] + "-stack.txt"
    114114        port.maybe_make_directory(os.path.split(filename)[0])
     
    123123    for test_type in test_types:
    124124        start_diff_time = time.time()
    125         new_failures = test_type.compare_output(port, test_info.filename,
     125        new_failures = test_type.compare_output(port, test_input.filename,
    126126                                                output, local_test_args,
    127127                                                options.configuration)
     
    135135
    136136    total_time_for_all_diffs = time.time() - start_diff_time
    137     return test_results.TestResult(test_info.filename, failures, test_run_time,
     137    return test_results.TestResult(test_input.filename, failures, test_run_time,
    138138                                   total_time_for_all_diffs, time_for_diffs)
    139139
     
    154154
    155155
    156 def _image_hash(test_info, test_args, options):
    157     """Returns the image hash of the test if it's needed, otherwise None."""
    158     if (test_args.new_baseline or test_args.reset_results or not options.pixel_tests):
    159         return None
    160     return test_info.image_hash()
     156def _should_fetch_expected_checksum(options):
     157    return options.pixel_tests and not (options.new_baseline or options.reset_results)
    161158
    162159
     
    164161    """Thread wrapper for running a single test file."""
    165162
    166     def __init__(self, port, options, test_info, test_types, test_args):
     163    def __init__(self, port, options, test_input, test_types, test_args):
    167164        """
    168165        Args:
    169166          port: object implementing port-specific hooks
    170167          options: command line argument object from optparse
    171           test_info: Object containing the test filename, uri and timeout
     168          test_input: Object containing the test filename, uri and timeout
    172169          test_types: A list of TestType objects to run the test output
    173170              against.
     
    178175        self._port = port
    179176        self._options = options
    180         self._test_info = test_info
     177        self._test_input = test_input
    181178        self._test_types = test_types
    182179        self._test_args = test_args
     
    189186        # FIXME: this is a separate routine to work around a bug
    190187        # in coverage: see http://bitbucket.org/ned/coveragepy/issue/85.
    191         test_info = self._test_info
     188
     189        # FIXME: Pull this into TestShellThread._run().
     190        test_input = self._test_input
     191        test_input.uri = self._port.filename_to_uri(test_input.filename)
     192        if _should_fetch_expected_checksum(self._options):
     193            test_input.image_checksum = self._port.expected_checksum(test_input.filename)
     194
     195        start = time.time()
    192196        self._driver = self._port.create_driver(self._test_args.png_path,
    193197                                                self._options)
    194198        self._driver.start()
    195         image_hash = _image_hash(test_info, self._test_args, self._options)
    196         start = time.time()
    197199        crash, timeout, actual_checksum, output, error = \
    198             self._driver.run_test(test_info.uri.strip(), test_info.timeout,
    199                                   image_hash)
     200            self._driver.run_test(test_input.uri, test_input.timeout,
     201                                  test_input.image_checksum)
    200202        end = time.time()
    201203        self._test_result = _process_output(self._port, self._options,
    202             test_info, self._test_types, self._test_args,
     204            test_input, self._test_types, self._test_args,
    203205            crash, timeout, end - start,
    204206            actual_checksum, output, error)
     
    259261              against.
    260262          test_args: A TestArguments object to pass to each TestType.
    261 
    262263        """
    263264        WatchableThread.__init__(self)
     
    403404                self._current_group_start_time = time.time()
    404405
    405             test_info = self._filename_list.pop()
     406            test_input = self._filename_list.pop()
    406407
    407408            # We have a url, run tests.
     
    409410            self._num_tests += 1
    410411            if self._options.run_singly:
    411                 result = self._run_test_singly(test_info)
     412                result = self._run_test_singly(test_input)
    412413            else:
    413                 result = self._run_test(test_info)
    414 
    415             filename = test_info.filename
     414                result = self._run_test(test_input)
     415
     416            filename = test_input.filename
    416417            tests_run_file.write(filename + "\n")
    417418            if result.failures:
     
    441442                test_runner.update_summary(result_summary)
    442443
    443     def _run_test_singly(self, test_info):
     444    def _run_test_singly(self, test_input):
    444445        """Run a test in a separate thread, enforcing a hard time limit.
    445446
     
    449450
    450451        Args:
    451           test_info: Object containing the test filename, uri and timeout
     452          test_input: Object containing the test filename, uri and timeout
    452453
    453454        Returns:
     
    457458        worker = SingleTestThread(self._port,
    458459                                  self._options,
    459                                   test_info,
     460                                  test_input,
    460461                                  self._test_types,
    461462                                  self._test_args)
     
    464465
    465466        thread_timeout = _milliseconds_to_seconds(
    466             _pad_timeout(int(test_info.timeout)))
     467            _pad_timeout(int(test_input.timeout)))
    467468        thread._next_timeout = time.time() + thread_timeout
    468469        worker.join(thread_timeout)
     
    486487            failures = []
    487488            _log.error('Cannot get results of test: %s' %
    488                        test_info.filename)
    489             result = test_results.TestResult(test_info.filename, failures=[],
     489                       test_input.filename)
     490            result = test_results.TestResult(test_input.filename, failures=[],
    490491                test_run_time=0, total_time_for_all_diffs=0, time_for_diffs=0)
    491492
    492493        return result
    493494
    494     def _run_test(self, test_info):
     495    def _run_test(self, test_input):
    495496        """Run a single test file using a shared DumpRenderTree process.
    496497
    497498        Args:
    498           test_info: Object containing the test filename, uri and timeout
     499          test_input: Object containing the test filename, uri and timeout
    499500
    500501        Returns: a TestResult object.
     
    505506        # are generating a new baseline.  (Otherwise, an image from a
    506507        # previous run will be copied into the baseline.)
    507         image_hash = _image_hash(test_info, self._test_args, self._options)
     508
     509        # FIXME: Pull this into TestShellThread._run().
     510        test_input.uri = self._port.filename_to_uri(test_input.filename)
     511        if _should_fetch_expected_checksum(self._options):
     512            test_input.image_checksum = self._port.expected_checksum(test_input.filename)
    508513        start = time.time()
    509514
    510515        thread_timeout = _milliseconds_to_seconds(
    511              _pad_timeout(int(test_info.timeout)))
     516             _pad_timeout(int(test_input.timeout)))
    512517        self._next_timeout = start + thread_timeout
    513518
    514519        crash, timeout, actual_checksum, output, error = \
    515            self._driver.run_test(test_info.uri, test_info.timeout, image_hash)
     520           self._driver.run_test(test_input.uri, test_input.timeout, test_input.image_checksum)
    516521        end = time.time()
    517522
    518523        result = _process_output(self._port, self._options,
    519                                  test_info, self._test_types,
     524                                 test_input, self._test_types,
    520525                                 self._test_args, crash,
    521526                                 timeout, end - start, actual_checksum,
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

    r71952 r72149  
    9191
    9292
    93 class TestInfo:
     93class TestInput:
    9494    """Groups information about a test for easy passing of data."""
    9595
    96     def __init__(self, port, filename, timeout):
    97         """Generates the URI and stores the filename and timeout for this test.
     96    def __init__(self, filename, timeout):
     97        """Holds the input parameters for a test.
    9898        Args:
    9999          filename: Full path to the test.
    100           timeout: Timeout for running the test in TestShell.
     100          timeout: Timeout in msecs the driver should use while running the test
    101101          """
     102        # FIXME: filename should really be test_name as a relative path.
    102103        self.filename = filename
    103         self._port = port
    104         self.uri = port.filename_to_uri(filename)
     104        # The image checksum is passed to the driver so that the driver can optionally not have
     105        # to output the image if the checksums match.
     106        self.image_checksum = None
    105107        self.timeout = timeout
    106         self._image_checksum = -1
    107 
    108     def image_hash(self):
    109         # Read the image_hash lazily to reduce startup time.
    110         # This class is accessed across threads, but only one thread should
    111         # ever be dealing with any given TestInfo so no locking is needed.
    112         #
    113         # Note that we use -1 to indicate that we haven't read the value,
    114         # because expected_checksum() returns a string or None.
    115         if self._image_checksum == -1:
    116             self._image_checksum = self._port.expected_checksum(self.filename)
    117         return self._image_checksum
     108
     109        # FIXME: Maybe the URI shouldn't be part of the TestInput at all?
     110        self.uri = None
    118111
    119112
     
    498491        return return_value
    499492
    500     def _get_test_info_for_file(self, test_file):
    501         """Returns the appropriate TestInfo object for the file. Mostly this
     493    def _get_test_input_for_file(self, test_file):
     494        """Returns the appropriate TestInput object for the file. Mostly this
    502495        is used for looking up the timeout value (in ms) to use for the given
    503496        test."""
    504497        if self._expectations.has_modifier(test_file, test_expectations.SLOW):
    505             return TestInfo(self._port, test_file,
    506                             self._options.slow_time_out_ms)
    507         return TestInfo(self._port, test_file, self._options.time_out_ms)
     498            return TestInput(test_file, self._options.slow_time_out_ms)
     499        return TestInput(test_file, self._options.time_out_ms)
    508500
    509501    def _test_requires_lock(self, test_file):
     
    523515
    524516        Return:
    525           The Queue of lists of TestInfo objects.
     517          The Queue of lists of TestInput objects.
    526518        """
    527519
     
    531523            self._is_single_threaded()):
    532524            for test_file in test_files:
    533                 test_info = self._get_test_info_for_file(test_file)
     525                test_input = self._get_test_input_for_file(test_file)
    534526                if self._test_requires_lock(test_file):
    535                     tests_to_http_lock.append(test_info)
     527                    tests_to_http_lock.append(test_input)
    536528                else:
    537                     test_lists.append((".", [test_info]))
     529                    test_lists.append((".", [test_input]))
    538530        else:
    539531            tests_by_dir = {}
    540532            for test_file in test_files:
    541533                directory = self._get_dir_for_test_file(test_file)
    542                 test_info = self._get_test_info_for_file(test_file)
     534                test_input = self._get_test_input_for_file(test_file)
    543535                if self._test_requires_lock(test_file):
    544                     tests_to_http_lock.append(test_info)
     536                    tests_to_http_lock.append(test_input)
    545537                else:
    546538                    tests_by_dir.setdefault(directory, [])
    547                     tests_by_dir[directory].append(test_info)
     539                    tests_by_dir[directory].append(test_input)
    548540            # Sort by the number of tests in the dir so that the ones with the
    549541            # most tests get run first in order to maximize parallelization.
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py

    r71580 r72149  
    381381            self.assertTrue(any(f.find(baseline) != -1 for f in file_list))
    382382
     383    # FIXME: Add tests to ensure that we're *not* writing baselines when we're not
     384    # supposed to be.
     385
    383386    def disabled_test_reset_results(self):
    384387        # FIXME: This test is disabled until we can rewrite it to use a
     
    427430
    428431class TestRunnerWrapper(run_webkit_tests.TestRunner):
    429     def _get_test_info_for_file(self, test_file):
     432    def _get_test_input_for_file(self, test_file):
    430433        return test_file
    431434
Note: See TracChangeset for help on using the changeset viewer.