def MoveOutputDeps(self): """Moves files from the output directory to the top level of |self._isolate_deps_dir|. Moves pak files from the output directory to to <isolate_deps_dir>/paks Moves files from the product directory to <isolate_deps_dir> """ # On Android, all pak files need to be in the top-level 'paks' directory. paks_dir = os.path.join(self._isolate_deps_dir, 'paks') os.mkdir(paks_dir) deps_out_dir = os.path.join( self._isolate_deps_dir, os.path.relpath( os.path.join(constants.GetOutDirectory(), os.pardir), constants.DIR_SOURCE_ROOT)) for root, _, filenames in os.walk(deps_out_dir): for filename in fnmatch.filter(filenames, '*.pak'): shutil.move(os.path.join(root, filename), paks_dir) # Move everything in PRODUCT_DIR to top level. deps_product_dir = os.path.join(deps_out_dir, constants.GetBuildType()) if os.path.isdir(deps_product_dir): for p in os.listdir(deps_product_dir): shutil.move(os.path.join(deps_product_dir, p), self._isolate_deps_dir) os.rmdir(deps_product_dir) os.rmdir(deps_out_dir)
def __init__(self, shard_index, test_server_port, test_server_path): """Sets up a Python driven test server on the host machine. Args: shard_index: Index of the current shard. test_server_port: Port to run the test server on. This is multiplexed with the shard index. To retrieve the real port access the member variable |port|. test_server_path: The path (relative to the root src dir) of the server """ self.host = _TEST_SERVER_HOST self.port = test_server_port + shard_index src_dir = constants.DIR_SOURCE_ROOT # Make dirs into a list of absolute paths. abs_dirs = [os.path.join(src_dir, d) for d in _PYTHONPATH_DIRS] # Add the generated python files to the path abs_dirs.extend([os.path.join(src_dir, 'out', constants.GetBuildType(), d) for d in _GENERATED_PYTHONPATH_DIRS]) current_python_path = os.environ.get('PYTHONPATH') extra_python_path = ':'.join(abs_dirs) if current_python_path: python_path = current_python_path + ':' + extra_python_path else: python_path = extra_python_path # NOTE: A separate python process is used to simplify getting the right # system path for finding includes. cmd = ['python', os.path.join(src_dir, test_server_path), '--log-to-console', ('--host=%s' % self.host), ('--port=%d' % self.port)] self._test_server_process = subprocess.Popen( cmd, env={'PYTHONPATH': python_path})
def DefaultConfigVariables(): # Note: This list must match the --config-vars in build/isolate.gypi return { 'CONFIGURATION_NAME': constants.GetBuildType(), 'OS': 'android', 'asan': '0', 'branding': 'Chromium', 'chromeos': '0', 'component': 'static_library', 'enable_pepper_cdms': '0', 'enable_plugins': '0', 'fastbuild': '0', 'icu_use_data_file_flag': '1', 'kasko': '0', 'lsan': '0', 'msan': '0', # TODO(maruel): This may not always be true. 'target_arch': 'arm', 'tsan': '0', 'use_custom_libcxx': '0', 'use_instrumented_libraries': '0', 'use_prebuilt_instrumented_libraries': '0', 'use_openssl': '0', 'use_ozone': '0', 'use_x11': '0', 'v8_use_external_startup_data': '1', 'msvs_version': '0', }
def __init__(self, test_server_spawner_port, device, tool): logging.info('Creating new spawner on port: %d.', test_server_spawner_port) self.server = BaseHTTPServer.HTTPServer(('', test_server_spawner_port), SpawningServerRequestHandler) self.server.device = device self.server.tool = tool self.server.test_server_instance = None self.server.build_type = constants.GetBuildType()
def DefaultConfigVariables(): return { 'CONFIGURATION_NAME': constants.GetBuildType(), 'OS': 'android', 'asan': '0', 'chromeos': '0', 'component': 'static_library', 'fastbuild': '0', 'icu_use_data_file_flag': '1', 'lsan': '0', # TODO(maruel): This may not always be true. 'target_arch': 'arm', 'use_openssl': '0', 'use_ozone': '0', 'v8_use_external_startup_data': '0', }
def _GenerateDepsDirUsingIsolate(suite_name): """Generate the dependency dir for the test suite using isolate. Args: suite_name: Name of the test suite (e.g. base_unittests). """ if os.path.isdir(constants.ISOLATE_DEPS_DIR): shutil.rmtree(constants.ISOLATE_DEPS_DIR) isolate_rel_path = _ISOLATE_FILE_PATHS.get(suite_name) if not isolate_rel_path: logging.info('Did not find an isolate file for the test suite.') return isolate_abs_path = os.path.join(constants.DIR_SOURCE_ROOT, isolate_rel_path) isolated_abs_path = os.path.join( constants.GetOutDirectory(), '%s.isolated' % suite_name) assert os.path.exists(isolate_abs_path) # This needs to be kept in sync with the cmd line options for isolate.py # in src/build/isolate.gypi. isolate_cmd = [ 'python', _ISOLATE_SCRIPT, 'remap', '--isolate', isolate_abs_path, '--isolated', isolated_abs_path, '--outdir', constants.ISOLATE_DEPS_DIR, '--path-variable', 'PRODUCT_DIR', constants.GetOutDirectory(), '--config-variable', 'OS', 'android', '--config-variable', 'component', 'static_library', '--config-variable', 'icu_use_data_file_flag', '0', '--config-variable', 'use_openssl', '0', ] assert not cmd_helper.RunCmd(isolate_cmd) # We're relying on the fact that timestamps are preserved # by the remap command (hardlinked). Otherwise, all the data # will be pushed to the device once we move to using time diff # instead of md5sum. Perform a sanity check here. for root, _, filenames in os.walk(constants.ISOLATE_DEPS_DIR): if filenames: linked_file = os.path.join(root, filenames[0]) orig_file = os.path.join( constants.DIR_SOURCE_ROOT, os.path.relpath(linked_file, constants.ISOLATE_DEPS_DIR)) if os.stat(linked_file).st_ino == os.stat(orig_file).st_ino: break else: raise Exception('isolate remap command did not use hardlinks.') # Delete excluded files as defined by _DEPS_EXCLUSION_LIST. old_cwd = os.getcwd() try: os.chdir(constants.ISOLATE_DEPS_DIR) excluded_paths = [x for y in _DEPS_EXCLUSION_LIST for x in glob.glob(y)] if excluded_paths: logging.info('Excluding the following from dependency list: %s', excluded_paths) for p in excluded_paths: if os.path.isdir(p): shutil.rmtree(p) else: os.remove(p) finally: os.chdir(old_cwd) # On Android, all pak files need to be in the top-level 'paks' directory. paks_dir = os.path.join(constants.ISOLATE_DEPS_DIR, 'paks') os.mkdir(paks_dir) for root, _, filenames in os.walk(os.path.join(constants.ISOLATE_DEPS_DIR, 'out')): for filename in fnmatch.filter(filenames, '*.pak'): shutil.move(os.path.join(root, filename), paks_dir) # Move everything in PRODUCT_DIR to top level. deps_product_dir = os.path.join(constants.ISOLATE_DEPS_DIR, 'out', constants.GetBuildType()) if os.path.isdir(deps_product_dir): for p in os.listdir(deps_product_dir): shutil.move(os.path.join(deps_product_dir, p), constants.ISOLATE_DEPS_DIR) os.rmdir(deps_product_dir) os.rmdir(os.path.join(constants.ISOLATE_DEPS_DIR, 'out'))