Changeset 68903 in webkit


Ignore:
Timestamp:
Oct 1, 2010 11:17:35 AM (14 years ago)
Author:
Csaba Osztrogonác
Message:

2010-10-01 Gabor Rapcsanyi <rgabor@inf.u-szeged.hu>

Reviewed by Tony Chang.

[NRWT] Put the http and websocket tests first in the test list.
https://bugs.webkit.org/show_bug.cgi?id=46453

  • Scripts/webkitpy/layout_tests/run_webkit_tests.py:
  • Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r68894 r68903  
     12010-10-01  Gabor Rapcsanyi  <rgabor@inf.u-szeged.hu>
     2
     3        Reviewed by Tony Chang.
     4
     5        [NRWT] Put the http and websocket tests first in the test list.
     6        https://bugs.webkit.org/show_bug.cgi?id=46453
     7
     8        * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
     9        * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py:
     10
    1112010-10-01  Fady Samuel  <fsamuel@chromium.org>
    212
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

    r68294 r68903  
    11#!/usr/bin/env python
    22# Copyright (C) 2010 Google Inc. All rights reserved.
     3# Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Szeged
    34#
    45# Redistribution and use in source and binary forms, with or without
     
    499500        return TestInfo(self._port, test_file, self._options.time_out_ms)
    500501
     502    def _test_requires_lock(self, test_file):
     503        """Return True if the test needs to be locked when
     504        running multiple copies of NRWTs."""
     505        split_path = test_file.split(os.sep)
     506        return 'http' in split_path or 'websocket' in split_path
     507
    501508    def _get_test_file_queue(self, test_files):
    502509        """Create the thread safe queue of lists of (test filenames, test URIs)
     
    512519        """
    513520
     521        test_lists = []
     522        tests_to_http_lock = []
    514523        if (self._options.experimental_fully_parallel or
    515524            self._is_single_threaded()):
    516             filename_queue = Queue.Queue()
    517525            for test_file in test_files:
    518                 filename_queue.put(
    519                     ('.', [self._get_test_info_for_file(test_file)]))
    520             return filename_queue
    521 
    522         tests_by_dir = {}
    523         for test_file in test_files:
    524             directory = self._get_dir_for_test_file(test_file)
    525             tests_by_dir.setdefault(directory, [])
    526             tests_by_dir[directory].append(
    527                 self._get_test_info_for_file(test_file))
    528 
    529         # Sort by the number of tests in the dir so that the ones with the
    530         # most tests get run first in order to maximize parallelization.
    531         # Number of tests is a good enough, but not perfect, approximation
    532         # of how long that set of tests will take to run. We can't just use
    533         # a PriorityQueue until we move # to Python 2.6.
    534         test_lists = []
    535         http_tests = None
    536         for directory in tests_by_dir:
    537             test_list = tests_by_dir[directory]
    538             # Keep the tests in alphabetical order.
    539             # TODO: Remove once tests are fixed so they can be run in any
    540             # order.
    541             test_list.reverse()
    542             test_list_tuple = (directory, test_list)
    543             if directory == 'LayoutTests' + os.sep + 'http':
    544                 http_tests = test_list_tuple
    545             else:
     526                test_info = self._get_test_info_for_file(test_file)
     527                if self._test_requires_lock(test_file):
     528                    tests_to_http_lock.append(test_info)
     529                else:
     530                    test_lists.append((".", [test_info]))
     531        else:
     532            tests_by_dir = {}
     533            for test_file in test_files:
     534                directory = self._get_dir_for_test_file(test_file)
     535                test_info = self._get_test_info_for_file(test_file)
     536                if self._test_requires_lock(test_file):
     537                    tests_to_http_lock.append(test_info)
     538                else:
     539                    tests_by_dir.setdefault(directory, [])
     540                    tests_by_dir[directory].append(test_info)
     541            # Sort by the number of tests in the dir so that the ones with the
     542            # most tests get run first in order to maximize parallelization.
     543            # Number of tests is a good enough, but not perfect, approximation
     544            # of how long that set of tests will take to run. We can't just use
     545            # a PriorityQueue until we move to Python 2.6.
     546            for directory in tests_by_dir:
     547                test_list = tests_by_dir[directory]
     548                # Keep the tests in alphabetical order.
     549                # FIXME: Remove once tests are fixed so they can be run in any
     550                # order.
     551                test_list.reverse()
     552                test_list_tuple = (directory, test_list)
    546553                test_lists.append(test_list_tuple)
    547         test_lists.sort(lambda a, b: cmp(len(b[1]), len(a[1])))
     554            test_lists.sort(lambda a, b: cmp(len(b[1]), len(a[1])))
    548555
    549556        # Put the http tests first. There are only a couple hundred of them,
    550557        # but each http test takes a very long time to run, so sorting by the
    551558        # number of tests doesn't accurately capture how long they take to run.
    552         if http_tests:
    553             test_lists.insert(0, http_tests)
     559        if tests_to_http_lock:
     560            test_lists.insert(0, ("tests_to_http_lock", tests_to_http_lock))
    554561
    555562        filename_queue = Queue.Queue()
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py

    r68063 r68903  
    11#!/usr/bin/python
    22# Copyright (C) 2010 Google Inc. All rights reserved.
     3# Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Szeged
    34#
    45# Redistribution and use in source and binary forms, with or without
     
    295296
    296297
     298class TestRunnerWrapper(run_webkit_tests.TestRunner):
     299    def _get_test_info_for_file(self, test_file):
     300        return test_file
     301
     302
    297303class TestRunnerTest(unittest.TestCase):
    298304    def test_results_html(self):
     
    315321        self.assertEqual(html, expected_html)
    316322
     323    def queue_to_list(self, queue):
     324        queue_list = []
     325        while(True):
     326            try:
     327                queue_list.append(queue.get_nowait())
     328            except Queue.Empty:
     329                break
     330        return queue_list
     331
     332    def test_get_test_file_queue(self):
     333        # Test that _get_test_file_queue in run_webkit_tests.TestRunner really
     334        # put the http tests first in the queue.
     335        runner = TestRunnerWrapper(port=Mock(), options=Mock(), printer=Mock())
     336        runner._options.experimental_fully_parallel = False
     337
     338        test_list = [
     339          "LayoutTests/websocket/tests/unicode.htm",
     340          "LayoutTests/animations/keyframes.html",
     341          "LayoutTests/http/tests/security/view-source-no-refresh.html",
     342          "LayoutTests/websocket/tests/websocket-protocol-ignored.html",
     343          "LayoutTests/fast/css/display-none-inline-style-change-crash.html",
     344          "LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html",
     345          "LayoutTests/dom/html/level2/html/HTMLAnchorElement03.html",
     346          "LayoutTests/ietestcenter/Javascript/11.1.5_4-4-c-1.html",
     347          "LayoutTests/dom/html/level2/html/HTMLAnchorElement06.html",
     348        ]
     349
     350        expected_tests_to_http_lock = set([
     351          'LayoutTests/websocket/tests/unicode.htm',
     352          'LayoutTests/http/tests/security/view-source-no-refresh.html',
     353          'LayoutTests/websocket/tests/websocket-protocol-ignored.html',
     354          'LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html',
     355        ])
     356
     357        runner._options.child_processes = 1
     358        test_queue_for_single_thread = runner._get_test_file_queue(test_list)
     359        runner._options.child_processes = 2
     360        test_queue_for_multi_thread = runner._get_test_file_queue(test_list)
     361
     362        single_thread_results = self.queue_to_list(test_queue_for_single_thread)
     363        multi_thread_results = self.queue_to_list(test_queue_for_multi_thread)
     364
     365        self.assertEqual("tests_to_http_lock", single_thread_results[0][0])
     366        self.assertEqual(expected_tests_to_http_lock, set(single_thread_results[0][1]))
     367        self.assertEqual("tests_to_http_lock", multi_thread_results[0][0])
     368        self.assertEqual(expected_tests_to_http_lock, set(multi_thread_results[0][1]))
    317369
    318370class DryrunTest(unittest.TestCase):
Note: See TracChangeset for help on using the changeset viewer.