def test_archived_testcase(self):
        """Ensure that we properly unpack archived test cases."""
        self.mock.request.return_value = (FakeResponse(200,
                                                       filename='test.zip'),
                                          'zip data')
        self.mock.get_file_list.return_value = ['test.html', 'resource.js']
        testcase = reproduce.SerializedTestcase({
            'archive_state':
            data_types.ArchiveStatus.ALL,
            'absolute_path':
            '/path/to/test.html',
            'minimized_keys':
            'key',
        })

        current_testcase_directory = os.path.join(reproduce.CONFIG_DIRECTORY,
                                                  'current-testcase')
        zip_path = os.path.join(current_testcase_directory, 'test.zip')

        reproduce._download_testcase(1, testcase, self.config)
        self.mock.write_data_to_file.assert_called_once_with(
            'zip data', zip_path)

        self.mock.unpack.assert_called_once_with(zip_path,
                                                 current_testcase_directory)
def _fake_get_libfuzzer_testcase(*_):
    """Fake test case output intended to run "echo -n"."""
    testcase_map = {
        'crash_state': 'state',
        'security_flag': False,
        'gestures': [],
        'flaky_stack': False,
        'job_type': 'test_job',
        'redzone': 32,
        'disable_ubsan': False,
        'additional_metadata': '{}',
        'fuzzer_name': 'libFuzzer',
        'job_definition': 'APP_NAME = launcher.py\n',
        'overridden_fuzzer_name': 'libFuzzer_test_fuzzer',
        'platform': environment.platform().lower(),
        'minimized_arguments': '',
        'window_argument': '',
        'timeout_multiplier': 1.0,
        'serialized_fuzz_target': {
            'binary': 'test_fuzzer',
            'engine': 'libFuzzer',
            'project': 'test_project',
        },
        'one_time_crasher_flag': False,
    }

    return reproduce.SerializedTestcase(testcase_map)
Exemple #3
0
def _fake_get_libfuzzer_testcase(*_):
    """Fake test case output intended to run "echo -n"."""
    testcase_map = {
        "crash_state": "state",
        "security_flag": False,
        "gestures": [],
        "flaky_stack": False,
        "job_type": "test_job",
        "redzone": 32,
        "disable_ubsan": False,
        "additional_metadata": "{}",
        "fuzzer_name": "libFuzzer",
        "job_definition": "APP_NAME = launcher.py\n",
        "overridden_fuzzer_name": "libFuzzer_test_fuzzer",
        "platform": environment.platform().lower(),
        "minimized_arguments": "",
        "window_argument": "",
        "timeout_multiplier": 1.0,
        "serialized_fuzz_target": {
            "binary": "test_fuzzer",
            "engine": "libFuzzer",
            "project": "test_project",
        },
        "one_time_crasher_flag": False,
    }

    return reproduce.SerializedTestcase(testcase_map)
Exemple #4
0
    def test_archived_testcase(self):
        """Ensure that we properly unpack archived test cases."""
        self.mock.request.return_value = (
            FakeResponse(200, filename="test.zip"),
            "zip data",
        )
        self.mock.get_file_list.return_value = ["test.html", "resource.js"]
        testcase = reproduce.SerializedTestcase({
            "archive_state":
            data_types.ArchiveStatus.ALL,
            "absolute_path":
            "/path/to/test.html",
            "minimized_keys":
            "key",
        })

        current_testcase_directory = os.path.join(reproduce.CONFIG_DIRECTORY,
                                                  "current-testcase")
        zip_path = os.path.join(current_testcase_directory, "test.zip")

        reproduce._download_testcase(1, testcase, self.config)
        self.mock.write_data_to_file.assert_called_once_with(
            "zip data", zip_path)

        self.mock.unpack.assert_called_once_with(zip_path,
                                                 current_testcase_directory)
def _fake_get_testcase(_):
    """Fake test case output intended to run "echo -n"."""
    testcase_map = {
        'crash_state': '',
        'security_flag': False,
        'gestures': [],
        'flaky_stack': False,
        'job_definition': 'APP_NAME = echo\nAPP_ARGS = -n\n',
    }

    return reproduce.SerializedTestcase(testcase_map)
  def test_archive_missing_file(self):
    """Ensure that we raise if the archive is missing an expected file."""
    self.mock.request.return_value = (FakeResponse(200, filename='test.zip'),
                                      'zip data')
    self.mock.get_file_list.return_value = []
    testcase = reproduce.SerializedTestcase({
        'archive_state': data_types.ArchiveStatus.ALL,
        'absolute_path': '/path/to/test.html',
        'minimized_keys': 'key',
    })

    with self.assertRaises(errors.ReproduceToolUnrecoverableError):
      reproduce._download_testcase(1, testcase, self.config)
  def test_non_archived_testcase(self):
    """Ensure that we properly unpack non-archived test cases."""
    self.mock.request.return_value = (FakeResponse(200, filename='test.html'),
                                      'html data')
    testcase = reproduce.SerializedTestcase({
        'archive_state': data_types.ArchiveStatus.NONE,
        'minimized_keys': 'key',
    })

    reproduce._download_testcase(1, testcase, self.config)
    self.mock.write_data_to_file.assert_called_once_with(
        'html data',
        os.path.join(reproduce.CONFIG_DIRECTORY, 'current-testcase',
                     'test.html'))
Exemple #8
0
def _fake_get_testcase(_):
  """Fake test case output intended to run "echo -n"."""
  testcase_map = {
      'crash_state': '',
      'security_flag': False,
      'gestures': [],
      'flaky_stack': False,
      'job_type': 'test_job',
      'redzone': 32,
      'additional_metadata': '{}',
      'fuzzer_name': 'fuzzer',
      'job_definition': 'APP_NAME = echo\nAPP_ARGS = -n\n',
  }

  return reproduce.SerializedTestcase(testcase_map)
Exemple #9
0
    def test_non_archived_testcase(self):
        """Ensure that we properly unpack non-archived test cases."""
        self.mock.request.return_value = (
            FakeResponse(200, filename="test.html"),
            "html data",
        )
        testcase = reproduce.SerializedTestcase({
            "archive_state":
            data_types.ArchiveStatus.NONE,
            "minimized_keys":
            "key"
        })

        reproduce._download_testcase(1, testcase, self.config)
        self.mock.write_data_to_file.assert_called_once_with(
            "html data",
            os.path.join(reproduce.CONFIG_DIRECTORY, "current-testcase",
                         "test.html"),
        )
def _fake_get_testcase(*_):
  """Fake test case output intended to run "echo -n"."""
  testcase_map = {
      'crash_state': 'state',
      'security_flag': False,
      'gestures': [],
      'flaky_stack': False,
      'job_type': 'test_job',
      'redzone': 32,
      'additional_metadata': '{}',
      'fuzzer_name': 'fuzzer',
      'job_definition': 'APP_NAME = echo\nAPP_ARGS = -n\n',
      'overridden_fuzzer_name': 'fuzzer',
      'platform': environment.platform().lower(),
      'minimized_arguments': '',
      'window_argument': '',
      'timeout_multiplier': 1.0,
  }

  return reproduce.SerializedTestcase(testcase_map)
 def test_initial_request_failed(self):
     """Ensure that we bail out if the initial request fails."""
     self.mock.request.return_value = (FakeResponse(500), '')
     testcase = reproduce.SerializedTestcase({})
     with self.assertRaises(errors.ReproduceToolUnrecoverableError):
         reproduce._download_testcase(1, testcase, self.config)