Changeset 127512 in webkit


Ignore:
Timestamp:
Sep 4, 2012 3:14:36 PM (12 years ago)
Author:
wangxianzhu@chromium.org
Message:

[Chromium-Android] Include device serial number in ChromiumAndroidDriver log messages
https://bugs.webkit.org/show_bug.cgi?id=95770

Reviewed by Adam Barth.

  • Scripts/webkitpy/layout_tests/port/chromium_android.py:

(ChromiumAndroidDriver.init):
(ChromiumAndroidDriver._log_error): Added to replace original _log.error().
(ChromiumAndroidDriver._log_debug): Added to replace original _log.debug().
(ChromiumAndroidDriver._abort): Added to replace original raise AssertionError().
(ChromiumAndroidDriver._push_executable):
(ChromiumAndroidDriver._push_fonts):
(ChromiumAndroidDriver._push_test_resources):
(ChromiumAndroidDriver._run_adb_command):
(ChromiumAndroidDriver._get_last_stacktrace):
(ChromiumAndroidDriver._get_crash_log):
(ChromiumAndroidDriver._start):
(ChromiumAndroidDriver._start_once):
(ChromiumAndroidDriver._start_once.deadlock_detector):

  • Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py:

(ChromiumAndroidDriverTest.test_get_crash_log):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r127507 r127512  
     12012-09-04  Xianzhu Wang  <wangxianzhu@chromium.org>
     2
     3        [Chromium-Android] Include device serial number in ChromiumAndroidDriver log messages
     4        https://bugs.webkit.org/show_bug.cgi?id=95770
     5
     6        Reviewed by Adam Barth.
     7
     8        * Scripts/webkitpy/layout_tests/port/chromium_android.py:
     9        (ChromiumAndroidDriver.__init__):
     10        (ChromiumAndroidDriver._log_error): Added to replace original _log.error().
     11        (ChromiumAndroidDriver._log_debug): Added to replace original _log.debug().
     12        (ChromiumAndroidDriver._abort): Added to replace original raise AssertionError().
     13        (ChromiumAndroidDriver._push_executable):
     14        (ChromiumAndroidDriver._push_fonts):
     15        (ChromiumAndroidDriver._push_test_resources):
     16        (ChromiumAndroidDriver._run_adb_command):
     17        (ChromiumAndroidDriver._get_last_stacktrace):
     18        (ChromiumAndroidDriver._get_crash_log):
     19        (ChromiumAndroidDriver._start):
     20        (ChromiumAndroidDriver._start_once):
     21        (ChromiumAndroidDriver._start_once.deadlock_detector):
     22        * Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py:
     23        (ChromiumAndroidDriverTest.test_get_crash_log):
     24
    1252012-09-04  Satish Sampath  <satish@chromium.org>
    226
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py

    r127488 r127512  
    318318        self._has_setup = False
    319319        self._original_governors = {}
    320         self._adb_command = ['adb', '-s', port._get_device_serial(worker_number)]
     320        self._device_serial = port._get_device_serial(worker_number)
     321        self._adb_command = ['adb', '-s', self._device_serial]
    321322
    322323    def __del__(self):
     
    347348        # This is like what's done in ChromiumPort.setup_test_run but on the device.
    348349        self._run_adb_command(['shell', 'rm', '-r', DRT_APP_CACHE_DIR])
     350
     351    def _log_error(self, message):
     352        _log.error('[%s] %s' % (self._device_serial, message))
     353
     354    def _log_debug(self, message):
     355        _log.debug('[%s] %s' % (self._device_serial, message))
     356
     357    def _abort(self, message):
     358        raise AssertionError('[%s] %s' % (self._device_serial, message))
    349359
    350360    def _push_executable(self):
     
    356366            'shell', 'cat %s 2>/dev/null || echo 0' % DEVICE_DRT_STAMP_PATH])))
    357367        if device_stamp != host_stamp:
    358             _log.debug('Pushing executable')
     368            self._log_debug('Pushing executable')
    359369            self._push_to_device(forwarder_host_path, DEVICE_FORWARDER_PATH)
    360370            self._run_adb_command(['uninstall', DRT_APP_PACKAGE])
    361371            install_result = self._run_adb_command(['install', drt_host_path])
    362372            if install_result.find('Success') == -1:
    363                 raise AssertionError('Failed to install %s onto device: %s' % (drt_host_path, install_result))
     373                self._abort('Failed to install %s onto device: %s' % (drt_host_path, install_result))
    364374            self._push_to_device(self._port._build_path('DumpRenderTree.pak'), DEVICE_DRT_DIR + 'DumpRenderTree.pak')
    365375            self._push_to_device(self._port._build_path('DumpRenderTree_resources'), DEVICE_DRT_DIR + 'DumpRenderTree_resources')
     
    374384    def _push_fonts(self):
    375385        if not self._check_version(DEVICE_FONTS_DIR, FONT_FILES_VERSION):
    376             _log.debug('Pushing fonts')
     386            self._log_debug('Pushing fonts')
    377387            path_to_ahem_font = self._port._build_path('AHEM____.TTF')
    378388            self._push_to_device(path_to_ahem_font, DEVICE_FONTS_DIR + 'AHEM____.TTF')
     
    383393
    384394    def _push_test_resources(self):
    385         _log.debug('Pushing test resources')
     395        self._log_debug('Pushing test resources')
    386396        for resource in TEST_RESOURCES_TO_PUSH:
    387397            self._push_to_device(self._port.layout_tests_dir() + '/' + resource, DEVICE_LAYOUT_TESTS_DIR + resource)
     
    410420
    411421    def _run_adb_command(self, cmd, ignore_error=False):
    412         _log.debug('Run adb command: ' + str(cmd))
     422        self._log_debug('Run adb command: ' + str(cmd))
    413423        if ignore_error:
    414424            error_handler = self._port._executive.ignore_error
     
    418428        # Limit the length to avoid too verbose output of commands like 'adb logcat' and 'cat /data/tombstones/tombstone01'
    419429        # whose outputs are normally printed in later logs.
    420         _log.debug('Run adb result: ' + result[:80])
     430        self._log_debug('Run adb result: ' + result[:80])
    421431        return result
    422432
     
    435445        tombstones = self._run_adb_command(['shell', 'ls', '-n', '/data/tombstones'])
    436446        if not tombstones or tombstones.startswith('/data/tombstones: No such file or directory'):
    437             _log.error('DRT crashed, but no tombstone found!')
     447            self._log_error('DRT crashed, but no tombstone found!')
    438448            return ''
    439449        tombstones = tombstones.rstrip().split('\n')
     
    480490        if not stdout:
    481491            stdout = ''
    482         stdout += '********* Logcat:\n' + self._get_logcat()
     492        stdout += '********* [%s] Logcat:\n%s' % (self._device_serial, self._get_logcat())
    483493        if not stderr:
    484494            stderr = ''
    485         stderr += '********* Tombstone file:\n' + self._get_last_stacktrace()
     495        stderr += '********* [%s] Tombstone file:\n%s' % (self._device_serial, self._get_last_stacktrace())
    486496        return super(ChromiumAndroidDriver, self)._get_crash_log(stdout, stderr, newer_than)
    487497
     
    544554            if self._start_once(pixel_tests, per_test_args):
    545555                return
    546             _log.error('Failed to start DumpRenderTree application. Retries=%d. Log:%s' % (retries, self._get_logcat()))
     556            self._log_error('Failed to start DumpRenderTree application. Retries=%d. Log:%s' % (retries, self._get_logcat()))
    547557            self.stop()
    548558            time.sleep(2)
    549         raise AssertionError('Failed to start DumpRenderTree application multiple times. Give up.')
     559        self._abort('Failed to start DumpRenderTree application multiple times. Give up.')
    550560
    551561    def _start_once(self, pixel_tests, per_test_args):
    552562        super(ChromiumAndroidDriver, self)._start(pixel_tests, per_test_args)
    553563
    554         _log.debug('Starting forwarder')
     564        self._log_debug('Starting forwarder')
    555565        self._forwarder_process = self._port._server_process_constructor(
    556566            self._port, 'Forwarder', self._adb_command + ['shell', '%s -D %s' % (DEVICE_FORWARDER_PATH, FORWARD_PORTS)])
     
    561571        start_result = self._run_adb_command(['shell', 'am', 'start', '-e', 'RunInSubThread', '-n', DRT_ACTIVITY_FULL_NAME])
    562572        if start_result.find('Exception') != -1:
    563             _log.error('Failed to start DumpRenderTree application. Exception:\n' + start_result)
     573            self._log_error('Failed to start DumpRenderTree application. Exception:\n' + start_result)
    564574            return False
    565575
     
    571581        self._server_process.start()
    572582        self._read_prompt(deadline)
    573         _log.debug('Interactive shell started')
     583        self._log_debug('Interactive shell started')
    574584
    575585        # Start a process to read from the stdout fifo of the DumpRenderTree app and print to stdout.
    576         _log.debug('Redirecting stdout to ' + self._out_fifo_path)
     586        self._log_debug('Redirecting stdout to ' + self._out_fifo_path)
    577587        self._read_stdout_process = self._port._server_process_constructor(
    578588            self._port, 'ReadStdout', self._adb_command + ['shell', 'cat', self._out_fifo_path])
     
    580590
    581591        # Start a process to read from the stderr fifo of the DumpRenderTree app and print to stdout.
    582         _log.debug('Redirecting stderr to ' + self._err_fifo_path)
     592        self._log_debug('Redirecting stderr to ' + self._err_fifo_path)
    583593        self._read_stderr_process = self._port._server_process_constructor(
    584594            self._port, 'ReadStderr', self._adb_command + ['shell', 'cat', self._err_fifo_path])
    585595        self._read_stderr_process.start()
    586596
    587         _log.debug('Redirecting stdin to ' + self._in_fifo_path)
     597        self._log_debug('Redirecting stdin to ' + self._in_fifo_path)
    588598        self._server_process.write('cat >%s\n' % self._in_fifo_path)
    589599
     
    597607                # main thread escape from the deadlocked state. After that, the main thread will
    598608                # treat this as a crash.
    599                 _log.warn('Deadlock detected. Processes killed.')
     609                self._log_error('Deadlock detected. Processes killed.')
    600610                for i in processes:
    601611                    i.kill()
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py

    r124851 r127512  
    195195            ('err bar\n'
    196196             'err baz\n'
    197              '********* Tombstone file:\n'
     197             '********* [123456789ABCDEF0] Tombstone file:\n'
    198198             '-rw------- 1000 1000 45316 2012-04-27 16:33 tombstone_03\n'
    199199             '/data/tombstones/tombstone_03\n'
     
    202202             u'STDOUT: out bar\n'
    203203             u'STDOUT: out baz\n'
    204              u'STDOUT: ********* Logcat:\n'
     204             u'STDOUT: ********* [123456789ABCDEF0] Logcat:\n'
    205205             u'STDOUT: logcat contents\n'
    206206             u'STDERR: err bar\n'
    207207             u'STDERR: err baz\n'
    208              u'STDERR: ********* Tombstone file:\n'
     208             u'STDERR: ********* [123456789ABCDEF0] Tombstone file:\n'
    209209             u'STDERR: -rw------- 1000 1000 45316 2012-04-27 16:33 tombstone_03\n'
    210210             u'STDERR: /data/tombstones/tombstone_03\n'
     
    214214        self.driver._crashed_pid = None
    215215        self.assertEquals(self.driver._get_crash_log(None, None, newer_than=None),
    216             ('********* Tombstone file:\n'
     216            ('********* [123456789ABCDEF0] Tombstone file:\n'
    217217             '-rw------- 1000 1000 45316 2012-04-27 16:33 tombstone_03\n'
    218218             '/data/tombstones/tombstone_03\n'
    219219             'mock_contents\n',
    220220             u'crash log for <unknown process name> (pid <unknown>):\n'
    221              u'STDOUT: ********* Logcat:\n'
     221             u'STDOUT: ********* [123456789ABCDEF0] Logcat:\n'
    222222             u'STDOUT: logcat contents\n'
    223              u'STDERR: ********* Tombstone file:\n'
     223             u'STDERR: ********* [123456789ABCDEF0] Tombstone file:\n'
    224224             u'STDERR: -rw------- 1000 1000 45316 2012-04-27 16:33 tombstone_03\n'
    225225             u'STDERR: /data/tombstones/tombstone_03\n'
Note: See TracChangeset for help on using the changeset viewer.