qt.py 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. """QtWebKit implementation of the Port interface."""
  29. import glob
  30. import logging
  31. import re
  32. import sys
  33. import os
  34. from webkitpy.common.memoized import memoized
  35. from webkitpy.layout_tests.models.test_configuration import TestConfiguration
  36. from webkitpy.port.base import Port
  37. from webkitpy.port.xvfbdriver import XvfbDriver
  38. _log = logging.getLogger(__name__)
  39. class QtPort(Port):
  40. ALL_VERSIONS = ['linux', 'win', 'mac']
  41. port_name = "qt"
  42. def _wk2_port_name(self):
  43. return "qt-5.0-wk2"
  44. def _port_flag_for_scripts(self):
  45. return "--qt"
  46. @classmethod
  47. def determine_full_port_name(cls, host, options, port_name):
  48. if port_name and port_name != cls.port_name:
  49. return port_name
  50. return port_name + '-' + host.platform.os_name
  51. # sys_platform exists only for unit testing.
  52. def __init__(self, host, port_name, **kwargs):
  53. super(QtPort, self).__init__(host, port_name, **kwargs)
  54. # FIXME: This will allow Port.baseline_search_path
  55. # to do the right thing, but doesn't include support for qt-4.8 or qt-arm (seen in LayoutTests/platform) yet.
  56. self._operating_system = port_name.replace('qt-', '')
  57. # FIXME: Why is this being set at all?
  58. self._version = self.operating_system()
  59. def _generate_all_test_configurations(self):
  60. configurations = []
  61. for version in self.ALL_VERSIONS:
  62. for build_type in self.ALL_BUILD_TYPES:
  63. configurations.append(TestConfiguration(version=version, architecture='x86', build_type=build_type))
  64. return configurations
  65. def _build_driver(self):
  66. # The Qt port builds DRT as part of the main build step
  67. return True
  68. def supports_per_test_timeout(self):
  69. return True
  70. def _path_to_driver(self):
  71. return self._build_path('bin/%s' % self.driver_name())
  72. def _path_to_image_diff(self):
  73. return self._build_path('bin/ImageDiff')
  74. def _path_to_webcore_library(self):
  75. if self.operating_system() == 'mac':
  76. return self._build_path('lib/QtWebKitWidgets.framework/QtWebKitWidgets')
  77. else:
  78. return self._build_path('lib/libQt5WebKitWidgets.so')
  79. def _modules_to_search_for_symbols(self):
  80. # We search in every library to be reliable in the case of building with CONFIG+=force_static_libs_as_shared.
  81. if self.operating_system() == 'mac':
  82. frameworks = glob.glob(os.path.join(self._build_path('lib'), '*.framework'))
  83. return [os.path.join(framework, os.path.splitext(os.path.basename(framework))[0]) for framework in frameworks]
  84. else:
  85. suffix = 'dll' if self.operating_system() == 'win' else 'so'
  86. return glob.glob(os.path.join(self._build_path('lib'), 'lib*.' + suffix))
  87. @memoized
  88. def qt_version(self):
  89. version = ''
  90. try:
  91. for line in self._executive.run_command(['qmake', '-v']).split('\n'):
  92. match = re.search('Qt\sversion\s(?P<version>\d\.\d)', line)
  93. if match:
  94. version = match.group('version')
  95. break
  96. except OSError:
  97. version = '4.8'
  98. return version
  99. def _search_paths(self):
  100. # qt-5.0-mac-wk2
  101. # /
  102. # qt-5.0-wk1 qt-5.0-wk2
  103. # \/
  104. # qt-5.0
  105. # \
  106. # (qt-linux|qt-mac|qt-win)
  107. # |
  108. # qt
  109. search_paths = []
  110. version = self.qt_version()
  111. if '5.0' in version:
  112. if self.get_option('webkit_test_runner'):
  113. if self.operating_system() == 'mac':
  114. search_paths.append('qt-5.0-mac-wk2')
  115. search_paths.append('qt-5.0-wk2')
  116. else:
  117. search_paths.append('qt-5.0-wk1')
  118. search_paths.append('qt-5.0')
  119. search_paths.append(self.port_name + '-' + self.operating_system())
  120. search_paths.append(self.port_name)
  121. return search_paths
  122. def default_baseline_search_path(self):
  123. return map(self._webkit_baseline_path, self._search_paths())
  124. def _port_specific_expectations_files(self):
  125. paths = self._search_paths()
  126. if self.get_option('webkit_test_runner'):
  127. paths.append('wk2')
  128. # expectations_files() uses the directories listed in _search_paths reversed.
  129. # e.g. qt -> qt-linux -> qt-5.0 -> qt-5.0-wk1
  130. return list(reversed([self._filesystem.join(self._webkit_baseline_path(p), 'TestExpectations') for p in paths]))
  131. def setup_environ_for_server(self, server_name=None):
  132. clean_env = super(QtPort, self).setup_environ_for_server(server_name)
  133. clean_env['QTWEBKIT_PLUGIN_PATH'] = self._build_path('lib/plugins')
  134. self._copy_value_from_environ_if_set(clean_env, 'QT_DRT_WEBVIEW_MODE')
  135. self._copy_value_from_environ_if_set(clean_env, 'DYLD_IMAGE_SUFFIX')
  136. self._copy_value_from_environ_if_set(clean_env, 'QT_WEBKIT_LOG')
  137. self._copy_value_from_environ_if_set(clean_env, 'DISABLE_NI_WARNING')
  138. self._copy_value_from_environ_if_set(clean_env, 'QT_WEBKIT_PAUSE_UI_PROCESS')
  139. self._copy_value_from_environ_if_set(clean_env, 'QT_QPA_PLATFORM_PLUGIN_PATH')
  140. self._copy_value_from_environ_if_set(clean_env, 'QT_WEBKIT_DISABLE_UIPROCESS_DUMPPIXELS')
  141. return clean_env
  142. # FIXME: We should find a way to share this implmentation with Gtk,
  143. # or teach run-launcher how to call run-safari and move this down to Port.
  144. def show_results_html_file(self, results_filename):
  145. run_launcher_args = []
  146. if self.get_option('webkit_test_runner'):
  147. run_launcher_args.append('-2')
  148. run_launcher_args.append("file://%s" % results_filename)
  149. self._run_script("run-launcher", run_launcher_args)
  150. def operating_system(self):
  151. return self._operating_system
  152. def check_sys_deps(self, needs_http):
  153. result = super(QtPort, self).check_sys_deps(needs_http)
  154. if not 'WEBKIT_TESTFONTS' in os.environ:
  155. _log.error('\nThe WEBKIT_TESTFONTS environment variable is not defined or not set properly.')
  156. _log.error('You must set it before running the tests.')
  157. _log.error('Use git to grab the actual fonts from http://gitorious.org/qtwebkit/testfonts')
  158. return False
  159. return result
  160. # Qt port is not ready for parallel testing, see https://bugs.webkit.org/show_bug.cgi?id=77730 for details.
  161. def default_child_processes(self):
  162. return 1