test.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. # Copyright (C) 2010 Google Inc. All rights reserved.
  2. #
  3. # Redistribution and use in source and binary forms, with or without
  4. # modification, are permitted provided that the following conditions are
  5. # met:
  6. #
  7. # * Redistributions of source code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # * Redistributions in binary form must reproduce the above
  10. # copyright notice, this list of conditions and the following disclaimer
  11. # in the documentation and/or other materials provided with the
  12. # distribution.
  13. # * Neither the Google name nor the names of its
  14. # contributors may be used to endorse or promote products derived from
  15. # this software without specific prior written permission.
  16. #
  17. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. import base64
  29. import sys
  30. import time
  31. from webkitpy.port import Port, Driver, DriverOutput
  32. from webkitpy.port.base import VirtualTestSuite
  33. from webkitpy.layout_tests.models.test_configuration import TestConfiguration
  34. from webkitpy.common.system.filesystem_mock import MockFileSystem
  35. from webkitpy.common.system.crashlogs import CrashLogs
  36. # This sets basic expectations for a test. Each individual expectation
  37. # can be overridden by a keyword argument in TestList.add().
  38. class TestInstance(object):
  39. def __init__(self, name):
  40. self.name = name
  41. self.base = name[(name.rfind("/") + 1):name.rfind(".")]
  42. self.crash = False
  43. self.web_process_crash = False
  44. self.exception = False
  45. self.hang = False
  46. self.keyboard = False
  47. self.error = ''
  48. self.timeout = False
  49. self.is_reftest = False
  50. # The values of each field are treated as raw byte strings. They
  51. # will be converted to unicode strings where appropriate using
  52. # FileSystem.read_text_file().
  53. self.actual_text = self.base + '-txt'
  54. self.actual_checksum = self.base + '-checksum'
  55. # We add the '\x8a' for the image file to prevent the value from
  56. # being treated as UTF-8 (the character is invalid)
  57. self.actual_image = self.base + '\x8a' + '-png' + 'tEXtchecksum\x00' + self.actual_checksum
  58. self.expected_text = self.actual_text
  59. self.expected_image = self.actual_image
  60. self.actual_audio = None
  61. self.expected_audio = None
  62. # This is an in-memory list of tests, what we want them to produce, and
  63. # what we want to claim are the expected results.
  64. class TestList(object):
  65. def __init__(self):
  66. self.tests = {}
  67. def add(self, name, **kwargs):
  68. test = TestInstance(name)
  69. for key, value in kwargs.items():
  70. test.__dict__[key] = value
  71. self.tests[name] = test
  72. def add_reftest(self, name, reference_name, same_image):
  73. self.add(name, actual_checksum='xxx', actual_image='XXX', is_reftest=True)
  74. if same_image:
  75. self.add(reference_name, actual_checksum='xxx', actual_image='XXX', is_reftest=True)
  76. else:
  77. self.add(reference_name, actual_checksum='yyy', actual_image='YYY', is_reftest=True)
  78. def keys(self):
  79. return self.tests.keys()
  80. def __contains__(self, item):
  81. return item in self.tests
  82. def __getitem__(self, item):
  83. return self.tests[item]
  84. #
  85. # These numbers may need to be updated whenever we add or delete tests.
  86. #
  87. TOTAL_TESTS = 104
  88. TOTAL_SKIPS = 28
  89. TOTAL_RETRIES = 14
  90. UNEXPECTED_PASSES = 6
  91. UNEXPECTED_FAILURES = 17
  92. def unit_test_list():
  93. tests = TestList()
  94. tests.add('failures/expected/crash.html', crash=True)
  95. tests.add('failures/expected/exception.html', exception=True)
  96. tests.add('failures/expected/timeout.html', timeout=True)
  97. tests.add('failures/expected/hang.html', hang=True)
  98. tests.add('failures/expected/missing_text.html', expected_text=None)
  99. tests.add('failures/expected/image.html',
  100. actual_image='image_fail-pngtEXtchecksum\x00checksum_fail',
  101. expected_image='image-pngtEXtchecksum\x00checksum-png')
  102. tests.add('failures/expected/image_checksum.html',
  103. actual_checksum='image_checksum_fail-checksum',
  104. actual_image='image_checksum_fail-png')
  105. tests.add('failures/expected/audio.html',
  106. actual_audio=base64.b64encode('audio_fail-wav'), expected_audio='audio-wav',
  107. actual_text=None, expected_text=None,
  108. actual_image=None, expected_image=None,
  109. actual_checksum=None)
  110. tests.add('failures/expected/keyboard.html', keyboard=True)
  111. tests.add('failures/expected/missing_check.html',
  112. expected_image='missing_check-png')
  113. tests.add('failures/expected/missing_image.html', expected_image=None)
  114. tests.add('failures/expected/missing_audio.html', expected_audio=None,
  115. actual_text=None, expected_text=None,
  116. actual_image=None, expected_image=None,
  117. actual_checksum=None)
  118. tests.add('failures/expected/missing_text.html', expected_text=None)
  119. tests.add('failures/expected/newlines_leading.html',
  120. expected_text="\nfoo\n", actual_text="foo\n")
  121. tests.add('failures/expected/newlines_trailing.html',
  122. expected_text="foo\n\n", actual_text="foo\n")
  123. tests.add('failures/expected/newlines_with_excess_CR.html',
  124. expected_text="foo\r\r\r\n", actual_text="foo\n")
  125. tests.add('failures/expected/text.html', actual_text='text_fail-png')
  126. tests.add('failures/expected/skip_text.html', actual_text='text diff')
  127. tests.add('failures/flaky/text.html')
  128. tests.add('failures/unexpected/missing_text.html', expected_text=None)
  129. tests.add('failures/unexpected/missing_check.html', expected_image='missing-check-png')
  130. tests.add('failures/unexpected/missing_image.html', expected_image=None)
  131. tests.add('failures/unexpected/missing_render_tree_dump.html', actual_text="""layer at (0,0) size 800x600
  132. RenderView at (0,0) size 800x600
  133. layer at (0,0) size 800x34
  134. RenderBlock {HTML} at (0,0) size 800x34
  135. RenderBody {BODY} at (8,8) size 784x18
  136. RenderText {#text} at (0,0) size 133x18
  137. text run at (0,0) width 133: "This is an image test!"
  138. """, expected_text=None)
  139. tests.add('failures/unexpected/crash.html', crash=True)
  140. tests.add('failures/unexpected/crash-with-stderr.html', crash=True,
  141. error="mock-std-error-output")
  142. tests.add('failures/unexpected/web-process-crash-with-stderr.html', web_process_crash=True,
  143. error="mock-std-error-output")
  144. tests.add('failures/unexpected/pass.html')
  145. tests.add('failures/unexpected/text-checksum.html',
  146. actual_text='text-checksum_fail-txt',
  147. actual_checksum='text-checksum_fail-checksum')
  148. tests.add('failures/unexpected/text-image-checksum.html',
  149. actual_text='text-image-checksum_fail-txt',
  150. actual_image='text-image-checksum_fail-pngtEXtchecksum\x00checksum_fail',
  151. actual_checksum='text-image-checksum_fail-checksum')
  152. tests.add('failures/unexpected/checksum-with-matching-image.html',
  153. actual_checksum='text-image-checksum_fail-checksum')
  154. tests.add('failures/unexpected/skip_pass.html')
  155. tests.add('failures/unexpected/text.html', actual_text='text_fail-txt')
  156. tests.add('failures/unexpected/timeout.html', timeout=True)
  157. tests.add('http/tests/passes/text.html')
  158. tests.add('http/tests/passes/image.html')
  159. tests.add('http/tests/ssl/text.html')
  160. tests.add('passes/args.html')
  161. tests.add('passes/error.html', error='stuff going to stderr')
  162. tests.add('passes/image.html')
  163. tests.add('passes/audio.html',
  164. actual_audio=base64.b64encode('audio-wav'), expected_audio='audio-wav',
  165. actual_text=None, expected_text=None,
  166. actual_image=None, expected_image=None,
  167. actual_checksum=None)
  168. tests.add('passes/platform_image.html')
  169. tests.add('passes/checksum_in_image.html',
  170. expected_image='tEXtchecksum\x00checksum_in_image-checksum')
  171. tests.add('passes/skipped/skip.html')
  172. # Note that here the checksums don't match but the images do, so this test passes "unexpectedly".
  173. # See https://bugs.webkit.org/show_bug.cgi?id=69444 .
  174. tests.add('failures/unexpected/checksum.html', actual_checksum='checksum_fail-checksum')
  175. # Text output files contain "\r\n" on Windows. This may be
  176. # helpfully filtered to "\r\r\n" by our Python/Cygwin tooling.
  177. tests.add('passes/text.html',
  178. expected_text='\nfoo\n\n', actual_text='\nfoo\r\n\r\r\n')
  179. # For reftests.
  180. tests.add_reftest('passes/reftest.html', 'passes/reftest-expected.html', same_image=True)
  181. tests.add_reftest('passes/mismatch.html', 'passes/mismatch-expected-mismatch.html', same_image=False)
  182. tests.add_reftest('passes/svgreftest.svg', 'passes/svgreftest-expected.svg', same_image=True)
  183. tests.add_reftest('passes/xhtreftest.xht', 'passes/xhtreftest-expected.html', same_image=True)
  184. tests.add_reftest('passes/phpreftest.php', 'passes/phpreftest-expected-mismatch.svg', same_image=False)
  185. tests.add_reftest('failures/expected/reftest.html', 'failures/expected/reftest-expected.html', same_image=False)
  186. tests.add_reftest('failures/expected/mismatch.html', 'failures/expected/mismatch-expected-mismatch.html', same_image=True)
  187. tests.add_reftest('failures/unexpected/reftest.html', 'failures/unexpected/reftest-expected.html', same_image=False)
  188. tests.add_reftest('failures/unexpected/mismatch.html', 'failures/unexpected/mismatch-expected-mismatch.html', same_image=True)
  189. tests.add('failures/unexpected/reftest-nopixel.html', actual_checksum=None, actual_image=None, is_reftest=True)
  190. tests.add('failures/unexpected/reftest-nopixel-expected.html', actual_checksum=None, actual_image=None, is_reftest=True)
  191. # FIXME: Add a reftest which crashes.
  192. tests.add('reftests/foo/test.html')
  193. tests.add('reftests/foo/test-ref.html')
  194. tests.add('reftests/foo/multiple-match-success.html', actual_checksum='abc', actual_image='abc')
  195. tests.add('reftests/foo/multiple-match-failure.html', actual_checksum='abc', actual_image='abc')
  196. tests.add('reftests/foo/multiple-mismatch-success.html', actual_checksum='abc', actual_image='abc')
  197. tests.add('reftests/foo/multiple-mismatch-failure.html', actual_checksum='abc', actual_image='abc')
  198. tests.add('reftests/foo/multiple-both-success.html', actual_checksum='abc', actual_image='abc')
  199. tests.add('reftests/foo/multiple-both-failure.html', actual_checksum='abc', actual_image='abc')
  200. tests.add('reftests/foo/matching-ref.html', actual_checksum='abc', actual_image='abc')
  201. tests.add('reftests/foo/mismatching-ref.html', actual_checksum='def', actual_image='def')
  202. tests.add('reftests/foo/second-mismatching-ref.html', actual_checksum='ghi', actual_image='ghi')
  203. # The following files shouldn't be treated as reftests
  204. tests.add_reftest('reftests/foo/unlistedtest.html', 'reftests/foo/unlistedtest-expected.html', same_image=True)
  205. tests.add('reftests/foo/reference/bar/common.html')
  206. tests.add('reftests/foo/reftest/bar/shared.html')
  207. tests.add('websocket/tests/passes/text.html')
  208. # For testing test are properly included from platform directories.
  209. tests.add('platform/test-mac-leopard/http/test.html')
  210. tests.add('platform/test-win-win7/http/test.html')
  211. # For --no-http tests, test that platform specific HTTP tests are properly skipped.
  212. tests.add('platform/test-snow-leopard/http/test.html')
  213. tests.add('platform/test-snow-leopard/websocket/test.html')
  214. # For testing if perf tests are running in a locked shard.
  215. tests.add('perf/foo/test.html')
  216. tests.add('perf/foo/test-ref.html')
  217. # For testing --pixel-test-directories.
  218. tests.add('failures/unexpected/pixeldir/image_in_pixeldir.html',
  219. actual_image='image_in_pixeldir-pngtEXtchecksum\x00checksum_fail',
  220. expected_image='image_in_pixeldir-pngtEXtchecksum\x00checksum-png')
  221. tests.add('failures/unexpected/image_not_in_pixeldir.html',
  222. actual_image='image_not_in_pixeldir-pngtEXtchecksum\x00checksum_fail',
  223. expected_image='image_not_in_pixeldir-pngtEXtchecksum\x00checksum-png')
  224. # For testing that virtual test suites don't expand names containing themselves
  225. # See webkit.org/b/97925 and base_unittest.PortTest.test_tests().
  226. tests.add('passes/test-virtual-passes.html')
  227. tests.add('passes/passes/test-virtual-passes.html')
  228. return tests
  229. # Here we use a non-standard location for the layout tests, to ensure that
  230. # this works. The path contains a '.' in the name because we've seen bugs
  231. # related to this before.
  232. LAYOUT_TEST_DIR = '/test.checkout/LayoutTests'
  233. PERF_TEST_DIR = '/test.checkout/PerformanceTests'
  234. # Here we synthesize an in-memory filesystem from the test list
  235. # in order to fully control the test output and to demonstrate that
  236. # we don't need a real filesystem to run the tests.
  237. def add_unit_tests_to_mock_filesystem(filesystem):
  238. # Add the test_expectations file.
  239. filesystem.maybe_make_directory(LAYOUT_TEST_DIR + '/platform/test')
  240. if not filesystem.exists(LAYOUT_TEST_DIR + '/platform/test/TestExpectations'):
  241. filesystem.write_text_file(LAYOUT_TEST_DIR + '/platform/test/TestExpectations', """
  242. Bug(test) failures/expected/crash.html [ Crash ]
  243. Bug(test) failures/expected/image.html [ ImageOnlyFailure ]
  244. Bug(test) failures/expected/audio.html [ Failure ]
  245. Bug(test) failures/expected/image_checksum.html [ ImageOnlyFailure ]
  246. Bug(test) failures/expected/mismatch.html [ ImageOnlyFailure ]
  247. Bug(test) failures/expected/missing_check.html [ Missing Pass ]
  248. Bug(test) failures/expected/missing_image.html [ Missing Pass ]
  249. Bug(test) failures/expected/missing_audio.html [ Missing Pass ]
  250. Bug(test) failures/expected/missing_text.html [ Missing Pass ]
  251. Bug(test) failures/expected/newlines_leading.html [ Failure ]
  252. Bug(test) failures/expected/newlines_trailing.html [ Failure ]
  253. Bug(test) failures/expected/newlines_with_excess_CR.html [ Failure ]
  254. Bug(test) failures/expected/reftest.html [ ImageOnlyFailure ]
  255. Bug(test) failures/expected/text.html [ Failure ]
  256. Bug(test) failures/expected/timeout.html [ Timeout ]
  257. Bug(test) failures/expected/hang.html [ WontFix ]
  258. Bug(test) failures/expected/keyboard.html [ WontFix ]
  259. Bug(test) failures/expected/exception.html [ WontFix ]
  260. Bug(test) failures/unexpected/pass.html [ Failure ]
  261. Bug(test) passes/skipped/skip.html [ Skip ]
  262. """)
  263. filesystem.maybe_make_directory(LAYOUT_TEST_DIR + '/reftests/foo')
  264. filesystem.write_text_file(LAYOUT_TEST_DIR + '/reftests/foo/reftest.list', """
  265. == test.html test-ref.html
  266. == multiple-match-success.html mismatching-ref.html
  267. == multiple-match-success.html matching-ref.html
  268. == multiple-match-failure.html mismatching-ref.html
  269. == multiple-match-failure.html second-mismatching-ref.html
  270. != multiple-mismatch-success.html mismatching-ref.html
  271. != multiple-mismatch-success.html second-mismatching-ref.html
  272. != multiple-mismatch-failure.html mismatching-ref.html
  273. != multiple-mismatch-failure.html matching-ref.html
  274. == multiple-both-success.html matching-ref.html
  275. == multiple-both-success.html mismatching-ref.html
  276. != multiple-both-success.html second-mismatching-ref.html
  277. == multiple-both-failure.html matching-ref.html
  278. != multiple-both-failure.html second-mismatching-ref.html
  279. != multiple-both-failure.html matching-ref.html
  280. """)
  281. # FIXME: This test was only being ignored because of missing a leading '/'.
  282. # Fixing the typo causes several tests to assert, so disabling the test entirely.
  283. # Add in a file should be ignored by port.find_test_files().
  284. #files[LAYOUT_TEST_DIR + '/userscripts/resources/iframe.html'] = 'iframe'
  285. def add_file(test, suffix, contents):
  286. dirname = filesystem.join(LAYOUT_TEST_DIR, test.name[0:test.name.rfind('/')])
  287. base = test.base
  288. filesystem.maybe_make_directory(dirname)
  289. filesystem.write_binary_file(filesystem.join(dirname, base + suffix), contents)
  290. # Add each test and the expected output, if any.
  291. test_list = unit_test_list()
  292. for test in test_list.tests.values():
  293. add_file(test, test.name[test.name.rfind('.'):], '')
  294. if test.is_reftest:
  295. continue
  296. if test.actual_audio:
  297. add_file(test, '-expected.wav', test.expected_audio)
  298. continue
  299. add_file(test, '-expected.txt', test.expected_text)
  300. add_file(test, '-expected.png', test.expected_image)
  301. filesystem.write_text_file(filesystem.join(LAYOUT_TEST_DIR, 'virtual', 'passes', 'args-expected.txt'), 'args-txt --virtual-arg')
  302. # Clear the list of written files so that we can watch what happens during testing.
  303. filesystem.clear_written_files()
  304. class TestPort(Port):
  305. port_name = 'test'
  306. default_port_name = 'test-mac-leopard'
  307. """Test implementation of the Port interface."""
  308. ALL_BASELINE_VARIANTS = (
  309. 'test-linux-x86_64',
  310. 'test-mac-snowleopard', 'test-mac-leopard',
  311. 'test-win-vista', 'test-win-win7', 'test-win-xp',
  312. )
  313. @classmethod
  314. def determine_full_port_name(cls, host, options, port_name):
  315. if port_name == 'test':
  316. return TestPort.default_port_name
  317. return port_name
  318. def __init__(self, host, port_name=None, **kwargs):
  319. Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs)
  320. self._tests = unit_test_list()
  321. self._flakes = set()
  322. self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/TestExpectations'
  323. self._results_directory = None
  324. self._operating_system = 'mac'
  325. if self._name.startswith('test-win'):
  326. self._operating_system = 'win'
  327. elif self._name.startswith('test-linux'):
  328. self._operating_system = 'linux'
  329. version_map = {
  330. 'test-win-xp': 'xp',
  331. 'test-win-win7': 'win7',
  332. 'test-win-vista': 'vista',
  333. 'test-mac-leopard': 'leopard',
  334. 'test-mac-snowleopard': 'snowleopard',
  335. 'test-linux-x86_64': 'lucid',
  336. }
  337. self._version = version_map[self._name]
  338. def default_pixel_tests(self):
  339. return True
  340. def _path_to_driver(self):
  341. # This routine shouldn't normally be called, but it is called by
  342. # the mock_drt Driver. We return something, but make sure it's useless.
  343. return 'MOCK _path_to_driver'
  344. def baseline_search_path(self):
  345. search_paths = {
  346. 'test-mac-snowleopard': ['test-mac-snowleopard'],
  347. 'test-mac-leopard': ['test-mac-leopard', 'test-mac-snowleopard'],
  348. 'test-win-win7': ['test-win-win7'],
  349. 'test-win-vista': ['test-win-vista', 'test-win-win7'],
  350. 'test-win-xp': ['test-win-xp', 'test-win-vista', 'test-win-win7'],
  351. 'test-linux-x86_64': ['test-linux', 'test-win-win7'],
  352. }
  353. return [self._webkit_baseline_path(d) for d in search_paths[self.name()]]
  354. def default_child_processes(self):
  355. return 1
  356. def worker_startup_delay_secs(self):
  357. return 0
  358. def check_build(self, needs_http):
  359. return True
  360. def check_sys_deps(self, needs_http):
  361. return True
  362. def default_configuration(self):
  363. return 'Release'
  364. def diff_image(self, expected_contents, actual_contents, tolerance=None):
  365. diffed = actual_contents != expected_contents
  366. if not actual_contents and not expected_contents:
  367. return (None, 0, None)
  368. if not actual_contents or not expected_contents:
  369. return (True, 0, None)
  370. if 'ref' in expected_contents:
  371. assert tolerance == 0
  372. if diffed:
  373. return ("< %s\n---\n> %s\n" % (expected_contents, actual_contents), 1, None)
  374. return (None, 0, None)
  375. def layout_tests_dir(self):
  376. return LAYOUT_TEST_DIR
  377. def perf_tests_dir(self):
  378. return PERF_TEST_DIR
  379. def webkit_base(self):
  380. return '/test.checkout'
  381. def _skipped_tests_for_unsupported_features(self, test_list):
  382. return set(['failures/expected/skip_text.html',
  383. 'failures/unexpected/skip_pass.html',
  384. 'virtual/skipped'])
  385. def name(self):
  386. return self._name
  387. def operating_system(self):
  388. return self._operating_system
  389. def _path_to_wdiff(self):
  390. return None
  391. def default_results_directory(self):
  392. return '/tmp/layout-test-results'
  393. def setup_test_run(self):
  394. pass
  395. def _driver_class(self):
  396. return TestDriver
  397. def start_http_server(self, additional_dirs=None, number_of_servers=None):
  398. pass
  399. def start_websocket_server(self):
  400. pass
  401. def acquire_http_lock(self):
  402. pass
  403. def stop_http_server(self):
  404. pass
  405. def stop_websocket_server(self):
  406. pass
  407. def release_http_lock(self):
  408. pass
  409. def _path_to_lighttpd(self):
  410. return "/usr/sbin/lighttpd"
  411. def _path_to_lighttpd_modules(self):
  412. return "/usr/lib/lighttpd"
  413. def _path_to_lighttpd_php(self):
  414. return "/usr/bin/php-cgi"
  415. def _path_to_apache(self):
  416. return "/usr/sbin/httpd"
  417. def _path_to_apache_config_file(self):
  418. return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'httpd.conf')
  419. def path_to_test_expectations_file(self):
  420. return self._expectations_path
  421. def all_test_configurations(self):
  422. """Returns a sequence of the TestConfigurations the port supports."""
  423. # By default, we assume we want to test every graphics type in
  424. # every configuration on every system.
  425. test_configurations = []
  426. for version, architecture in self._all_systems():
  427. for build_type in self._all_build_types():
  428. test_configurations.append(TestConfiguration(
  429. version=version,
  430. architecture=architecture,
  431. build_type=build_type))
  432. return test_configurations
  433. def _all_systems(self):
  434. return (('leopard', 'x86'),
  435. ('snowleopard', 'x86'),
  436. ('xp', 'x86'),
  437. ('vista', 'x86'),
  438. ('win7', 'x86'),
  439. ('lucid', 'x86'),
  440. ('lucid', 'x86_64'))
  441. def _all_build_types(self):
  442. return ('debug', 'release')
  443. def configuration_specifier_macros(self):
  444. """To avoid surprises when introducing new macros, these are intentionally fixed in time."""
  445. return {'mac': ['leopard', 'snowleopard'], 'win': ['xp', 'vista', 'win7'], 'linux': ['lucid']}
  446. def all_baseline_variants(self):
  447. return self.ALL_BASELINE_VARIANTS
  448. def virtual_test_suites(self):
  449. return [
  450. VirtualTestSuite('virtual/passes', 'passes', ['--virtual-arg']),
  451. VirtualTestSuite('virtual/skipped', 'failures/expected', ['--virtual-arg2']),
  452. ]
  453. class TestDriver(Driver):
  454. """Test/Dummy implementation of the DumpRenderTree interface."""
  455. next_pid = 1
  456. def __init__(self, *args, **kwargs):
  457. super(TestDriver, self).__init__(*args, **kwargs)
  458. self.started = False
  459. self.pid = 0
  460. def cmd_line(self, pixel_tests, per_test_args):
  461. pixel_tests_flag = '-p' if pixel_tests else ''
  462. return [self._port._path_to_driver()] + [pixel_tests_flag] + self._port.get_option('additional_drt_flag', []) + per_test_args
  463. def run_test(self, test_input, stop_when_done):
  464. if not self.started:
  465. self.started = True
  466. self.pid = TestDriver.next_pid
  467. TestDriver.next_pid += 1
  468. start_time = time.time()
  469. test_name = test_input.test_name
  470. test_args = test_input.args or []
  471. test = self._port._tests[test_name]
  472. if test.keyboard:
  473. raise KeyboardInterrupt
  474. if test.exception:
  475. raise ValueError('exception from ' + test_name)
  476. if test.hang:
  477. time.sleep((float(test_input.timeout) * 4) / 1000.0 + 1.0) # The 1.0 comes from thread_padding_sec in layout_test_runnery.
  478. audio = None
  479. actual_text = test.actual_text
  480. if 'flaky' in test_name and not test_name in self._port._flakes:
  481. self._port._flakes.add(test_name)
  482. actual_text = 'flaky text failure'
  483. if actual_text and test_args and test_name == 'passes/args.html':
  484. actual_text = actual_text + ' ' + ' '.join(test_args)
  485. if test.actual_audio:
  486. audio = base64.b64decode(test.actual_audio)
  487. crashed_process_name = None
  488. crashed_pid = None
  489. if test.crash:
  490. crashed_process_name = self._port.driver_name()
  491. crashed_pid = 1
  492. elif test.web_process_crash:
  493. crashed_process_name = 'WebProcess'
  494. crashed_pid = 2
  495. crash_log = ''
  496. if crashed_process_name:
  497. crash_logs = CrashLogs(self._port.host)
  498. crash_log = crash_logs.find_newest_log(crashed_process_name, None) or ''
  499. if stop_when_done:
  500. self.stop()
  501. if test.actual_checksum == test_input.image_hash:
  502. image = None
  503. else:
  504. image = test.actual_image
  505. return DriverOutput(actual_text, image, test.actual_checksum, audio,
  506. crash=test.crash or test.web_process_crash, crashed_process_name=crashed_process_name,
  507. crashed_pid=crashed_pid, crash_log=crash_log,
  508. test_time=time.time() - start_time, timeout=test.timeout, error=test.error, pid=self.pid)
  509. def stop(self):
  510. self.started = False