def _prepare_env(self, target): """Prepare the running environment.""" # Prepare `<target_name>.runfiles` directory runfiles_dir = self._runfiles_dir(target) shutil.rmtree(runfiles_dir, ignore_errors=True) os.mkdir(runfiles_dir) self._prepare_shared_libraries(target, runfiles_dir) self._prepare_test_data(target) # Prepare environments run_env = dict(os.environ) environ_add_path(run_env, 'LD_LIBRARY_PATH', runfiles_dir) run_lib_paths = config.get_item('cc_binary_config', 'run_lib_paths') if run_lib_paths: for path in run_lib_paths: if path.startswith('//'): path = path[2:] path = os.path.abspath(path) environ_add_path(run_env, 'LD_LIBRARY_PATH', path) java_home = config.get_item('java_config', 'java_home') if java_home: java_home = os.path.abspath(java_home) environ_add_path(run_env, 'PATH', os.path.join(java_home, 'bin')) return run_env
def _prepare_env(self, target): """Prepare the test environment. """ runfiles_dir = self._runfiles_dir(target) shutil.rmtree(runfiles_dir, ignore_errors=True) os.mkdir(runfiles_dir) # Make a symbolic link of build_dir because dynamic linked binary need to load shared # libraries from this path build_dir_name = os.path.basename(self.build_dir) os.symlink(os.path.abspath(self.build_dir), os.path.join(runfiles_dir, build_dir_name)) # Also make symbolic links for prebuilt shared libraries for prebuilt_file in self._get_prebuilt_files(target): src = os.path.abspath(prebuilt_file[0]) dst = os.path.join(runfiles_dir, prebuilt_file[1]) if os.path.lexists(dst): console.warning('Trying to make duplicate prebuilt symlink:\n' '%s -> %s\n' '%s -> %s already exists\n' 'skipped, should check duplicate prebuilt ' 'libraries' % (dst, src, dst, os.path.realpath(dst))) continue os.symlink(src, dst) self._prepare_test_data(target) run_env = dict(os.environ) environ_add_path(run_env, 'LD_LIBRARY_PATH', runfiles_dir) run_lib_paths = config.get_item('cc_binary_config', 'run_lib_paths') if run_lib_paths: for path in run_lib_paths: if path.startswith('//'): path = path[2:] path = os.path.abspath(path) environ_add_path(run_env, 'LD_LIBRARY_PATH', path) java_home = config.get_item('java_config', 'java_home') if java_home: java_home = os.path.abspath(java_home) environ_add_path(run_env, 'PATH', os.path.join(java_home, 'bin')) return run_env
def _prepare_env(self, target): """Prepare the test environment. """ runfiles_dir = self._runfiles_dir(target) shutil.rmtree(runfiles_dir, ignore_errors=True) os.mkdir(runfiles_dir) # Build profile symlink profile_link_name = os.path.basename(self.build_dir) os.symlink(os.path.abspath(self.build_dir), os.path.join(runfiles_dir, profile_link_name)) # Prebuilt library symlink for prebuilt_file in self._get_prebuilt_files(target): src = os.path.abspath(prebuilt_file[0]) dst = os.path.join(runfiles_dir, prebuilt_file[1]) if os.path.lexists(dst): console.warning('trying to make duplicate prebuilt symlink:\n' '%s -> %s\n' '%s -> %s already exists\n' 'skipped, should check duplicate prebuilt ' 'libraries' % (dst, src, dst, os.path.realpath(dst))) continue os.symlink(src, dst) self._prepare_test_data(target) run_env = dict(os.environ) environ_add_path(run_env, 'LD_LIBRARY_PATH', runfiles_dir) run_lib_paths = config.get_item('cc_binary_config', 'run_lib_paths') if run_lib_paths: for path in run_lib_paths: if path.startswith('//'): path = path[2:] path = os.path.abspath(path) environ_add_path(run_env, 'LD_LIBRARY_PATH', path) java_home = config.get_item('java_config', 'java_home') if java_home: java_home = os.path.abspath(java_home) environ_add_path(run_env, 'PATH', os.path.join(java_home, 'bin')) return run_env