Esempio n. 1
0
  def CompileOnHost(self):
    """Compiles Test.java into classes.dex using either javac/dx or d8.

    Raises:
      FatalError: error when compilation fails
    """
    if self._dexer == 'dx' or self._dexer == 'd8':
      dbg = '-g' if self._debug_info else '-g:none'
      if RunCommand(['javac', '--release=8', dbg, 'Test.java'],
                    out=None, err='jerr.txt', timeout=30) != RetCode.SUCCESS:
        print('Unexpected error while running javac')
        raise FatalError('Unexpected error while running javac')
      cfiles = glob('*.class')
      dx = 'dx' if self._dexer == 'dx' else 'd8-compat-dx'
      if RunCommand([dx, '--dex', '--output=classes.dex'] + cfiles,
                    out=None, err='dxerr.txt', timeout=30) != RetCode.SUCCESS:
        print('Unexpected error while running dx')
        raise FatalError('Unexpected error while running dx')
      # Cleanup on success (nothing to see).
      for cfile in cfiles:
        os.unlink(cfile)
      os.unlink('jerr.txt')
      os.unlink('dxerr.txt')
    else:
      raise FatalError('Unknown dexer: ' + self._dexer)
Esempio n. 2
0
 def CompileAndRunTest(self):
     if RunCommand(['javac', 'Test.java'], out=None, err=None,
                   timeout=30) == RetCode.SUCCESS:
         retc = RunCommand(['java', 'Test'], self.output_file, err=None)
     else:
         retc = RetCode.NOTCOMPILED
     return retc
Esempio n. 3
0
 def CompileAndRunTest(self):
     if RunCommand(['jack'] + self._jack_args,
                   out=None,
                   err='jackerr.txt',
                   timeout=30) == RetCode.SUCCESS:
         retc = RunCommand(self._art_cmd, self.output_file, 'arterr.txt')
     else:
         retc = RetCode.NOTCOMPILED
     return retc
Esempio n. 4
0
 def CompileAndRunTest(self):
     dbg = '-g' if self._debug_info else '-g:none'
     if RunCommand(['javac', '--release=8', dbg, 'Test.java'],
                   out=None,
                   err=None,
                   timeout=30) == RetCode.SUCCESS:
         retc = RunCommand(['java', 'Test'], self.output_file, err=None)
     else:
         retc = RetCode.NOTCOMPILED
     return retc
Esempio n. 5
0
 def CompileOnHost(self):
   if self._use_dx:
     if RunCommand(['javac', 'Test.java'],
                   out=None, err=None, timeout=30) == RetCode.SUCCESS:
       retc = RunCommand(['dx', '--dex', '--output=classes.dex'] + glob('*.class'),
                         out=None, err='dxerr.txt', timeout=30)
     else:
       retc = RetCode.NOTCOMPILED
   else:
     retc = RunCommand(['jack'] + self._jack_args,
                       out=None, err='jackerr.txt', timeout=30)
   return retc
Esempio n. 6
0
    def ConstructTest(self):
        """Use JFuzz to generate next Test.java test.

    Raises:
      FatalError: error when jfuzz fails
    """
        if (RunCommand(['jfuzz'] + self._jfuzz_args, out='Test.java', err=None)
                != RetCode.SUCCESS):
            raise FatalError('Unexpected error while running JFuzz')
Esempio n. 7
0
 def CompileOnHost(self):
     if self._dexer == 'dx' or self._dexer == 'd8':
         dbg = '-g' if self._debug_info else '-g:none'
         if RunCommand(['javac', '--release=8', dbg, 'Test.java'],
                       out=None,
                       err=None,
                       timeout=30) == RetCode.SUCCESS:
             dx = 'dx' if self._dexer == 'dx' else 'd8-compat-dx'
             retc = RunCommand([dx, '--dex', '--output=classes.dex'] +
                               glob('*.class'),
                               out=None,
                               err='dxerr.txt',
                               timeout=30)
         else:
             retc = RetCode.NOTCOMPILED
     else:
         raise FatalError('Unknown dexer: ' + self._dexer)
     return retc
