|
Lines 31-36
import copy
a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py_sec1
|
| 31 |
import logging |
31 |
import logging |
| 32 |
import os |
32 |
import os |
| 33 |
import re |
33 |
import re |
|
|
34 |
import sys |
| 34 |
import threading |
35 |
import threading |
| 35 |
import time |
36 |
import time |
| 36 |
|
37 |
|
|
Lines 39-44
from webkitpy.layout_tests.port import driver
a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py_sec2
|
| 39 |
from webkitpy.layout_tests.port import factory |
40 |
from webkitpy.layout_tests.port import factory |
| 40 |
from webkitpy.layout_tests.port import server_process |
41 |
from webkitpy.layout_tests.port import server_process |
| 41 |
|
42 |
|
|
|
43 |
sys.path.append( |
| 44 |
os.path.join(os.environ['CHROME_SRC'], 'build', 'android', 'pylib')) |
| 45 |
import android_commands |
| 42 |
|
46 |
|
| 43 |
_log = logging.getLogger(__name__) |
47 |
_log = logging.getLogger(__name__) |
| 44 |
|
48 |
|
|
Lines 54-60
COMMAND_LINE_FILE = DEVICE_SOURCE_ROOT_DIR + 'chrome-native-tests-command-line'
a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py_sec3
|
| 54 |
# and Chromium's webkit/support/platform_support_android.cc. |
58 |
# and Chromium's webkit/support/platform_support_android.cc. |
| 55 |
DEVICE_DRT_DIR = DEVICE_SOURCE_ROOT_DIR + 'drt/' |
59 |
DEVICE_DRT_DIR = DEVICE_SOURCE_ROOT_DIR + 'drt/' |
| 56 |
DEVICE_FORWARDER_PATH = DEVICE_DRT_DIR + 'forwarder' |
60 |
DEVICE_FORWARDER_PATH = DEVICE_DRT_DIR + 'forwarder' |
| 57 |
DEVICE_DRT_STAMP_PATH = DEVICE_DRT_DIR + 'DumpRenderTree.stamp' |
|
|
| 58 |
|
61 |
|
| 59 |
DRT_APP_PACKAGE = 'org.chromium.native_test' |
62 |
DRT_APP_PACKAGE = 'org.chromium.native_test' |
| 60 |
DRT_ACTIVITY_FULL_NAME = DRT_APP_PACKAGE + '/.ChromeNativeTestActivity' |
63 |
DRT_ACTIVITY_FULL_NAME = DRT_APP_PACKAGE + '/.ChromeNativeTestActivity' |
|
Lines 355-360
class ChromiumAndroidDriver(driver.Driver):
a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py_sec4
|
| 355 |
self._has_setup = False |
358 |
self._has_setup = False |
| 356 |
self._original_governors = {} |
359 |
self._original_governors = {} |
| 357 |
self._adb_command = ['adb', '-s', port._get_device_serial(worker_number)] |
360 |
self._adb_command = ['adb', '-s', port._get_device_serial(worker_number)] |
|
|
361 |
self._adb = android_commands.AndroidCommands() |
| 362 |
self._push_executable() |
| 363 |
self._push_fonts() |
| 364 |
self._push_test_resources() |
| 358 |
|
365 |
|
| 359 |
def __del__(self): |
366 |
def __del__(self): |
| 360 |
self._teardown_performance() |
367 |
self._teardown_performance() |
|
Lines 376-412
class ChromiumAndroidDriver(driver.Driver):
a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py_sec5
|
| 376 |
self._run_adb_command(['shell', 'mkdir', '-p', DEVICE_DRT_DIR]) |
383 |
self._run_adb_command(['shell', 'mkdir', '-p', DEVICE_DRT_DIR]) |
| 377 |
self._run_adb_command(['shell', 'chmod', '777', DEVICE_DRT_DIR]) |
384 |
self._run_adb_command(['shell', 'chmod', '777', DEVICE_DRT_DIR]) |
| 378 |
|
385 |
|
| 379 |
self._push_executable() |
|
|
| 380 |
self._push_fonts() |
| 381 |
self._synchronize_datetime() |
| 382 |
|
| 383 |
# Delete the disk cache if any to ensure a clean test run. |
386 |
# Delete the disk cache if any to ensure a clean test run. |
| 384 |
# This is like what's done in ChromiumPort.setup_test_run but on the device. |
387 |
# This is like what's done in ChromiumPort.setup_test_run but on the device. |
| 385 |
self._run_adb_command(['shell', 'rm', '-r', DRT_APP_CACHE_DIR]) |
388 |
self._run_adb_command(['shell', 'rm', '-r', DRT_APP_CACHE_DIR]) |
| 386 |
|
389 |
|
| 387 |
def _push_executable(self): |
390 |
def _push_executable(self): |
|
|
391 |
self._adb.PushIfNeeded(self._port._path_to_forwarder(), DEVICE_FORWARDER_PATH) |
| 392 |
self._adb.PushIfNeeded(self._port._build_path('DumpRenderTree.pak'), DEVICE_DRT_DIR + 'DumpRenderTree.pak') |
| 393 |
self._adb.PushIfNeeded(self._port._build_path('DumpRenderTree_resources'), DEVICE_DRT_DIR + 'DumpRenderTree_resources') |
| 394 |
self._adb.PushIfNeeded(self._port._build_path('android_main_fonts.xml'), DEVICE_DRT_DIR + 'android_main_fonts.xml') |
| 395 |
self._adb.PushIfNeeded(self._port._build_path('android_fallback_fonts.xml'), DEVICE_DRT_DIR + 'android_fallback_fonts.xml') |
| 396 |
_log.debug('Pushing executable') |
| 397 |
self._run_adb_command(['uninstall', DRT_APP_PACKAGE]) |
| 388 |
drt_host_path = self._port._path_to_driver() |
398 |
drt_host_path = self._port._path_to_driver() |
| 389 |
forwarder_host_path = self._port._path_to_forwarder() |
399 |
install_result = self._run_adb_command(['install', drt_host_path]) |
| 390 |
host_stamp = int(float(max(os.stat(drt_host_path).st_mtime, |
400 |
if install_result.find('Success') == -1: |
| 391 |
os.stat(forwarder_host_path).st_mtime))) |
401 |
raise AssertionError('Failed to install %s onto device: %s' % (drt_host_path, install_result)) |
| 392 |
device_stamp = int(float(self._run_adb_command([ |
|
|
| 393 |
'shell', 'cat %s 2>/dev/null || echo 0' % DEVICE_DRT_STAMP_PATH]))) |
| 394 |
if device_stamp != host_stamp: |
| 395 |
_log.debug('Pushing executable') |
| 396 |
self._push_to_device(forwarder_host_path, DEVICE_FORWARDER_PATH) |
| 397 |
self._run_adb_command(['uninstall', DRT_APP_PACKAGE]) |
| 398 |
install_result = self._run_adb_command(['install', drt_host_path]) |
| 399 |
if install_result.find('Success') == -1: |
| 400 |
raise AssertionError('Failed to install %s onto device: %s' % (drt_host_path, install_result)) |
| 401 |
self._push_to_device(self._port._build_path('DumpRenderTree.pak'), DEVICE_DRT_DIR + 'DumpRenderTree.pak') |
| 402 |
self._push_to_device(self._port._build_path('DumpRenderTree_resources'), DEVICE_DRT_DIR + 'DumpRenderTree_resources') |
| 403 |
self._push_to_device(self._port._build_path('android_main_fonts.xml'), DEVICE_DRT_DIR + 'android_main_fonts.xml') |
| 404 |
self._push_to_device(self._port._build_path('android_fallback_fonts.xml'), DEVICE_DRT_DIR + 'android_fallback_fonts.xml') |
| 405 |
# Version control of test resources is dependent on executables, |
| 406 |
# because we will always rebuild executables when resources are |
| 407 |
# updated. |
| 408 |
self._push_test_resources() |
| 409 |
self._run_adb_command(['shell', 'echo %d >%s' % (host_stamp, DEVICE_DRT_STAMP_PATH)]) |
| 410 |
|
402 |
|
| 411 |
def _push_fonts(self): |
403 |
def _push_fonts(self): |
| 412 |
if not self._check_version(DEVICE_FONTS_DIR, FONT_FILES_VERSION): |
404 |
if not self._check_version(DEVICE_FONTS_DIR, FONT_FILES_VERSION): |
|
Lines 421-438
class ChromiumAndroidDriver(driver.Driver):
a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py_sec6
|
| 421 |
def _push_test_resources(self): |
413 |
def _push_test_resources(self): |
| 422 |
_log.debug('Pushing test resources') |
414 |
_log.debug('Pushing test resources') |
| 423 |
for resource in TEST_RESOURCES_TO_PUSH: |
415 |
for resource in TEST_RESOURCES_TO_PUSH: |
| 424 |
self._push_to_device(self._port.layout_tests_dir() + '/' + resource, DEVICE_LAYOUT_TESTS_DIR + resource) |
416 |
self._adb.PushIfNeeded(self._port.layout_tests_dir() + '/' + resource, DEVICE_LAYOUT_TESTS_DIR + resource) |
| 425 |
|
|
|
| 426 |
def _synchronize_datetime(self): |
| 427 |
# The date/time between host and device may not be synchronized. |
| 428 |
# We need to make them synchronized, otherwise tests might fail. |
| 429 |
try: |
| 430 |
# Get seconds since 1970-01-01 00:00:00 UTC. |
| 431 |
host_datetime = self._port._executive.run_command(['date', '-u', '+%s']) |
| 432 |
except: |
| 433 |
# Reset to 1970-01-01 00:00:00 UTC. |
| 434 |
host_datetime = 0 |
| 435 |
self._run_adb_command(['shell', 'date -u %s' % (host_datetime)]) |
| 436 |
|
417 |
|
| 437 |
def _check_version(self, dir, version): |
418 |
def _check_version(self, dir, version): |
| 438 |
assert(dir.endswith('/')) |
419 |
assert(dir.endswith('/')) |
|
Lines 691-698
class ChromiumAndroidDriver(driver.Driver):
a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py_sec7
|
| 691 |
while True: |
672 |
while True: |
| 692 |
current_char = self._server_process.read_stdout(deadline, 1) |
673 |
current_char = self._server_process.read_stdout(deadline, 1) |
| 693 |
if current_char == ' ': |
674 |
if current_char == ' ': |
| 694 |
if last_char == '#': |
675 |
if last_char in ['#', '$']: |
| 695 |
return |
676 |
return |
| 696 |
if last_char == '$': |
|
|
| 697 |
raise AssertionError('Adbd is not running as root') |
| 698 |
last_char = current_char |
677 |
last_char = current_char |