| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Base class for linker-specific test cases. | 5 """Base class for linker-specific test cases. |
| 6 | 6 |
| 7 The custom dynamic linker can only be tested through a custom test case | 7 The custom dynamic linker can only be tested through a custom test case |
| 8 for various technical reasons: | 8 for various technical reasons: |
| 9 | 9 |
| 10 - It's an 'invisible feature', i.e. it doesn't expose a new API or | 10 - It's an 'invisible feature', i.e. it doesn't expose a new API or |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 - Enabling test support in the Linker code requires building a special | 23 - Enabling test support in the Linker code requires building a special |
| 24 APK with a flag to activate special test-only support code in the | 24 APK with a flag to activate special test-only support code in the |
| 25 Linker code itself. | 25 Linker code itself. |
| 26 | 26 |
| 27 Host-driven tests have also been tried, but since they're really | 27 Host-driven tests have also been tried, but since they're really |
| 28 sub-classes of instrumentation tests, they didn't work well either. | 28 sub-classes of instrumentation tests, they didn't work well either. |
| 29 | 29 |
| 30 To build and run the linker tests, do the following: | 30 To build and run the linker tests, do the following: |
| 31 | 31 |
| 32 ninja -C out/Debug content_linker_test_apk | 32 ninja -C out/Debug chromium_linker_test_apk |
| 33 build/android/test_runner.py linker | 33 build/android/test_runner.py linker |
| 34 | 34 |
| 35 """ | 35 """ |
| 36 # pylint: disable=R0201 | 36 # pylint: disable=R0201 |
| 37 | 37 |
| 38 import logging | 38 import logging |
| 39 import os | 39 import os |
| 40 import re | 40 import re |
| 41 import time | 41 import time |
| 42 | 42 |
| 43 from pylib import constants | 43 from pylib import constants |
| 44 from pylib import android_commands | 44 from pylib import android_commands |
| 45 from pylib.base import base_test_result | 45 from pylib.base import base_test_result |
| 46 | 46 |
| 47 | 47 |
| 48 ResultType = base_test_result.ResultType | 48 ResultType = base_test_result.ResultType |
| 49 | 49 |
| 50 _PACKAGE_NAME = 'org.chromium.content_linker_test_apk' | 50 _PACKAGE_NAME = 'org.chromium.chromium_linker_test_apk' |
| 51 _ACTIVITY_NAME = '.ContentLinkerTestActivity' | 51 _ACTIVITY_NAME = '.ChromiumLinkerTestActivity' |
| 52 _COMMAND_LINE_FILE = '/data/local/tmp/content-linker-test-command-line' | 52 _COMMAND_LINE_FILE = '/data/local/tmp/chromium-linker-test-command-line' |
| 53 | 53 |
| 54 # Path to the Linker.java source file. | 54 # Path to the Linker.java source file. |
| 55 _LINKER_JAVA_SOURCE_PATH = ( | 55 _LINKER_JAVA_SOURCE_PATH = ( |
| 56 'content/public/android/java/src/org/chromium/content/app/Linker.java') | 56 'base/android/java/src/org/chromium/base/library_loader/Linker.java') |
| 57 | 57 |
| 58 # A regular expression used to extract the browser shared RELRO configuration | 58 # A regular expression used to extract the browser shared RELRO configuration |
| 59 # from the Java source file above. | 59 # from the Java source file above. |
| 60 _RE_LINKER_BROWSER_CONFIG = re.compile( | 60 _RE_LINKER_BROWSER_CONFIG = re.compile( |
| 61 r'.*BROWSER_SHARED_RELRO_CONFIG\s+=\s+' + | 61 r'.*BROWSER_SHARED_RELRO_CONFIG\s+=\s+' + |
| 62 'BROWSER_SHARED_RELRO_CONFIG_(\S+)\s*;.*', | 62 'BROWSER_SHARED_RELRO_CONFIG_(\S+)\s*;.*', |
| 63 re.MULTILINE | re.DOTALL) | 63 re.MULTILINE | re.DOTALL) |
| 64 | 64 |
| 65 # Logcat filters used during each test. Only the 'chromium' one is really | 65 # Logcat filters used during each test. Only the 'chromium' one is really |
| 66 # needed, but the logs are added to the TestResult in case of error, and | 66 # needed, but the logs are added to the TestResult in case of error, and |
| 67 # it is handy to have the 'content_android_linker' ones as well when | 67 # it is handy to have the 'chromium_android_linker' ones as well when |
| 68 # troubleshooting. | 68 # troubleshooting. |
| 69 _LOGCAT_FILTERS = [ '*:s', 'chromium:v', 'content_android_linker:v' ] | 69 _LOGCAT_FILTERS = [ '*:s', 'chromium:v', 'chromium_android_linker:v' ] |
| 70 #_LOGCAT_FILTERS = [ '*:v' ] ## DEBUG | 70 #_LOGCAT_FILTERS = [ '*:v' ] ## DEBUG |
| 71 | 71 |
| 72 # Regular expression used to match status lines in logcat. | 72 # Regular expression used to match status lines in logcat. |
| 73 re_status_line = re.compile(r'(BROWSER|RENDERER)_LINKER_TEST: (FAIL|SUCCESS)') | 73 re_status_line = re.compile(r'(BROWSER|RENDERER)_LINKER_TEST: (FAIL|SUCCESS)') |
| 74 | 74 |
| 75 # Regular expression used to mach library load addresses in logcat. | 75 # Regular expression used to mach library load addresses in logcat. |
| 76 re_library_address = re.compile( | 76 re_library_address = re.compile( |
| 77 r'(BROWSER|RENDERER)_LIBRARY_ADDRESS: (\S+) ([0-9A-Fa-f]+)') | 77 r'(BROWSER|RENDERER)_LIBRARY_ADDRESS: (\S+) ([0-9A-Fa-f]+)') |
| 78 | 78 |
| 79 | 79 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 # Note that this behaviour doesn't seem to happen when starting an | 545 # Note that this behaviour doesn't seem to happen when starting an |
| 546 # application 'normally', i.e. when using the application launcher to | 546 # application 'normally', i.e. when using the application launcher to |
| 547 # start the activity. | 547 # start the activity. |
| 548 logging.info('Ignoring system\'s low randomization of browser libraries' + | 548 logging.info('Ignoring system\'s low randomization of browser libraries' + |
| 549 ' for regular devices') | 549 ' for regular devices') |
| 550 | 550 |
| 551 if not renderer_status: | 551 if not renderer_status: |
| 552 return ResultType.FAIL, renderer_logs | 552 return ResultType.FAIL, renderer_logs |
| 553 | 553 |
| 554 return ResultType.PASS, logs | 554 return ResultType.PASS, logs |
| OLD | NEW |