コード例 #1
0
    def test_not_found(self):
        """Tests not found."""
        os.makedirs('/tmp/test/sub')
        self.fs.CreateFile('/tmp/test/sub/test.hello', contents='test')

        with self.assertRaises(Exception):
            common.find_file('args.gn', '/tmp/test')
コード例 #2
0
def download_build_if_needed(dest, url):
  """Download and extract a build (if it's not already there)."""
  if os.path.exists(dest):
    return dest

  logger.info('Downloading build data...')

  gsutil_path = url.replace(
      'https://storage.cloud.google.com/', 'gs://')
  common.gsutil('cp %s .' % gsutil_path, common.CLUSTERFUZZ_CACHE_DIR)

  filename = os.path.basename(gsutil_path)
  saved_file = os.path.join(common.CLUSTERFUZZ_CACHE_DIR, filename)

  tmp_dir_path = tempfile.mkdtemp(dir=common.CLUSTERFUZZ_TMP_DIR)
  common.execute('unzip', '-q %s -d %s' % (saved_file, tmp_dir_path), cwd='.')

  # args.gn is guaranteed to be in the wanted folder. In Chrome, it's under a
  # sub-directory. In Android, it's in the top dir.
  args_gn_path = common.find_file('args.gn', tmp_dir_path)
  shutil.copytree(os.path.dirname(args_gn_path), dest)

  logger.info('Cleaning up...')
  common.delete_if_exists(saved_file)
  common.delete_if_exists(tmp_dir_path)
コード例 #3
0
    def test_find(self):
        """Tests not found."""
        os.makedirs('/tmp/test/sub')
        self.fs.CreateFile('/tmp/test/sub/test.hello', contents='test')
        self.fs.CreateFile('/tmp/test/sub/args.gn', contents='test')

        self.assertEqual('/tmp/test/sub/args.gn',
                         common.find_file('args.gn', '/tmp/test'))
コード例 #4
0
def get_true_testcase_path(testcase_dir_path, testcase_absolute_path,
                           downloaded_file_path):
    """Return actual testcase path, unzips testcase if required."""
    filename = os.path.basename(testcase_absolute_path)
    if downloaded_file_path.endswith('.zip'):
        zipped_file = zipfile.ZipFile(downloaded_file_path, 'r')
        zipped_file.extractall(testcase_dir_path)
        zipped_file.close()
        return common.find_file(filename, testcase_dir_path)
    else:
        dest_path = os.path.join(testcase_dir_path, filename)
        shutil.move(downloaded_file_path, dest_path)
        return dest_path