Exemple #1
0
  def __enter__(self):
    """On entry, enters new temp directory after saving current directory.

    Raises:
      FatalError: error when temp directory cannot be constructed
    """
    self._save_dir = os.getcwd()
    self._results_dir = mkdtemp(dir='/tmp/')
    self._dexfuzz_dir = mkdtemp(dir=self._results_dir)
    self._inputs_dir = mkdtemp(dir=self._dexfuzz_dir)
    if self._results_dir is None or self._dexfuzz_dir is None or \
        self._inputs_dir is None:
      raise FatalError('Cannot obtain temp directory')
    self._dexfuzz_env = os.environ.copy()
    self._dexfuzz_env['ANDROID_DATA'] = self._dexfuzz_dir
    top = GetEnvVariableOrError('ANDROID_BUILD_TOP')
    self._dexfuzz_env['PATH'] = (top + '/art/tools/bisection_search:' +
                                 self._dexfuzz_env['PATH'])
    android_root = GetEnvVariableOrError('ANDROID_HOST_OUT')
    self._dexfuzz_env['ANDROID_ROOT'] = android_root
    self._dexfuzz_env['LD_LIBRARY_PATH'] = android_root + '/lib'
    os.chdir(self._dexfuzz_dir)
    os.mkdir('divergent_programs')
    os.mkdir('bisection_outputs')
    return self
 def RunBisectionSearch(self, args, expected_retcode, expected_output,
                        runner_id):
   ddir = self.GetCurrentDivergenceDir()
   outfile_path = ddir + '/' + runner_id + '_bisection_out.txt'
   logfile_path = ddir + '/' + runner_id + '_bisection_log.txt'
   errfile_path = ddir + '/' + runner_id + '_bisection_err.txt'
   args = list(args) + ['--logfile', logfile_path, '--cleanup']
   args += ['--expected-retcode', expected_retcode.name]
   if expected_output:
     args += ['--expected-output', expected_output]
   bisection_search_path = os.path.join(
       GetEnvVariableOrError('ANDROID_BUILD_TOP'),
       'art/tools/bisection_search/bisection_search.py')
   if RunCommand([bisection_search_path] + args, out=outfile_path,
                 err=errfile_path, timeout=300) == RetCode.TIMEOUT:
     print('Bisection search TIMEOUT')
def PrepareBaseCommand(args, classpath):
  """Prepares base command used to run test."""
  if args.raw_cmd:
    return shlex.split(args.raw_cmd)
  else:
    base_cmd = ['dalvikvm64'] if args.x64 else ['dalvikvm32']
    if not args.device:
      base_cmd += ['-XXlib:{0}'.format(args.lib)]
      if not args.image:
        image_path = (GetEnvVariableOrError('ANDROID_HOST_OUT') +
                      DEFAULT_IMAGE_RELATIVE_PATH)
      else:
        image_path = args.image
      base_cmd += ['-Ximage:{0}'.format(image_path)]
    if args.dalvikvm_opts:
      base_cmd += args.dalvikvm_opts
    base_cmd += ['-cp', classpath, args.classname] + args.test_args
  return base_cmd