diff --git a/.dockerignore b/.dockerignore index cf6ef5d41..b72d742a6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,11 +1,11 @@ .git +infra/cifuzz/test_data/* +docs/* + # Copied from .gitignore. .vscode/ *.pyc build *~ .DS_Store -*.swp -infra/cifuzz/test_files/* -docs/* -infra/testcases/* \ No newline at end of file +*.swp \ No newline at end of file diff --git a/infra/.dockerignore b/infra/.dockerignore index 8835a70c6..c78653342 100644 --- a/infra/.dockerignore +++ b/infra/.dockerignore @@ -1,2 +1,9 @@ -cifuzz/test_files/* -testcases/* \ No newline at end of file +cifuzz/test_data/* + +# Copied from .gitignore. +.vscode/ +*.pyc +build +*~ +.DS_Store +*.swp \ No newline at end of file diff --git a/infra/cifuzz/affected_fuzz_targets_test.py b/infra/cifuzz/affected_fuzz_targets_test.py index 72e6d266c..05f27c072 100644 --- a/infra/cifuzz/affected_fuzz_targets_test.py +++ b/infra/cifuzz/affected_fuzz_targets_test.py @@ -30,15 +30,15 @@ EXAMPLE_PROJECT = 'example' EXAMPLE_FILE_CHANGED = 'test.txt' -TEST_FILES_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'test_files') +TEST_DATA_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'test_data') class RemoveUnaffectedFuzzTargets(unittest.TestCase): """Tests remove_unaffected_fuzzers.""" - TEST_FUZZER_1 = os.path.join(TEST_FILES_PATH, 'out', 'example_crash_fuzzer') - TEST_FUZZER_2 = os.path.join(TEST_FILES_PATH, 'out', 'example_nocrash_fuzzer') + TEST_FUZZER_1 = os.path.join(TEST_DATA_PATH, 'out', 'example_crash_fuzzer') + TEST_FUZZER_2 = os.path.join(TEST_DATA_PATH, 'out', 'example_nocrash_fuzzer') # yapf: disable @parameterized.parameterized.expand([ diff --git a/infra/cifuzz/build_fuzzers_test.py b/infra/cifuzz/build_fuzzers_test.py index 2329894b9..298778867 100644 --- a/infra/cifuzz/build_fuzzers_test.py +++ b/infra/cifuzz/build_fuzzers_test.py @@ -36,9 +36,9 @@ import test_helpers # https://github.com/google/oss-fuzz/tree/master/projects/example project. EXAMPLE_PROJECT = 'example' -# Location of files used for testing. -TEST_FILES_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'test_files') +# Location of data used for testing. +TEST_DATA_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'test_data') # An example fuzzer that triggers an crash. # Binary is a copy of the example project's do_stuff_fuzzer and can be @@ -257,7 +257,7 @@ class CheckFuzzerBuildTest(unittest.TestCase): def setUp(self): self.tmp_dir_obj = tempfile.TemporaryDirectory() self.test_files_path = os.path.join(self.tmp_dir_obj.name, 'test_files') - shutil.copytree(TEST_FILES_PATH, self.test_files_path) + shutil.copytree(TEST_DATA_PATH, self.test_files_path) def tearDown(self): self.tmp_dir_obj.cleanup() @@ -286,7 +286,7 @@ class CheckFuzzerBuildTest(unittest.TestCase): """Tests that ALLOWED_BROKEN_TARGETS_PERCENTAGE is set when running docker if passed to check_fuzzer_build.""" mocked_docker_run.return_value = 0 - test_fuzzer_dir = os.path.join(TEST_FILES_PATH, 'out') + test_fuzzer_dir = os.path.join(TEST_DATA_PATH, 'out') build_fuzzers.check_fuzzer_build(test_fuzzer_dir, self.SANITIZER, self.LANGUAGE, diff --git a/infra/cifuzz/coverage_test.py b/infra/cifuzz/coverage_test.py index 56269d732..1b24d798c 100644 --- a/infra/cifuzz/coverage_test.py +++ b/infra/cifuzz/coverage_test.py @@ -21,8 +21,8 @@ import coverage # pylint: disable=protected-access -TEST_FILES_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'test_files') +TEST_DATA_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'test_data') PROJECT_NAME = 'curl' REPO_PATH = '/src/curl' @@ -31,7 +31,7 @@ PROJECT_COV_JSON_FILENAME = 'example_curl_cov.json' FUZZ_TARGET_COV_JSON_FILENAME = 'example_curl_fuzzer_cov.json' INVALID_TARGET = 'not-a-fuzz-target' -with open(os.path.join(TEST_FILES_PATH, +with open(os.path.join(TEST_DATA_PATH, PROJECT_COV_JSON_FILENAME),) as cov_file_handle: PROJECT_COV_INFO = json.loads(cov_file_handle.read()) @@ -107,7 +107,7 @@ class GetFilesCoveredByTargetTest(unittest.TestCase): def test_valid_target(self): """Tests that covered files can be retrieved from a coverage report.""" - with open(os.path.join(TEST_FILES_PATH, + with open(os.path.join(TEST_DATA_PATH, FUZZ_TARGET_COV_JSON_FILENAME),) as file_handle: fuzzer_cov_info = json.loads(file_handle.read()) @@ -115,7 +115,7 @@ class GetFilesCoveredByTargetTest(unittest.TestCase): return_value=fuzzer_cov_info): file_list = self.coverage_getter.get_files_covered_by_target(FUZZ_TARGET) - curl_files_list_path = os.path.join(TEST_FILES_PATH, + curl_files_list_path = os.path.join(TEST_DATA_PATH, 'example_curl_file_list.json') with open(curl_files_list_path) as file_handle: expected_file_list = json.loads(file_handle.read()) diff --git a/infra/cifuzz/fuzz_target_test.py b/infra/cifuzz/fuzz_target_test.py index 8a506fa59..8bec234dc 100644 --- a/infra/cifuzz/fuzz_target_test.py +++ b/infra/cifuzz/fuzz_target_test.py @@ -148,8 +148,7 @@ class GetTestCaseTest(unittest.TestCase): def test_valid_error_string(self): """Tests that get_testcase returns the correct testcase give an error.""" testcase_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'test_files', - 'example_crash_fuzzer_output.txt') + 'test_data', 'example_crash_fuzzer_output.txt') with open(testcase_path, 'rb') as test_fuzz_output: parsed_testcase = self.test_target.get_testcase(test_fuzz_output.read()) self.assertEqual( diff --git a/infra/cifuzz/run_fuzzers_test.py b/infra/cifuzz/run_fuzzers_test.py index f524b8942..b2659903c 100644 --- a/infra/cifuzz/run_fuzzers_test.py +++ b/infra/cifuzz/run_fuzzers_test.py @@ -37,13 +37,13 @@ import test_helpers EXAMPLE_PROJECT = 'example' # Location of files used for testing. -TEST_FILES_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'test_files') +TEST_DATA_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'test_data') -MEMORY_FUZZER_DIR = os.path.join(TEST_FILES_PATH, 'memory') +MEMORY_FUZZER_DIR = os.path.join(TEST_DATA_PATH, 'memory') MEMORY_FUZZER = 'curl_fuzzer_memory' -UNDEFINED_FUZZER_DIR = os.path.join(TEST_FILES_PATH, 'undefined') +UNDEFINED_FUZZER_DIR = os.path.join(TEST_DATA_PATH, 'undefined') UNDEFINED_FUZZER = 'curl_fuzzer_undefined' FUZZ_SECONDS = 10 @@ -335,7 +335,7 @@ class RunAddressFuzzersIntegrationTest(RunFuzzerIntegrationTestMixin, side_effect=[True, False]): with tempfile.TemporaryDirectory() as tmp_dir: workspace = os.path.join(tmp_dir, 'workspace') - shutil.copytree(TEST_FILES_PATH, workspace) + shutil.copytree(TEST_DATA_PATH, workspace) config = _create_config(fuzz_seconds=FUZZ_SECONDS, workspace=workspace, project_name=EXAMPLE_PROJECT) @@ -351,17 +351,17 @@ class RunAddressFuzzersIntegrationTest(RunFuzzerIntegrationTestMixin, def test_old_bug_found(self, _): """Tests run_fuzzers with a bug found in OSS-Fuzz before.""" config = _create_config(fuzz_seconds=FUZZ_SECONDS, - workspace=TEST_FILES_PATH, + workspace=TEST_DATA_PATH, project_name=EXAMPLE_PROJECT) with tempfile.TemporaryDirectory() as tmp_dir: workspace = os.path.join(tmp_dir, 'workspace') - shutil.copytree(TEST_FILES_PATH, workspace) + shutil.copytree(TEST_DATA_PATH, workspace) config = _create_config(fuzz_seconds=FUZZ_SECONDS, - workspace=TEST_FILES_PATH, + workspace=TEST_DATA_PATH, project_name=EXAMPLE_PROJECT) result = run_fuzzers.run_fuzzers(config) self.assertEqual(result, run_fuzzers.RunFuzzersResult.NO_BUG_FOUND) - build_dir = os.path.join(TEST_FILES_PATH, 'out', self.BUILD_DIR_NAME) + build_dir = os.path.join(TEST_DATA_PATH, 'out', self.BUILD_DIR_NAME) self.assertTrue(os.path.exists(build_dir)) self.assertNotEqual(0, len(os.listdir(build_dir))) diff --git a/infra/cifuzz/stack_parser_test.py b/infra/cifuzz/stack_parser_test.py index a7b57f5ed..faf601fd5 100644 --- a/infra/cifuzz/stack_parser_test.py +++ b/infra/cifuzz/stack_parser_test.py @@ -25,9 +25,9 @@ import stack_parser # https://github.com/google/oss-fuzz/tree/master/projects/example project. EXAMPLE_PROJECT = 'example' -# Location of files used for testing. -TEST_FILES_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'test_files') +# Location of data used for testing. +TEST_DATA_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), + 'test_data') class ParseOutputTest(fake_filesystem_unittest.TestCase): @@ -44,7 +44,7 @@ class ParseOutputTest(fake_filesystem_unittest.TestCase): def test_parse_valid_output(self, fuzzer_output_file, bug_summary_file): """Checks that the parse fuzzer output can correctly parse output.""" # Read the fuzzer output from disk. - fuzzer_output_path = os.path.join(TEST_FILES_PATH, fuzzer_output_file) + fuzzer_output_path = os.path.join(TEST_DATA_PATH, fuzzer_output_file) self.fs.add_real_file(fuzzer_output_path) with open(fuzzer_output_path, 'rb') as fuzzer_output_handle: fuzzer_output = fuzzer_output_handle.read() @@ -57,7 +57,7 @@ class ParseOutputTest(fake_filesystem_unittest.TestCase): bug_summary = bug_summary_handle.read() # Compare the bug to the expected one. - expected_bug_summary_path = os.path.join(TEST_FILES_PATH, bug_summary_file) + expected_bug_summary_path = os.path.join(TEST_DATA_PATH, bug_summary_file) self.fs.add_real_file(expected_bug_summary_path) with open(expected_bug_summary_path) as expected_bug_summary_handle: expected_bug_summary = expected_bug_summary_handle.read() diff --git a/infra/cifuzz/test_files/example_crash_fuzzer_bug_summary.txt b/infra/cifuzz/test_data/example_crash_fuzzer_bug_summary.txt similarity index 100% rename from infra/cifuzz/test_files/example_crash_fuzzer_bug_summary.txt rename to infra/cifuzz/test_data/example_crash_fuzzer_bug_summary.txt diff --git a/infra/cifuzz/test_files/example_crash_fuzzer_output.txt b/infra/cifuzz/test_data/example_crash_fuzzer_output.txt similarity index 100% rename from infra/cifuzz/test_files/example_crash_fuzzer_output.txt rename to infra/cifuzz/test_data/example_crash_fuzzer_output.txt diff --git a/infra/cifuzz/test_files/example_curl_cov.json b/infra/cifuzz/test_data/example_curl_cov.json similarity index 100% rename from infra/cifuzz/test_files/example_curl_cov.json rename to infra/cifuzz/test_data/example_curl_cov.json diff --git a/infra/cifuzz/test_files/example_curl_file_list.json b/infra/cifuzz/test_data/example_curl_file_list.json similarity index 100% rename from infra/cifuzz/test_files/example_curl_file_list.json rename to infra/cifuzz/test_data/example_curl_file_list.json diff --git a/infra/cifuzz/test_files/example_curl_fuzzer_cov.json b/infra/cifuzz/test_data/example_curl_fuzzer_cov.json similarity index 100% rename from infra/cifuzz/test_files/example_curl_fuzzer_cov.json rename to infra/cifuzz/test_data/example_curl_fuzzer_cov.json diff --git a/infra/cifuzz/test_files/external-project/Makefile b/infra/cifuzz/test_data/external-project/Makefile similarity index 100% rename from infra/cifuzz/test_files/external-project/Makefile rename to infra/cifuzz/test_data/external-project/Makefile diff --git a/infra/cifuzz/test_files/external-project/do_stuff_fuzzer.cpp b/infra/cifuzz/test_data/external-project/do_stuff_fuzzer.cpp similarity index 100% rename from infra/cifuzz/test_files/external-project/do_stuff_fuzzer.cpp rename to infra/cifuzz/test_data/external-project/do_stuff_fuzzer.cpp diff --git a/infra/cifuzz/test_files/external-project/do_stuff_fuzzer.dict b/infra/cifuzz/test_data/external-project/do_stuff_fuzzer.dict similarity index 100% rename from infra/cifuzz/test_files/external-project/do_stuff_fuzzer.dict rename to infra/cifuzz/test_data/external-project/do_stuff_fuzzer.dict diff --git a/infra/cifuzz/test_files/external-project/my_api.cpp b/infra/cifuzz/test_data/external-project/my_api.cpp similarity index 100% rename from infra/cifuzz/test_files/external-project/my_api.cpp rename to infra/cifuzz/test_data/external-project/my_api.cpp diff --git a/infra/cifuzz/test_files/external-project/my_api.h b/infra/cifuzz/test_data/external-project/my_api.h similarity index 100% rename from infra/cifuzz/test_files/external-project/my_api.h rename to infra/cifuzz/test_data/external-project/my_api.h diff --git a/infra/cifuzz/test_files/external-project/oss-fuzz/Dockerfile b/infra/cifuzz/test_data/external-project/oss-fuzz/Dockerfile similarity index 100% rename from infra/cifuzz/test_files/external-project/oss-fuzz/Dockerfile rename to infra/cifuzz/test_data/external-project/oss-fuzz/Dockerfile diff --git a/infra/cifuzz/test_files/external-project/oss-fuzz/build.sh b/infra/cifuzz/test_data/external-project/oss-fuzz/build.sh similarity index 100% rename from infra/cifuzz/test_files/external-project/oss-fuzz/build.sh rename to infra/cifuzz/test_data/external-project/oss-fuzz/build.sh diff --git a/infra/cifuzz/test_files/external-project/standalone_fuzz_target_runner.cpp b/infra/cifuzz/test_data/external-project/standalone_fuzz_target_runner.cpp similarity index 100% rename from infra/cifuzz/test_files/external-project/standalone_fuzz_target_runner.cpp rename to infra/cifuzz/test_data/external-project/standalone_fuzz_target_runner.cpp diff --git a/infra/cifuzz/test_files/memory/out/curl_fuzzer_memory b/infra/cifuzz/test_data/memory/out/curl_fuzzer_memory similarity index 100% rename from infra/cifuzz/test_files/memory/out/curl_fuzzer_memory rename to infra/cifuzz/test_data/memory/out/curl_fuzzer_memory diff --git a/infra/cifuzz/test_files/msan_crash_fuzzer_bug_summary.txt b/infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt similarity index 100% rename from infra/cifuzz/test_files/msan_crash_fuzzer_bug_summary.txt rename to infra/cifuzz/test_data/msan_crash_fuzzer_bug_summary.txt diff --git a/infra/cifuzz/test_files/msan_crash_fuzzer_output.txt b/infra/cifuzz/test_data/msan_crash_fuzzer_output.txt similarity index 100% rename from infra/cifuzz/test_files/msan_crash_fuzzer_output.txt rename to infra/cifuzz/test_data/msan_crash_fuzzer_output.txt diff --git a/infra/cifuzz/test_files/out/example_crash_fuzzer b/infra/cifuzz/test_data/out/example_crash_fuzzer similarity index 100% rename from infra/cifuzz/test_files/out/example_crash_fuzzer rename to infra/cifuzz/test_data/out/example_crash_fuzzer diff --git a/infra/cifuzz/test_files/out/example_nocrash_fuzzer b/infra/cifuzz/test_data/out/example_nocrash_fuzzer similarity index 100% rename from infra/cifuzz/test_files/out/example_nocrash_fuzzer rename to infra/cifuzz/test_data/out/example_nocrash_fuzzer diff --git a/infra/cifuzz/test_files/undefined/out/curl_fuzzer_undefined b/infra/cifuzz/test_data/undefined/out/curl_fuzzer_undefined similarity index 100% rename from infra/cifuzz/test_files/undefined/out/curl_fuzzer_undefined rename to infra/cifuzz/test_data/undefined/out/curl_fuzzer_undefined diff --git a/infra/testcases/curl_test_data b/infra/testcases/curl_test_data deleted file mode 100644 index ed4b54ea3..000000000 Binary files a/infra/testcases/curl_test_data and /dev/null differ diff --git a/infra/testcases/libarchive_test_data b/infra/testcases/libarchive_test_data deleted file mode 100644 index 928bfec97..000000000 Binary files a/infra/testcases/libarchive_test_data and /dev/null differ diff --git a/infra/testcases/ndpi_test_data b/infra/testcases/ndpi_test_data deleted file mode 100644 index 010af8604..000000000 Binary files a/infra/testcases/ndpi_test_data and /dev/null differ diff --git a/infra/testcases/usrsctp_test_data b/infra/testcases/usrsctp_test_data deleted file mode 100644 index fa90322a2..000000000 Binary files a/infra/testcases/usrsctp_test_data and /dev/null differ diff --git a/infra/testcases/yara_test_data b/infra/testcases/yara_test_data deleted file mode 100644 index e2a0b94af..000000000 --- a/infra/testcases/yara_test_data +++ /dev/null @@ -1 +0,0 @@ -rule N{condition:for 1r in r(r \ No newline at end of file diff --git a/infra/utils_test.py b/infra/utils_test.py index a56295c93..aa6ec7ba7 100644 --- a/infra/utils_test.py +++ b/infra/utils_test.py @@ -24,7 +24,7 @@ import helper EXAMPLE_PROJECT = 'example' TEST_OUT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'cifuzz', 'test_files', 'out') + 'cifuzz', 'test_data', 'out') class IsFuzzTargetLocalTest(unittest.TestCase):