Esempio n. 8
0
    def GenerateJFuzzPrograms(self):
        """Generates JFuzz programs.

    Raises:
      FatalError: error when generation fails
    """
        os.chdir(self._inputs_dir)
        for i in range(1, self._num_inputs + 1):
            jack_args = [
                '-cp',
                GetJackClassPath(), '--output-dex', '.', 'Test.java'
            ]
            if RunCommand(['jfuzz'], out='Test.java',
                          err=None) != RetCode.SUCCESS:
                raise FatalError('Unexpected error while running JFuzz')
            if RunCommand(
                ['jack'] + jack_args, out=None, err='jackerr.txt',
                    timeout=30) != RetCode.SUCCESS:
                raise FatalError('Unexpected error while running Jack')
            shutil.move('Test.java', '../Test' + str(i) + '.java')
            shutil.move('classes.dex', 'classes' + str(i) + '.dex')
        os.unlink('jackerr.txt')
Esempio n. 9
0
  def GenerateJFuzzPrograms(self):
    """Generates JFuzz programs.

    Raises:
      FatalError: error when generation fails
    """
    os.chdir(self._inputs_dir)
    for i in range(1, self._num_inputs + 1):
      if RunCommand(['jfuzz'], out='Test.java', err=None) != RetCode.SUCCESS:
        print('Unexpected error while running JFuzz')
        raise FatalError('Unexpected error while running JFuzz')
      self.CompileOnHost()
      shutil.move('Test.java', '../Test' + str(i) + '.java')
      shutil.move('classes.dex', 'classes' + str(i) + '.dex')
Esempio n. 10
0
    def CompileOnHost(self):
        """Compiles Test.java into classes.dex using either javac/dx or jack.

    Raises:
      FatalError: error when compilation fails
    """
        if self._use_dx:
            if RunCommand(
                ['javac', 'Test.java'], out=None, err='jerr.txt',
                    timeout=30) != RetCode.SUCCESS:
                print('Unexpected error while running javac')
                raise FatalError('Unexpected error while running javac')
            cfiles = glob('*.class')
            if RunCommand(['dx', '--dex', '--output=classes.dex'] + cfiles,
                          out=None,
                          err='dxerr.txt',
                          timeout=30) != RetCode.SUCCESS:
                print('Unexpected error while running dx')
                raise FatalError('Unexpected error while running dx')
            # Cleanup on success (nothing to see).
            for cfile in cfiles:
                os.unlink(cfile)
            os.unlink('jerr.txt')
            os.unlink('dxerr.txt')
        else:
            jack_args = [
                '-cp',
                GetJackClassPath(), '--output-dex', '.', 'Test.java'
            ]
            if RunCommand(
                ['jack'] + jack_args, out=None, err='jackerr.txt',
                    timeout=30) != RetCode.SUCCESS:
                print('Unexpected error while running Jack')
                raise FatalError('Unexpected error while running Jack')
            # Cleanup on success (nothing to see).
            os.unlink('jackerr.txt')
Esempio n. 11
0
 def CompileAndRunTest(self):
     if RunCommand(['jack'] + self._jack_args,
                   out=None,
                   err='jackerr.txt',
                   timeout=30) == RetCode.SUCCESS:
         self._device_classpath = self._test_env.PushClasspath(
             'classes.dex')
         cmd = self._dalvik_cmd + ['-cp', self._device_classpath, 'Test']
         (output,
          retc) = self._test_env.RunCommand(cmd,
                                            {'ANDROID_LOG_TAGS': '*:s'})
         with open(self.output_file, 'w') as run_out:
             run_out.write(output)
     else:
         retc = RetCode.NOTCOMPILED
     return retc
Esempio n. 12
0
 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')
Esempio n. 13
0
 def CompileAndRunTest(self):
     if self.CompileOnHost() == RetCode.SUCCESS:
         retc = RunCommand(self._art_cmd, self.output_file, 'arterr.txt')
     else:
         retc = RetCode.NOTCOMPILED
     return retc