• Home
  • Raw
  • Download

Lines Matching +full:mock +full:- +full:tests

7 #      http://www.apache.org/licenses/LICENSE-2.0
14 """Tests for running fuzzers."""
21 from unittest import mock
30 # pylint: disable=wrong-import-position
38 # https://github.com/google/oss-fuzz/tree/master/projects/example project.
54 class RunFuzzerIntegrationTestMixin: # pylint: disable=too-few-public-methods,invalid-name
86 """Tests run_fuzzers with a valid MSAN build."""
99 """Tests run_fuzzers with a valid UBSAN build."""
104 """Tests BaseFuzzTargetRunner."""
106 def _create_runner(self, **kwargs): # pylint: disable=no-self-use
119 with mock.patch('logging.error') as mock_error:
124 @parameterized.parameterized.expand([(0,), (None,), (-1,)])
126 """Tests initialize fails with an invalid fuzz seconds."""
130 out_path = os.path.join(tmp_dir, 'build-out')
132 with mock.patch('utils.get_fuzz_targets') as mock_get_fuzz_targets:
141 """Tests initialize fails with no out dir."""
143 out_path = os.path.join(tmp_dir, 'build-out')
148 """Tests initialize with a file artifacts path."""
150 out_path = os.path.join(tmp_dir, 'build-out')
162 """Tests initialize with a non-empty artifacts path."""
164 out_path = os.path.join(tmp_dir, 'build-out')
176 @mock.patch('utils.get_fuzz_targets')
177 @mock.patch('logging.error')
180 """Tests initialize with an empty artifacts dir."""
181 mock_get_fuzz_targets.return_value = ['fuzz-target']
183 out_path = os.path.join(tmp_dir, 'build-out')
192 @mock.patch('utils.get_fuzz_targets')
193 @mock.patch('logging.error')
195 """Tests initialize with no artifacts dir (the expected setting)."""
196 mock_get_fuzz_targets.return_value = ['fuzz-target']
198 out_path = os.path.join(tmp_dir, 'build-out')
206 """Tests initialize with no fuzz targets."""
208 out_path = os.path.join(tmp_dir, 'build-out')
215 """Tests that get_fuzz_target_artifact works as intended."""
218 crashes_dir = 'crashes-dir'
220 artifact_name = 'artifact-name'
221 target = mock.MagicMock()
228 tmp_dir, 'out', 'artifacts', 'target_name-address-artifact-name')
234 """Tests that CiFuzzTargetRunner works as intended."""
239 @mock.patch('utils.get_fuzz_targets')
240 @mock.patch('run_fuzzers.CiFuzzTargetRunner.run_fuzz_target')
241 @mock.patch('run_fuzzers.CiFuzzTargetRunner.create_fuzz_target_obj')
244 """Tests that run_fuzz_targets quits on the first crash it finds."""
246 out_path = os.path.join(workspace, 'build-out')
263 magic_mock = mock.MagicMock()
267 self.assertIn('target1-address-testcase',
273 """Tests that BatchFuzzTargetRunnerTest works as intended."""
280 out_dir = os.path.join(self.WORKSPACE, 'build-out')
282 self.testcase1 = os.path.join(out_dir, 'testcase-aaa')
284 self.testcase2 = os.path.join(out_dir, 'testcase-bbb')
290 @mock.patch('utils.get_fuzz_targets', return_value=['target1', 'target2'])
291 @mock.patch('clusterfuzz_deployment.ClusterFuzzLite.upload_build',
293 @mock.patch('run_fuzzers.BatchFuzzTargetRunner.run_fuzz_target')
294 @mock.patch('run_fuzzers.BatchFuzzTargetRunner.create_fuzz_target_obj')
297 """Tests that run_fuzz_targets doesn't quit on the first crash it finds."""
316 magic_mock = mock.MagicMock()
322 @mock.patch('run_fuzzers.BaseFuzzTargetRunner.run_fuzz_targets',
324 @mock.patch('clusterfuzz_deployment.ClusterFuzzLite.upload_crashes')
327 """Tests that run_fuzz_targets uploads crashes and builds correctly."""
339 """Integration tests for coverage reports."""
345 @mock.patch('filestore.github_actions._upload_artifact_with_upload_js')
347 """Tests generation of coverage reports end-to-end, from building to
353 copy_command = ('cp -r /opt/code_coverage /shared && '
354 'cp $(which llvm-profdata) /shared && '
355 'cp $(which llvm-cov) /shared')
357 '-v', f'{shared}:/shared', 'gcr.io/oss-fuzz-base/base-runner', 'bash',
358 '-c', copy_command
366 project_repo_name='oss-fuzz',
377 chmod_command = ('chmod -R +r /out && '
378 'find /out -type d -exec chmod +x {} +')
381 '-v', f'{os.path.join(temp_dir, "build-out")}:/out',
382 'gcr.io/oss-fuzz-base/base-builder', 'bash', '-c', chmod_command
397 actual_summary_path = os.path.join(temp_dir, 'cifuzz-coverage',
408 """Integration tests for build_fuzzers with an ASAN build."""
410 BUILD_DIR_NAME = 'cifuzz-latest-build'
413 """Tests run_fuzzers with a valid ASAN build."""
416 # OSS-Fuzz build.
417 with mock.patch('fuzz_target.FuzzTarget.is_reproducible',
429 @mock.patch('fuzz_target.FuzzTarget.is_reproducible',
432 """Tests run_fuzzers with a bug found in OSS-Fuzz before."""
444 """Tests run_fuzzers with an invalid ASAN build."""
446 out_path = os.path.join(tmp_dir, 'build-out')
457 """Tests for get_fuzz_fuzz_target_runner."""
466 """Tests that get_fuzz_target_runner returns the correct runner based on the