diff --git a/src/python/tests/core/bot/fuzzers/afl/afl_launcher_test.py b/src/python/tests/core/bot/fuzzers/afl/afl_launcher_test.py index bd161a535a..4fa89dc5a5 100644 --- a/src/python/tests/core/bot/fuzzers/afl/afl_launcher_test.py +++ b/src/python/tests/core/bot/fuzzers/afl/afl_launcher_test.py @@ -45,9 +45,9 @@ class LauncherTestBase(fake_filesystem_unittest.TestCase): def setUp(self): test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory(self.INPUT_DIR) + self.fs.create_dir(self.INPUT_DIR) if not os.path.exists(self.TEMP_DIR): - self.fs.CreateDirectory(self.TEMP_DIR) + self.fs.create_dir(self.TEMP_DIR) self._create_file(fuzzer.AFL_DUMMY_INPUT) test_helpers.patch(self, [ @@ -65,7 +65,7 @@ def _create_file(self, filename, directory=None, contents=' '): directory = self.INPUT_DIR file_path = os.path.join(directory, filename) - return file_path, self.fs.CreateFile(file_path, contents=contents) + return file_path, self.fs.create_file(file_path, contents=contents) def _assert_elements_equal(self, l1, l2): """Assert that the elements of |l1| and |l2|. Modifies |l1| and |l2| by @@ -249,7 +249,7 @@ def test_create_new_if_needed_subdirs(self): self._create_file('small_1') self._create_oversized_file(filename='too_big_1') subdirectory = os.path.join(self.INPUT_DIR, 'subdir') - self.fs.CreateDirectory(subdirectory) + self.fs.create_dir(subdirectory) self._create_file('small_2', directory=subdirectory) self._create_oversized_file(directory=subdirectory, filename='too_big_2') afl_input = self._new_afl_input() @@ -654,7 +654,7 @@ def test_fuzzer_stderr_ioerror(self): def test_fuzzer_stderr(self): """Test AflRunner.fuzzer_stderr works correctly.""" stderr = 'hello' - self.fs.CreateFile(self.runner.stderr_file_path, contents=stderr) + self.fs.create_file(self.runner.stderr_file_path, contents=stderr) self.assertIsNone(self.runner._fuzzer_stderr) self.assertEqual(self.runner.fuzzer_stderr, stderr) @@ -697,7 +697,7 @@ def _initialization_for_run_afl(self): # Make sure this initialized or else it will remove CRASHES_DIR. self.runner.afl_output # pylint: disable=pointless-statement - self.fs.CreateDirectory(self.CRASHES_DIR) + self.fs.create_dir(self.CRASHES_DIR) self.runner.initial_max_total_time = 100 self.mock.run_and_wait.side_effect = ( lambda *args, **kwargs: self._process_result()) @@ -897,7 +897,7 @@ def test_list_full_file_paths(self): # Test it works with a subdirectory by not returning it: dummy_dir = os.path.join(self.INPUT_DIR, 'dummydir') - self.fs.CreateDirectory(dummy_dir) + self.fs.create_dir(dummy_dir) self._create_file(self.DUMMY_2_FILENAME, directory=dummy_dir) self._assert_elements_equal( @@ -922,7 +922,7 @@ def _get_unique_feature(self): def _create_file(self, path, size=1): """Creates a file at |path| that is |size| bytes large.""" - self.fs.CreateFile(path, contents=size * 'A') + self.fs.create_file(path, contents=size * 'A') def test_corpus_element(self): """Tests CorpusElement class.""" diff --git a/src/python/tests/core/bot/fuzzers/builtin_fuzzers_test.py b/src/python/tests/core/bot/fuzzers/builtin_fuzzers_test.py index fb2e6c9bd8..68dcc343a2 100644 --- a/src/python/tests/core/bot/fuzzers/builtin_fuzzers_test.py +++ b/src/python/tests/core/bot/fuzzers/builtin_fuzzers_test.py @@ -65,8 +65,8 @@ class BuiltinFuzzersSetupTest(fake_filesystem_unittest.TestCase): def setUp(self): helpers.patch_environ(self) test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory('/input') - self.fs.CreateDirectory('/output') + self.fs.create_dir('/input') + self.fs.create_dir('/output') helpers.patch(self, [ 'bot.fuzzers.libFuzzer.fuzzer.LibFuzzer.run', diff --git a/src/python/tests/core/bot/fuzzers/builtin_test.py b/src/python/tests/core/bot/fuzzers/builtin_test.py index 9cabf34535..7b54545590 100644 --- a/src/python/tests/core/bot/fuzzers/builtin_test.py +++ b/src/python/tests/core/bot/fuzzers/builtin_test.py @@ -44,8 +44,8 @@ def setUp(self): ]) test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory('/input') - self.fs.CreateDirectory('/output') + self.fs.create_dir('/input') + self.fs.create_dir('/output') environment.set_value('BUILD_DIR', '/build_dir') environment.set_value('FAIL_RETRIES', 1) @@ -56,7 +56,7 @@ def setUp(self): self.mock.get_fuzz_targets.return_value = [ '/build_dir/target', ] - self.fs.CreateFile( + self.fs.create_file( '/build_dir/target.owners', contents='dev1@example1.com\ndev2@example2.com') @@ -87,7 +87,7 @@ def test_run(self): def test_run_with_labels(self): """Test running an engine fuzzer with a labels file.""" - self.fs.CreateFile('/build_dir/target.labels', contents='label1\nlabel2\n') + self.fs.create_file('/build_dir/target.labels', contents='label1\nlabel2\n') fuzzer = TestEngineFuzzer() result = fuzzer.run('/input', '/output', 1) diff --git a/src/python/tests/core/bot/fuzzers/engine_common_test.py b/src/python/tests/core/bot/fuzzers/engine_common_test.py index 3c52d9a912..437b3ed03f 100644 --- a/src/python/tests/core/bot/fuzzers/engine_common_test.py +++ b/src/python/tests/core/bot/fuzzers/engine_common_test.py @@ -32,22 +32,22 @@ class GetIssueOwnersTest(fake_filesystem_unittest.TestCase): def setUp(self): test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory('/test') + self.fs.create_dir('/test') def test_no_file(self): self.assertEqual([], engine_common.get_issue_owners('/test/does_not_exist')) def test_empty_file(self): - self.fs.CreateFile('/test/fuzz_target.owners', contents='') + self.fs.create_file('/test/fuzz_target.owners', contents='') self.assertEqual([], engine_common.get_issue_owners('/test/fuzz_target')) def test_all_allowed(self): - self.fs.CreateFile('/test/fuzz_target.owners', contents='*') + self.fs.create_file('/test/fuzz_target.owners', contents='*') self.assertEqual([], engine_common.get_issue_owners('/test/fuzz_target')) def test_sections(self): """Test sections.""" - self.fs.CreateFile( + self.fs.create_file( '/test/fuzz_target.owners', contents=('file://ENG_REVIEW_OWNERS\n' ' \n' @@ -70,7 +70,7 @@ class GetIssueLabelsTest(fake_filesystem_unittest.TestCase): def setUp(self): test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory('/test') + self.fs.create_dir('/test') def test_no_file(self): """Test no labels file.""" @@ -78,19 +78,19 @@ def test_no_file(self): def test_empty_file(self): """Test empty file.""" - self.fs.CreateFile('/test/fuzz_target.labels', contents='') + self.fs.create_file('/test/fuzz_target.labels', contents='') self.assertEqual([], engine_common.get_issue_labels('/test/fuzz_target')) def test_well_formed(self): """Test well formed labels file.""" - self.fs.CreateFile( + self.fs.create_file( '/test/fuzz_target.labels', contents='label1\nlabel2\nlabel3\n') self.assertEqual(['label1', 'label2', 'label3'], engine_common.get_issue_labels('/test/fuzz_target')) def test_empty_lines(self): """Test labels file with empty lines.""" - self.fs.CreateFile( + self.fs.create_file( '/test/fuzz_target.labels', contents='label1\n\t\nlabel2\n \nlabel3\n') self.assertEqual(['label1', 'label2', 'label3'], engine_common.get_issue_labels('/test/fuzz_target')) @@ -215,14 +215,14 @@ def setUp(self): test_helpers.patch_environ(self) self.build_dir = '/test' self.fuzzer_name = 'fuzz_target' - self.fs.CreateDirectory(self.build_dir) + self.fs.create_dir(self.build_dir) def _setup_fuzzer(self, fuzzer_name=None): """Create a file to represent the fuzzer.""" if fuzzer_name is None: fuzzer_name = self.fuzzer_name fuzzer_path = os.path.join(self.build_dir, fuzzer_name) - self.fs.CreateFile(fuzzer_path) + self.fs.create_file(fuzzer_path) return fuzzer_path def _find_fuzzer_path(self, fuzzer_name=None): @@ -251,7 +251,7 @@ def test_finds_fuzzer_with_legacy_prefix_in_name_and_env(self): def test_only_finds_file(self): """Test that a directory is never returned.""" - self.fs.CreateDirectory(os.path.join(self.build_dir, self.fuzzer_name)) + self.fs.create_dir(os.path.join(self.build_dir, self.fuzzer_name)) self.assertIsNone(self._find_fuzzer_path()) @@ -303,7 +303,7 @@ def setUp(self): def _create_seed_corpus(self, extension): seed_corpus_archive_path = self.archive_path_without_extension + extension - self.fs.CreateFile(seed_corpus_archive_path) + self.fs.create_file(seed_corpus_archive_path) return seed_corpus_archive_path def _get_seed_corpus_path(self, fuzz_target_path): @@ -372,7 +372,7 @@ def setUp(self): self.seed_corpus_subdirs_contents = seed_corpus_handle.read() test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory(self.CORPUS_DIRECTORY) + self.fs.create_dir(self.CORPUS_DIRECTORY) def _unpack_seed_corpus_if_needed(self, *args, **kwargs): return engine_common.unpack_seed_corpus_if_needed( @@ -400,7 +400,7 @@ def _create_corpus_files(self, num_files): filenames = [] for file_num in range(num_files): file_num = str(file_num) - self.fs.CreateFile(os.path.join(self.CORPUS_DIRECTORY, file_num)) + self.fs.create_file(os.path.join(self.CORPUS_DIRECTORY, file_num)) filenames.append(file_num) return filenames diff --git a/src/python/tests/core/bot/fuzzers/libFuzzer/libfuzzer_launcher_test.py b/src/python/tests/core/bot/fuzzers/libFuzzer/libfuzzer_launcher_test.py index 6670bd5499..a07d621f6b 100644 --- a/src/python/tests/core/bot/fuzzers/libFuzzer/libfuzzer_launcher_test.py +++ b/src/python/tests/core/bot/fuzzers/libFuzzer/libfuzzer_launcher_test.py @@ -194,21 +194,21 @@ def setUp(self): # Set up fake filesystem. test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory(FUZZ_INPUTS_DISK) - self.fs.CreateDirectory(GSUTIL_PATH) + self.fs.create_dir(FUZZ_INPUTS_DISK) + self.fs.create_dir(GSUTIL_PATH) os.environ['BUILD_DIR'] = BUILD_DIR - self.fs.CreateFile(os.path.join(BUILD_DIR, 'fake_fuzzer')) - self.fs.CreateFile('/dev/null') - self.fs.CreateFile('/bin/sh') - self.fs.CreateDirectory('/lib') - self.fs.CreateDirectory('/lib64') - self.fs.CreateDirectory('/proc') - self.fs.CreateDirectory('/usr/lib') - self.fs.CreateDirectory(FAKE_ROOT_DIR) - self.fs.CreateDirectory(os.path.join(FAKE_ROOT_DIR, 'bot', 'logs')) - self.fs.CreateFile( + self.fs.create_file(os.path.join(BUILD_DIR, 'fake_fuzzer')) + self.fs.create_file('/dev/null') + self.fs.create_file('/bin/sh') + self.fs.create_dir('/lib') + self.fs.create_dir('/lib64') + self.fs.create_dir('/proc') + self.fs.create_dir('/usr/lib') + self.fs.create_dir(FAKE_ROOT_DIR) + self.fs.create_dir(os.path.join(FAKE_ROOT_DIR, 'bot', 'logs')) + self.fs.create_file( os.path.join(FAKE_ROOT_DIR, 'resources', 'platform', environment.platform().lower(), 'llvm-symbolizer')) @@ -239,8 +239,8 @@ def setUp(self): @mock.patch('sys.stdout', new_callable=test_utils.MockStdout) def test_analyze_recommended_dictionary(self, mock_stdout): """Test analysis of recommended dictionary.""" - self.fs.CreateDirectory('/fake/inputs-disk/temp-1337') - self.fs.CreateFile('/fuzzer_path') + self.fs.create_dir('/fake/inputs-disk/temp-1337') + self.fs.create_file('/fuzzer_path') log_lines = self.analyze_dict_log.splitlines() with mock.patch('subprocess.Popen', @@ -270,10 +270,10 @@ def test_analyze_recommended_dictionary(self, mock_stdout): lambda x, y, z: False) def test_basic_fuzz(self, mock_stdout): """Test a basic fuzzing run.""" - self.fs.CreateDirectory('/fake/corpus_basic') - self.fs.CreateFile('/fake/testcase_basic') + self.fs.create_dir('/fake/corpus_basic') + self.fs.create_file('/fake/testcase_basic') - self.fs.CreateFile( + self.fs.create_file( os.path.join(BUILD_DIR, 'fake_fuzzer.options'), contents=self.options_data) os.environ['ASAN_OPTIONS'] = 'blah=1:foo=0' @@ -459,13 +459,13 @@ def test_basic_fuzz_with_custom_options(self, mock_stdout): self.mock.generate_weighted_strategy_pool.return_value = set_strategy_pool( [strategy.RECOMMENDED_DICTIONARY_STRATEGY]) - self.fs.CreateDirectory('/fake/corpus_basic') - self.fs.CreateFile('/fake/testcase_basic') + self.fs.create_dir('/fake/corpus_basic') + self.fs.create_file('/fake/testcase_basic') - self.fs.CreateFile( + self.fs.create_file( os.path.join(BUILD_DIR, 'fake_fuzzer.options'), contents=self.options_data) - self.fs.CreateFile( + self.fs.create_file( os.path.join(BUILD_DIR, 'fake_fuzzer.dict'), contents=self.dictionary_data) os.environ['ASAN_OPTIONS'] = 'blah=1:foo=0' @@ -1135,8 +1135,8 @@ def test_parse_log_and_stats_timeout(self): @mock.patch('sys.stdout', new_callable=test_utils.MockStdout) def test_single_input(self, mock_stdout): """Tests a run for a single input.""" - self.fs.CreateFile('/fake/testcase', contents='fake') - self.fs.CreateDirectory('/fake/corpus') + self.fs.create_file('/fake/testcase', contents='fake') + self.fs.create_dir('/fake/corpus') with mock.patch('subprocess.Popen', create_mock_popen('OUTPUT')) as mock_popen: @@ -1158,8 +1158,8 @@ def test_single_input(self, mock_stdout): @mock.patch('sys.stdout', new_callable=test_utils.MockStdout) def test_single_input_with_custom_options(self, mock_stdout): """Tests a run for a single input with custom options.""" - self.fs.CreateFile('/fake/testcase', contents='fake') - self.fs.CreateDirectory('/fake/corpus') + self.fs.create_file('/fake/testcase', contents='fake') + self.fs.create_dir('/fake/corpus') with mock.patch('subprocess.Popen', create_mock_popen('OUTPUT')) as mock_popen: @@ -1185,11 +1185,11 @@ def test_single_input_with_custom_options(self, mock_stdout): @mock.patch('sys.stdout', new_callable=test_utils.MockStdout) def test_fuzz_crash(self, mock_stdout): """Tests a fuzzing run with a crash found.""" - self.fs.CreateFile('/fake/testcase_crash') - self.fs.CreateFile( + self.fs.create_file('/fake/testcase_crash') + self.fs.create_file( '/fake/crash-1e15825e6f0b2240a5af75d84214adda1b6b5340', contents='crasher') - self.fs.CreateDirectory('/fake/corpus_crash') + self.fs.create_dir('/fake/corpus_crash') os.environ['FUZZ_CORPUS_DIR'] = '/fake/corpus_crash' with mock.patch( @@ -1223,11 +1223,11 @@ def test_fuzz_crash(self, mock_stdout): @mock.patch('sys.stdout', new_callable=test_utils.MockStdout) def test_oom_crash(self, mock_stdout): """Tests a fuzzing run with a OOM.""" - self.fs.CreateFile('/fake/testcase_oom') - self.fs.CreateFile( + self.fs.create_file('/fake/testcase_oom') + self.fs.create_file( '/fake/oom-755e18dc1b20912de7556d11380e540231dc292c', contents='oom_crasher') - self.fs.CreateDirectory('/fake/corpus_oom') + self.fs.create_dir('/fake/corpus_oom') os.environ['FUZZ_CORPUS_DIR'] = '/fake/corpus_oom' new_units_added = 11 @@ -1382,16 +1382,16 @@ def test_fuzz_from_subset(self, _): self.mock.generate_weighted_strategy_pool.return_value = set_strategy_pool( [strategy.CORPUS_SUBSET_STRATEGY]) - self.fs.CreateFile('/fake/testcase_subset') - self.fs.CreateDirectory('/fake/main_corpus_dir') + self.fs.create_file('/fake/testcase_subset') + self.fs.create_dir('/fake/main_corpus_dir') # Intentionally put testcases into a subsir, as the main corpus directory # should be parsed recursively by both libFuzzer and CF code. - self.fs.CreateDirectory('/fake/main_corpus_dir/sub') + self.fs.create_dir('/fake/main_corpus_dir/sub') # To use corpus subset, there should be enough files in the main corpus. for i in range(1 + max(strategy.CORPUS_SUBSET_NUM_TESTCASES)): - self.fs.CreateFile('/fake/main_corpus_dir/sub/%d' % i) + self.fs.create_file('/fake/main_corpus_dir/sub/%d' % i) os.environ['FUZZ_CORPUS_DIR'] = '/fake/main_corpus_dir' @@ -1431,7 +1431,7 @@ def test_engine_error(self, mock_log_error): testcase_path = '/fake/engine_error_testcase' corpus_path = '/fake/engine_error_corpus' os.environ['FUZZ_CORPUS_DIR'] = corpus_path - self.fs.CreateDirectory(corpus_path) + self.fs.create_dir(corpus_path) mocked_popen = create_mock_popen( '', return_code=constants.LIBFUZZER_ERROR_EXITCODE) @@ -1448,7 +1448,7 @@ def test_set_sanitizer_options_exitcode(self): """Tests that set_sanitizer_options sets the exitcode correctly.""" testcase_path = '/fake/engine_error_testcase' corpus_path = '/fake/engine_error_corpus' - self.fs.CreateDirectory(corpus_path) + self.fs.create_dir(corpus_path) environment.set_value('ASAN_OPTIONS', 'exitcode=99') environment.set_value('JOB_NAME', 'libfuzzer_chrome_asan') launcher.set_sanitizer_options(testcase_path) @@ -1464,8 +1464,8 @@ def test_fuzz_from_subset_without_enough_corpus(self, _): self.mock.generate_weighted_strategy_pool.return_value = set_strategy_pool( [strategy.CORPUS_SUBSET_STRATEGY]) - self.fs.CreateFile('/fake/testcase_subset') - self.fs.CreateDirectory('/fake/main_corpus_dir') + self.fs.create_file('/fake/testcase_subset') + self.fs.create_dir('/fake/main_corpus_dir') os.environ['FUZZ_CORPUS_DIR'] = '/fake/main_corpus_dir' # Main corpus directory is empty, we should fall back to regular fuzzing. @@ -1510,17 +1510,17 @@ def test_fuzz_from_subset_minijail(self, mock_tempfile, _): mock_tempfile.return_value.__enter__.return_value.name = '/tmppath' mock_tempfile.return_value.name = '/tmpfile' - self.fs.CreateFile('/fake/testcase_subset') - self.fs.CreateDirectory('/fake/main_corpus_dir') + self.fs.create_file('/fake/testcase_subset') + self.fs.create_dir('/fake/main_corpus_dir') os.environ['FUZZ_CORPUS_DIR'] = '/fake/main_corpus_dir' # Intentionally put testcases into a subsir, as the main corpus directory # should be parsed recursively by both libFuzzer and CF code. - self.fs.CreateDirectory('/fake/main_corpus_dir/sub') + self.fs.create_dir('/fake/main_corpus_dir/sub') # To use corpus subset, there should be enough files in the main corpus. for i in range(1 + max(strategy.CORPUS_SUBSET_NUM_TESTCASES)): - self.fs.CreateFile('/fake/main_corpus_dir/sub/%d' % i) + self.fs.create_file('/fake/main_corpus_dir/sub/%d' % i) new_units_added = 11 with mock.patch( @@ -1637,10 +1637,10 @@ def test_fuzz_from_subset_without_enough_corpus_minijail( mock_tempfile.return_value.__enter__.return_value.name = '/tmppath' mock_tempfile.return_value.name = '/tmpfile' - self.fs.CreateFile('/fake/testcase_subset') + self.fs.create_file('/fake/testcase_subset') # Main corpus directory is empty, we should fall back to regular fuzzing. - self.fs.CreateDirectory('/fake/main_corpus_dir') + self.fs.create_dir('/fake/main_corpus_dir') os.environ['FUZZ_CORPUS_DIR'] = '/fake/main_corpus_dir' new_units_added = 11 @@ -1750,8 +1750,8 @@ def test_fuzz_with_mutations_using_radamsa(self, *_): self.mock.generate_weighted_strategy_pool.return_value = set_strategy_pool( [strategy.CORPUS_MUTATION_RADAMSA_STRATEGY]) - self.fs.CreateFile('/fake/testcase_mutations') - self.fs.CreateDirectory('/fake/corpus_mutations') + self.fs.create_file('/fake/testcase_mutations') + self.fs.create_dir('/fake/corpus_mutations') os.environ['FUZZ_CORPUS_DIR'] = '/fake/corpus_mutations' new_units_added = 11 @@ -1798,8 +1798,8 @@ def test_fuzz_with_mutations_using_ml_rnn(self, mock_execute, *_): self.mock.generate_weighted_strategy_pool.return_value = set_strategy_pool( [strategy.CORPUS_MUTATION_ML_RNN_STRATEGY]) - self.fs.CreateFile('/fake/testcase_mutations') - self.fs.CreateDirectory('/fake/corpus_mutations') + self.fs.create_file('/fake/testcase_mutations') + self.fs.create_dir('/fake/corpus_mutations') os.environ['FUZZ_CORPUS_DIR'] = '/fake/corpus_mutations' new_units_added = 11 @@ -1845,9 +1845,9 @@ def _dataflow_tracing_test_setup(self): self.mock.generate_weighted_strategy_pool.return_value = set_strategy_pool( [strategy.DATAFLOW_TRACING_STRATEGY]) - self.fs.CreateDirectory('/fake/corpus_dir') - self.fs.CreateFile('/fake/testcase_basic') - self.fs.CreateFile('/fake/dfsan_build/fake_fuzzer') + self.fs.create_dir('/fake/corpus_dir') + self.fs.create_file('/fake/testcase_basic') + self.fs.create_file('/fake/dfsan_build/fake_fuzzer') os.environ['FUZZ_CORPUS_DIR'] = '/fake/corpus_dir' os.environ['DATAFLOW_BUILD_DIR'] = '/fake/dfsan_build' @@ -2188,8 +2188,8 @@ def test_fuzz_with_fork_mode(self, mock_stdout, *_): self.mock.generate_weighted_strategy_pool.return_value = set_strategy_pool( [strategy.FORK_STRATEGY]) - self.fs.CreateDirectory('/fake/corpus_dir') - self.fs.CreateFile('/fake/testcase_basic') + self.fs.create_dir('/fake/corpus_dir') + self.fs.create_file('/fake/testcase_basic') os.environ['FUZZ_CORPUS_DIR'] = '/fake/corpus_dir' @@ -2403,12 +2403,12 @@ def setUp(self): self.work_directory_path = '/fake/fuzzers/' self.fuzz_inputs_path = '/fake/fuzzers/inputs' self.fuzz_inputs_disk_path = '/fake/fuzzers/inputs-disk' - self.fs.CreateDirectory(self.work_directory_path) - self.fs.CreateDirectory(self.fuzz_inputs_path) - self.fs.CreateDirectory(self.fuzz_inputs_disk_path) + self.fs.create_dir(self.work_directory_path) + self.fs.create_dir(self.fuzz_inputs_path) + self.fs.create_dir(self.fuzz_inputs_disk_path) self.local_dictionaries_dir = os.path.join(self.work_directory_path, 'dicts') - self.fs.CreateDirectory(self.local_dictionaries_dir) + self.fs.create_dir(self.local_dictionaries_dir) self.fuzzer_name = 'test_fuzzer' self.fuzzer_path = os.path.join(self.work_directory_path, self.fuzzer_name) @@ -2445,7 +2445,7 @@ def test_add_recommended_dictionary_with_merge(self): """Test dictionary processing when there is a local dictionary.""" dictionary_path = os.path.join(self.work_directory_path, 'dictionary_from_repository.dict') - self.fs.CreateFile( + self.fs.create_file( dictionary_path, contents=self.dictionary_from_repository_data) dictionary_argument = '-dict=%s' % dictionary_path @@ -2518,9 +2518,10 @@ def move_mergeable_units(self): def test_duplicate_not_moved(self): """Tests that a duplicated file is not moved into the corpus directory.""" - self.fs.CreateFile(os.path.join(self.CORPUS_DIRECTORY, ARBITRARY_SHA1_HASH)) + self.fs.create_file( + os.path.join(self.CORPUS_DIRECTORY, ARBITRARY_SHA1_HASH)) merge_corpus_file = os.path.join(self.MERGE_DIRECTORY, ARBITRARY_SHA1_HASH) - self.fs.CreateFile(merge_corpus_file) + self.fs.create_file(merge_corpus_file) self.move_mergeable_units() # File will be deleted from merge directory if it isn't a duplicate. self.assertTrue(os.path.exists(merge_corpus_file)) @@ -2530,11 +2531,11 @@ def test_new_file_moved(self): # Make a file that looks like a sha1 hash but is different from # ARBITRARY_SHA1_HASH. filename = ARBITRARY_SHA1_HASH.replace('d', 'a') - self.fs.CreateFile(os.path.join(self.CORPUS_DIRECTORY, filename)) + self.fs.create_file(os.path.join(self.CORPUS_DIRECTORY, filename)) # Create an arbitrary file with a hash name that is different from this # filename. merge_corpus_file = os.path.join(self.MERGE_DIRECTORY, ARBITRARY_SHA1_HASH) - self.fs.CreateFile(merge_corpus_file) + self.fs.create_file(merge_corpus_file) self.move_mergeable_units() # File will be deleted from merge directory if it isn't a duplicate. self.assertFalse(os.path.exists(merge_corpus_file)) diff --git a/src/python/tests/core/bot/fuzzers/mutator_plugin_test.py b/src/python/tests/core/bot/fuzzers/mutator_plugin_test.py index 5d9b273072..c6f04c0915 100644 --- a/src/python/tests/core/bot/fuzzers/mutator_plugin_test.py +++ b/src/python/tests/core/bot/fuzzers/mutator_plugin_test.py @@ -39,7 +39,7 @@ def test_find_mutator_plugin_with_usable(self): self.plugins_root_dir, 'plugins', mutator_plugin.MUTATOR_SHARED_OBJECT_FILENAME) - self.fs.CreateFile(usable_plugin_path) + self.fs.create_file(usable_plugin_path) self.assertEqual(usable_plugin_path, mutator_plugin.find_mutator_plugin()) def test_set_mutator_plugin_without_usable(self): @@ -93,7 +93,7 @@ def setUp(self): self.name = 'myplugin' self.plugins_root_dir = '/plugins' os.environ['MUTATOR_PLUGINS_DIR'] = self.plugins_root_dir - self.fs.CreateDirectory(self.plugins_root_dir) + self.fs.create_dir(self.plugins_root_dir) self.plugin_getter = mutator_plugin.PluginGetter(self.fuzzer_binary_name) self.plugins_archives_dir = os.path.join(self.plugins_root_dir, 'archives') self.plugin_archive_filename = '%s-%s-%s.zip' % ( @@ -120,7 +120,7 @@ def mocked_copy_file_from(gcs_url, file_path): def test_create_directories(self): """Tests that create_directories creates the right directories.""" shutil.rmtree(self.plugins_root_dir) - self.fs.CreateDirectory(self.plugins_root_dir) + self.fs.create_dir(self.plugins_root_dir) self.plugin_getter.create_directories() directories = [ os.path.join(self.plugins_root_dir, 'plugins'), diff --git a/src/python/tests/core/bot/fuzzers/options_test.py b/src/python/tests/core/bot/fuzzers/options_test.py index d9c3376ae8..62f003b2be 100644 --- a/src/python/tests/core/bot/fuzzers/options_test.py +++ b/src/python/tests/core/bot/fuzzers/options_test.py @@ -43,8 +43,8 @@ def test_basic(self, mock_sysrandom): '[ubsan]\n' 'ubsan_option=0\n') - self.fs.CreateFile('/path/blah.options', contents=input_data) - self.fs.CreateFile('/path/blah.dict', contents=input_data) + self.fs.create_file('/path/blah.options', contents=input_data) + self.fs.create_file('/path/blah.dict', contents=input_data) fuzzer_options = options.FuzzerOptions('/path/blah.options') fuzzer_arguments = fuzzer_options.get_engine_arguments('libfuzzer') @@ -77,7 +77,7 @@ def setUp(self): test_utils.set_up_pyfakefs(self) input_data = ('[libfuzzer]\n' 'close_fd_mask=1\n') - self.fs.CreateFile('/path/fuzz_target.options', contents=input_data) + self.fs.create_file('/path/fuzz_target.options', contents=input_data) def _get_arguments(self, fuzz_target_path): """Helper to return fuzz target arguments by parsing options file for a diff --git a/src/python/tests/core/bot/fuzzers/utils_test.py b/src/python/tests/core/bot/fuzzers/utils_test.py index d01dbadc08..cb16f236df 100644 --- a/src/python/tests/core/bot/fuzzers/utils_test.py +++ b/src/python/tests/core/bot/fuzzers/utils_test.py @@ -28,52 +28,53 @@ def setUp(self): test_utils.set_up_pyfakefs(self) def test_not_a_fuzzer_invalid_name(self): - self.fs.CreateFile('/abc$_fuzzer', contents='anything') + self.fs.create_file('/abc$_fuzzer', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/abc$_fuzzer')) def test_not_a_fuzzer_without_extension(self): - self.fs.CreateFile('/abc', contents='anything') + self.fs.create_file('/abc', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/abc')) def test_not_a_fuzzer_with_extension(self): - self.fs.CreateFile('/abc.dict', contents='anything') + self.fs.create_file('/abc.dict', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/abc.dict')) def test_not_a_fuzzer_with_extension_and_suffix(self): - self.fs.CreateFile('/abc_fuzzer.dict', contents='anything') + self.fs.create_file('/abc_fuzzer.dict', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/abc_fuzzer.dict')) def test_fuzzer_posix(self): - self.fs.CreateFile('/abc_fuzzer', contents='anything') + self.fs.create_file('/abc_fuzzer', contents='anything') self.assertTrue(utils.is_fuzz_target_local('/abc_fuzzer')) def test_fuzzer_win(self): - self.fs.CreateFile('/abc_fuzzer.exe', contents='anything') + self.fs.create_file('/abc_fuzzer.exe', contents='anything') self.assertTrue(utils.is_fuzz_target_local('/abc_fuzzer.exe')) def test_fuzzer_not_exist(self): self.assertFalse(utils.is_fuzz_target_local('/not_exist_fuzzer')) def test_fuzzer_without_suffix(self): - self.fs.CreateFile('/abc', contents='anything\nLLVMFuzzerTestOneInput') + self.fs.create_file('/abc', contents='anything\nLLVMFuzzerTestOneInput') self.assertTrue(utils.is_fuzz_target_local('/abc')) def test_fuzzer_with_name_regex_match(self): environment.set_value('FUZZER_NAME_REGEX', '.*_custom$') - self.fs.CreateFile('/a_custom', contents='anything') + self.fs.create_file('/a_custom', contents='anything') self.assertTrue(utils.is_fuzz_target_local('/a_custom')) def test_fuzzer_with_file_string_and_without_name_regex_match(self): environment.set_value('FUZZER_NAME_REGEX', '.*_custom$') - self.fs.CreateFile('/nomatch', contents='anything\nLLVMFuzzerTestOneInput') + self.fs.create_file('/nomatch', contents='anything\nLLVMFuzzerTestOneInput') self.assertFalse(utils.is_fuzz_target_local('/nomatch')) def test_fuzzer_without_file_string_and_without_name_regex_match(self): environment.set_value('FUZZER_NAME_REGEX', '.*_custom$') - self.fs.CreateFile('/nomatch', contents='anything') + self.fs.create_file('/nomatch', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/nomatch')) def test_fuzzer_with_fuzzer_name_and_without_name_regex_match(self): environment.set_value('FUZZER_NAME_REGEX', '.*_custom$') - self.fs.CreateFile('/a_fuzzer', contents='anything\nLLVMFuzzerTestOneInput') + self.fs.create_file( + '/a_fuzzer', contents='anything\nLLVMFuzzerTestOneInput') self.assertTrue(utils.is_fuzz_target_local('/a_fuzzer')) diff --git a/src/python/tests/core/bot/tasks/fuzz_task_test.py b/src/python/tests/core/bot/tasks/fuzz_task_test.py index 7947bdf124..8c09ef4ea0 100644 --- a/src/python/tests/core/bot/tasks/fuzz_task_test.py +++ b/src/python/tests/core/bot/tasks/fuzz_task_test.py @@ -1138,12 +1138,12 @@ def setUp(self): self.mock.rsync_to_disk.return_value = True test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory('/dir') - self.fs.CreateDirectory('/dir1') + self.fs.create_dir('/dir') + self.fs.create_dir('/dir1') def _write_corpus_files(self, *args, **kwargs): # pylint: disable=unused-argument - self.fs.CreateFile('/dir/a') - self.fs.CreateFile('/dir/b') + self.fs.create_file('/dir/a') + self.fs.create_file('/dir/b') return True def test_sync(self): @@ -1154,7 +1154,7 @@ def test_sync(self): self.assertTrue(corpus.sync_from_gcs()) self.assertTrue(os.path.exists('/dir1/.child_sync')) self.assertEqual(('/dir',), self.mock.rsync_to_disk.call_args[0][1:]) - self.fs.CreateFile('/dir/c') + self.fs.create_file('/dir/c') self.assertListEqual(['/dir/c'], corpus.get_new_files()) corpus.upload_files(corpus.get_new_files()) diff --git a/src/python/tests/core/bot/tasks/ml_train_task_test.py b/src/python/tests/core/bot/tasks/ml_train_task_test.py index 727ebfd81e..95156e4aae 100644 --- a/src/python/tests/core/bot/tasks/ml_train_task_test.py +++ b/src/python/tests/core/bot/tasks/ml_train_task_test.py @@ -42,7 +42,7 @@ def setUp(self): test_utils.set_up_pyfakefs(self) # Create model directory. - self.fs.CreateDirectory(MODEL_DIR) + self.fs.create_dir(MODEL_DIR) # Create fake meta file, index file and data file. # Model_1 has three complete files. @@ -52,9 +52,9 @@ def setUp(self): self.model_1_index_path = os.path.join(MODEL_DIR, 'model_1.index') # Create three files for model_1. - self.fs.CreateFile(self.model_1_meta_path) - self.fs.CreateFile(self.model_1_data_path) - self.fs.CreateFile(self.model_1_index_path) + self.fs.create_file(self.model_1_meta_path) + self.fs.create_file(self.model_1_data_path) + self.fs.create_file(self.model_1_index_path) # Update timestamp. os.utime(self.model_1_meta_path, (1330711140, 1330711160)) @@ -68,9 +68,9 @@ def setUp(self): self.model_2_index_path = os.path.join(MODEL_DIR, 'model_2.index') # Create three files for model_2. - self.fs.CreateFile(self.model_2_meta_path) - self.fs.CreateFile(self.model_2_data_path) - self.fs.CreateFile(self.model_2_index_path) + self.fs.create_file(self.model_2_meta_path) + self.fs.create_file(self.model_2_data_path) + self.fs.create_file(self.model_2_index_path) # Update timestamp. Make sure they are newer than model_1. os.utime(self.model_2_meta_path, (1330713340, 1330713360)) diff --git a/src/python/tests/core/bot/tasks/update_task_test.py b/src/python/tests/core/bot/tasks/update_task_test.py index 782b81131f..b8d569ae69 100644 --- a/src/python/tests/core/bot/tasks/update_task_test.py +++ b/src/python/tests/core/bot/tasks/update_task_test.py @@ -42,7 +42,7 @@ def test_no_revision(self): def test_has_revision(self): """Test when there's a revision.""" os.mkdir('/root') - self.fs.CreateFile( + self.fs.create_file( os.path.join('/root', utils.LOCAL_SOURCE_MANIFEST), contents='revision') self.assertEqual('revision', update_task.get_local_source_revision()) @@ -70,7 +70,7 @@ def test_no_revision(self): def test_has_revision(self): """Test when there's a revision.""" os.mkdir('/root') - self.fs.CreateFile( + self.fs.create_file( os.path.join('/root', utils.LOCAL_SOURCE_MANIFEST), contents='revision') update_task.track_revision() self.assertEqual(1, diff --git a/src/python/tests/core/bot/untrusted_runner/file_host_test.py b/src/python/tests/core/bot/untrusted_runner/file_host_test.py index efdb73e9c4..c19479fbe1 100644 --- a/src/python/tests/core/bot/untrusted_runner/file_host_test.py +++ b/src/python/tests/core/bot/untrusted_runner/file_host_test.py @@ -62,7 +62,7 @@ def test_copy_file_to_worker(self): 'B' * config.FILE_TRANSFER_CHUNK_SIZE + 'C' * config.FILE_TRANSFER_CHUNK_SIZE) - self.fs.CreateFile('/file', contents=contents) + self.fs.create_file('/file', contents=contents) def mock_copy_file_to(iterator, metadata): """Mock copy file to.""" @@ -146,11 +146,11 @@ def test_copy_directory_to_worker(self, mock_copy_file_to_worker, """Test file_host.copy_directory_to_worker.""" mock_copy_file_to_worker.return_value = True - self.fs.CreateFile('/host/dir/file1') - self.fs.CreateFile('/host/dir/file2') - self.fs.CreateFile('/host/dir/dir2/file3') - self.fs.CreateFile('/host/dir/dir2/file4') - self.fs.CreateFile('/host/dir/dir2/dir3/file5') + self.fs.create_file('/host/dir/file1') + self.fs.create_file('/host/dir/file2') + self.fs.create_file('/host/dir/dir2/file3') + self.fs.create_file('/host/dir/dir2/file4') + self.fs.create_file('/host/dir/dir2/dir3/file5') self.assertTrue( file_host.copy_directory_to_worker('/host/dir', '/worker/copied_dir')) diff --git a/src/python/tests/core/bot/untrusted_runner/file_impl_test.py b/src/python/tests/core/bot/untrusted_runner/file_impl_test.py index 26e60a21b6..74e2b7b4f4 100644 --- a/src/python/tests/core/bot/untrusted_runner/file_impl_test.py +++ b/src/python/tests/core/bot/untrusted_runner/file_impl_test.py @@ -84,7 +84,7 @@ def test_copy_file_to_worker(self): def test_stat(self): """Test file_impl.stat.""" - self.fs.CreateFile('/file') + self.fs.create_file('/file') request = untrusted_runner_pb2.StatRequest(path='/file') response = file_impl.stat(request, None) @@ -129,7 +129,7 @@ def test_copy_file_to_worker_create_dir_is_a_file(self): untrusted_runner_pb2.FileChunk(data='C'), ) - self.fs.CreateFile('/file') + self.fs.create_file('/file') context = mock.MagicMock() context.invocation_metadata.return_value = (('path-bin', '/file/file'),) @@ -147,7 +147,7 @@ def test_copy_file_to_worker_create_dir_error(self): untrusted_runner_pb2.FileChunk(data='C'), ) - self.fs.CreateFile('/file') + self.fs.create_file('/file') context = mock.MagicMock() context.invocation_metadata.return_value = (('path-bin', '/file/dir/file'),) @@ -162,7 +162,7 @@ def test_copy_file_from_worker(self): 'B' * config.FILE_TRANSFER_CHUNK_SIZE + 'C' * config.FILE_TRANSFER_CHUNK_SIZE) - self.fs.CreateFile('/file', contents=contents) + self.fs.create_file('/file', contents=contents) request = untrusted_runner_pb2.CopyFileFromRequest(path='/file') context = mock.MagicMock() diff --git a/src/python/tests/core/bot/webserver/http_server_test.py b/src/python/tests/core/bot/webserver/http_server_test.py index b1d1e35eb1..1ed2432e73 100644 --- a/src/python/tests/core/bot/webserver/http_server_test.py +++ b/src/python/tests/core/bot/webserver/http_server_test.py @@ -61,9 +61,9 @@ def setUp(self): os.environ['FUZZ_DATA'] = '/data' os.environ['FUZZERS_DIR'] = '/fuzzers' os.environ['INPUT_DIR'] = '/input' - self.fs.CreateFile( + self.fs.create_file( os.path.join('/input', 'valid.txt'), contents='valid file') - self.fs.CreateFile( + self.fs.create_file( os.path.join('/input', 'unreadable.txt'), contents='unreadable file') os.chmod(os.path.join('/input', 'unreadable.txt'), 0) diff --git a/src/python/tests/core/build_management/build_manager_test.py b/src/python/tests/core/build_management/build_manager_test.py index 22e4dc3b38..5f75740be4 100644 --- a/src/python/tests/core/build_management/build_manager_test.py +++ b/src/python/tests/core/build_management/build_manager_test.py @@ -1221,11 +1221,11 @@ def setUp(self): os.makedirs('/builds/build2/revisions') os.makedirs('/builds/build3/revisions') os.makedirs('/builds/build4/revisions') - self.fs.CreateFile( + self.fs.create_file( '/builds/build1/.timestamp', contents='1486166114.668105') - self.fs.CreateFile( + self.fs.create_file( '/builds/build2/.timestamp', contents='1486166110.142942') - self.fs.CreateFile( + self.fs.create_file( '/builds/build3/.timestamp', contents='1486166112.180345') self.free_disk_space = [] diff --git a/src/python/tests/core/datastore/data_handler_test.py b/src/python/tests/core/datastore/data_handler_test.py index cbc0359708..00465f4035 100644 --- a/src/python/tests/core/datastore/data_handler_test.py +++ b/src/python/tests/core/datastore/data_handler_test.py @@ -45,7 +45,7 @@ def test_set(self): os.environ['BUILD_URL'] = 'build_url_value' os.environ['APP_DIR'] = 'app_dir_value' os.environ['GN_ARGS_PATH'] = 'app_dir_value/args.gn' - self.fs.CreateFile( + self.fs.create_file( 'app_dir_value/args.gn', contents=('is_asan = true\n' 'goma_dir = /home/user/goma\n' diff --git a/src/python/tests/core/fuzzing/corpus_manager_test.py b/src/python/tests/core/fuzzing/corpus_manager_test.py index 050b071d7f..854aad2356 100644 --- a/src/python/tests/core/fuzzing/corpus_manager_test.py +++ b/src/python/tests/core/fuzzing/corpus_manager_test.py @@ -210,7 +210,7 @@ def setUp(self): self.mock.cpu_count.return_value = 2 self.mock._count_corpus_files.return_value = 1 # pylint: disable=protected-access test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory('/dir') + self.fs.create_dir('/dir') def test_rsync_to_disk(self): """Test rsync_to_disk.""" @@ -269,7 +269,7 @@ class CorpusBackupTest(fake_filesystem_unittest.TestCase): def _mock_make_archive(self, archive_path, backup_format, _): path = archive_path + '.' + backup_format - self.fs.CreateFile(path) + self.fs.create_file(path) return path @@ -277,7 +277,7 @@ def setUp(self): test_helpers.patch_environ(self) test_utils.set_up_pyfakefs(self) - self.fs.CreateDirectory('/dir') + self.fs.create_dir('/dir') os.environ['GSUTIL_PATH'] = '/gsutil_path' os.environ['CORPUS_BUCKET'] = 'bucket' diff --git a/src/python/tests/core/fuzzing/testcase_manager_test.py b/src/python/tests/core/fuzzing/testcase_manager_test.py index 64d8768b04..f69b2a151c 100644 --- a/src/python/tests/core/fuzzing/testcase_manager_test.py +++ b/src/python/tests/core/fuzzing/testcase_manager_test.py @@ -36,11 +36,11 @@ def setUp(self): def test_create(self): """Tests creation of testcase list file.""" - self.fs.CreateFile('/test/aa/bb.txt', contents='') - self.fs.CreateFile('/test/aa/cc.txt', contents='') - self.fs.CreateFile('/test/aa/aa/dd.txt', contents='') - self.fs.CreateFile('/test/aa/aa/files.info', contents='') - self.fs.CreateFile('/test/aa/bb/files.chrome.info', contents='') + self.fs.create_file('/test/aa/bb.txt', contents='') + self.fs.create_file('/test/aa/cc.txt', contents='') + self.fs.create_file('/test/aa/aa/dd.txt', contents='') + self.fs.create_file('/test/aa/aa/files.info', contents='') + self.fs.create_file('/test/aa/bb/files.chrome.info', contents='') testcase_manager.create_testcase_list_file('/test/aa') @@ -63,7 +63,7 @@ def setUp(self): test_helpers.patch_environ(self) test_utils.set_up_pyfakefs(self) self.testcase_path = '/test/fuzzer/testcase' - self.fs.CreateFile(self.testcase_path, contents='') + self.fs.create_file(self.testcase_path, contents='') environment.set_value('FUZZ_LOGS_BUCKET', 'fake-gcs-logs') environment.set_value('FUZZER_NAME', 'fuzzer') @@ -98,7 +98,7 @@ def test_upload_with_timestamp_from_stats(self): mock_gsutil = mock.MagicMock() self.mock.write_data.return_value = mock_gsutil - self.fs.CreateFile( + self.fs.create_file( self.testcase_path + '.stats2', contents='{"stat": 1000, "timestamp": 1472846341.017923, "kind": ' '"TestcaseRun", "job": "job", "fuzzer": "fuzzer", ' @@ -120,7 +120,7 @@ def test_upload_without_timestamp(self): mock_gsutil = mock.MagicMock() self.mock.write_data.return_value = mock_gsutil - self.fs.CreateFile( + self.fs.create_file( self.testcase_path + '.stats2', contents='{"stat": 1000, "kind": "TestcaseRun", "job": "job", ' '"fuzzer": "fuzzer", "build_revision": 123}\n') @@ -140,7 +140,7 @@ def test_upload_without_component_revisions(self): mock_gsutil = mock.MagicMock() self.mock.write_data.return_value = mock_gsutil - self.fs.CreateFile( + self.fs.create_file( self.testcase_path + '.stats2', contents='{"stat": 1000, "timestamp": 1472846341.017923, "kind": ' '"TestcaseRun", "job": "job", "fuzzer": "fuzzer", ' diff --git a/src/python/tests/core/google_cloud_utils/gsutil_test.py b/src/python/tests/core/google_cloud_utils/gsutil_test.py index 0f2a4aac18..748e1ae4fd 100644 --- a/src/python/tests/core/google_cloud_utils/gsutil_test.py +++ b/src/python/tests/core/google_cloud_utils/gsutil_test.py @@ -48,8 +48,8 @@ def test_rsync_remote_gcs_1(self): def test_rsync_local_gcs_1(self): """Test rsync.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/source_bucket') - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/source_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.rsync('gs://source_bucket/source_path', 'gs://target_bucket/target_path') self.mock.run_and_wait.assert_called_with( @@ -77,8 +77,8 @@ def test_rsync_remote_gcs_2(self): def test_rsync_local_gcs_2(self): """Test rsync.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/source_bucket') - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/source_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.rsync( 'gs://source_bucket/source_path', 'gs://target_bucket/target_path', @@ -108,8 +108,8 @@ def test_rsync_remote_gcs_3(self): def test_rsync_local_gcs_3(self): """Test rsync.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/source_bucket') - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/source_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.rsync( 'gs://source_bucket/source_path', 'gs://target_bucket/target_path', @@ -139,8 +139,8 @@ def test_rsync_remote_gcs_4(self): def test_rsync_local_gcs_4(self): """Test rsync.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/source_bucket') - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/source_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.rsync( 'gs://source_bucket/source_path', 'gs://target_bucket/target_path', @@ -172,8 +172,8 @@ def test_rsync_remote_gcs_5(self): def test_rsync_local_gcs_5(self): """Test rsync.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/source_bucket') - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/source_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.rsync( 'gs://source_bucket/source_path', 'gs://target_bucket/target_path', @@ -239,7 +239,7 @@ def test_upload_file_remote_gcs_1(self): def test_upload_file_local_gcs_1(self): """Test upload_file.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.upload_file('/source_path', 'gs://target_bucket/target_path') self.mock.run_and_wait.assert_called_with( @@ -266,7 +266,7 @@ def test_upload_file_remote_gcs_2(self): def test_upload_file_local_gcs_2(self): """Test upload_file.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.upload_file( '/source_path', 'gs://target_bucket/target_path', @@ -294,7 +294,7 @@ def test_upload_files_to_url_remote_gcs_1(self): def test_upload_files_local_gcs_1(self): """Test upload_files_to_url.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.upload_files_to_url( ['/source_path1', '/source_path2'], 'gs://target_bucket/target_path') self.mock.run_and_wait.assert_called_with( @@ -319,7 +319,7 @@ def test_upload_files_remote_gcs_2(self): def test_upload_files_to_url_local_gcs_2(self): """Test upload_files_to_url.""" os.environ['LOCAL_GCS_BUCKETS_PATH'] = '/local' - self.fs.CreateDirectory('/local/target_bucket') + self.fs.create_dir('/local/target_bucket') self.gsutil_runner_obj.upload_files_to_url( ['/source_path1', '/source_path2'], 'gs://target_bucket/target_path', diff --git a/src/python/tests/core/google_cloud_utils/storage_test.py b/src/python/tests/core/google_cloud_utils/storage_test.py index 52cc85d86c..e21aa946da 100644 --- a/src/python/tests/core/google_cloud_utils/storage_test.py +++ b/src/python/tests/core/google_cloud_utils/storage_test.py @@ -87,7 +87,7 @@ def test_create_bucket(self): def test_get_bucket(self): """Test get_bucket.""" - self.fs.CreateDirectory('/local/test-bucket') + self.fs.create_dir('/local/test-bucket') self.assertDictEqual({ 'name': 'test-bucket', }, self.provider.get_bucket('test-bucket')) @@ -97,15 +97,15 @@ def test_list_blobs(self): mtime = datetime.datetime(2019, 1, 1) mtime_seconds = utils.utc_datetime_to_timestamp(mtime) - self.fs.CreateFile( + self.fs.create_file( '/local/test-bucket/objects/a', st_size=11).st_mtime = mtime_seconds - self.fs.CreateFile( + self.fs.create_file( '/local/test-bucket/objects/b/c', st_size=22).st_mtime = mtime_seconds - self.fs.CreateFile( + self.fs.create_file( '/local/test-bucket/objects/b/d/e', st_size=33).st_mtime = mtime_seconds - self.fs.CreateFile( + self.fs.create_file( '/local/test-bucket/objects/f', st_size=44).st_mtime = mtime_seconds - self.fs.CreateFile( + self.fs.create_file( '/local/test-bucket/metadata/b/c', contents='{"key":"value"}').st_mtime = mtime_seconds @@ -185,15 +185,15 @@ def test_list_blobs(self): def test_copy_file_from(self): """Test copy_file_from.""" - self.fs.CreateFile('/local/test-bucket/objects/a', contents='a') + self.fs.create_file('/local/test-bucket/objects/a', contents='a') self.provider.copy_file_from('gs://test-bucket/a', '/a') with open('/a') as f: self.assertEqual('a', f.read()) def test_copy_file_to(self): """Test copy_file_to.""" - self.fs.CreateFile('/a', contents='a') - self.fs.CreateDirectory('/local/test-bucket') + self.fs.create_file('/a', contents='a') + self.fs.create_dir('/local/test-bucket') self.provider.copy_file_to( '/a', 'gs://test-bucket/subdir/a', metadata={'key': 'value'}) @@ -205,7 +205,7 @@ def test_copy_file_to(self): def test_copy_blob(self): """Test copy_blob.""" - self.fs.CreateFile('/local/test-bucket/objects/a', contents='a') + self.fs.create_file('/local/test-bucket/objects/a', contents='a') self.provider.copy_blob('gs://test-bucket/a', 'gs://test-bucket/copy/a') with open('/local/test-bucket/objects/copy/a') as f: @@ -213,12 +213,12 @@ def test_copy_blob(self): def test_read_data(self): """Test copy_blob.""" - self.fs.CreateFile('/local/test-bucket/objects/a', contents='a') + self.fs.create_file('/local/test-bucket/objects/a', contents='a') self.assertEqual('a', self.provider.read_data('gs://test-bucket/a')) def test_write_data(self): """Test copy_blob.""" - self.fs.CreateDirectory('/local/test-bucket') + self.fs.create_dir('/local/test-bucket') self.provider.write_data( 'a', 'gs://test-bucket/subdir/a', metadata={'key': 'value'}) with open('/local/test-bucket/objects/subdir/a') as f: @@ -232,9 +232,9 @@ def test_get(self): mtime = datetime.datetime(2019, 1, 1) mtime_seconds = utils.utc_datetime_to_timestamp(mtime) - self.fs.CreateFile( + self.fs.create_file( '/local/test-bucket/objects/a', contents='a').st_mtime = mtime_seconds - self.fs.CreateFile( + self.fs.create_file( '/local/test-bucket/metadata/a', contents='{"key": "value"}') self.assertDictEqual({ @@ -249,8 +249,8 @@ def test_get(self): def test_delete(self): """Test get.""" - self.fs.CreateFile('/local/test-bucket/objects/a', contents='a') - self.fs.CreateFile( + self.fs.create_file('/local/test-bucket/objects/a', contents='a') + self.fs.create_file( '/local/test-bucket/metadata/a', contents='{"key": "value"}') self.provider.delete('gs://test-bucket/a') diff --git a/src/python/tests/core/local/butler/deploy_test.py b/src/python/tests/core/local/butler/deploy_test.py index 042213f924..52beceed9d 100644 --- a/src/python/tests/core/local/butler/deploy_test.py +++ b/src/python/tests/core/local/butler/deploy_test.py @@ -394,16 +394,16 @@ class FindFileExceedingLimitTest(fake_filesystem_unittest.TestCase): def setUp(self): test_utils.set_up_pyfakefs(self) - self.fs.CreateFile('/test/small1', contents='aaa') - self.fs.CreateFile('/test/small2', contents='aaa') - self.fs.CreateFile('/test/dir1/small3', contents='aaa') - self.fs.CreateFile('/test/dir1/small4', contents='aaa') - self.fs.CreateFile('/test/dir1/dir1/small5', contents='aaa') - self.fs.CreateFile('/test/dir2/small6', contents='aaa') + self.fs.create_file('/test/small1', contents='aaa') + self.fs.create_file('/test/small2', contents='aaa') + self.fs.create_file('/test/dir1/small3', contents='aaa') + self.fs.create_file('/test/dir1/small4', contents='aaa') + self.fs.create_file('/test/dir1/dir1/small5', contents='aaa') + self.fs.create_file('/test/dir2/small6', contents='aaa') def test_get_too_large_file(self): """Test getting a too large file.""" - self.fs.CreateFile('/test/dir1/dir1/too_large', contents='aaaaaa') + self.fs.create_file('/test/dir1/dir1/too_large', contents='aaaaaa') self.assertEqual('/test/dir1/dir1/too_large', deploy.find_file_exceeding_limit('/test', 5)) diff --git a/src/python/tests/core/system/minijail_test.py b/src/python/tests/core/system/minijail_test.py index 147a69f40d..fc889054fa 100644 --- a/src/python/tests/core/system/minijail_test.py +++ b/src/python/tests/core/system/minijail_test.py @@ -32,8 +32,8 @@ def setUp(self): self.setUpPyfakefs() for subdir in ['dev', 'lib', 'lib32', 'lib64', 'proc']: - self.fs.CreateDirectory(os.path.join('/', subdir)) - self.fs.CreateDirectory(os.path.join('/', 'usr', 'lib')) + self.fs.create_dir(os.path.join('/', subdir)) + self.fs.create_dir(os.path.join('/', 'usr', 'lib')) test_helpers.patch(self, [ 'system.minijail._get_minijail_path', diff --git a/src/python/tests/core/system/shell_test.py b/src/python/tests/core/system/shell_test.py index 7553ddf03b..bbf9c4baac 100644 --- a/src/python/tests/core/system/shell_test.py +++ b/src/python/tests/core/system/shell_test.py @@ -37,10 +37,10 @@ def setUp(self): def test_remove(self): """Test remove.""" - self.fs.CreateFile('/test/aa/bb.txt', contents='s') - self.fs.CreateFile('/test/aa/cc.txt', contents='') - self.fs.CreateFile('/test/aa/aa/dd.txt', contents='s') - self.fs.CreateFile('/test/aa/aa/aa.txt', contents='') + self.fs.create_file('/test/aa/bb.txt', contents='s') + self.fs.create_file('/test/aa/cc.txt', contents='') + self.fs.create_file('/test/aa/aa/dd.txt', contents='s') + self.fs.create_file('/test/aa/aa/aa.txt', contents='') shell.remove_empty_files('/test') @@ -50,7 +50,7 @@ def test_remove(self): self.assertFalse(os.path.exists('/test/aa/aa/aa.txt')) def test_ignore_file(self): - self.fs.CreateFile('/test/aa/cc.txt', contents='') + self.fs.create_file('/test/aa/cc.txt', contents='') shell.remove_empty_files('/test/aa/cc.txt') self.assertTrue(os.path.exists('/test/aa/cc.txt')) @@ -60,7 +60,7 @@ def test_exception(self, mock_remove): os.remove = mock_remove mock_remove.side_effect = OSError() - self.fs.CreateFile('/test/aa/cc.txt', contents='') + self.fs.create_file('/test/aa/cc.txt', contents='') shell.remove_empty_files('/test') self.assertTrue(os.path.exists('/test/aa/cc.txt')) @@ -174,10 +174,10 @@ def setUp(self): def test(self): """Test get_directory_file_count.""" - self.fs.CreateFile('/test/aa/bb.txt', contents='abc') - self.fs.CreateFile('/test/aa/cc.txt', contents='def') - self.fs.CreateFile('/test/aa/aa/aa.txt', contents='ghi') - self.fs.CreateFile('/test/aa/aa/dd.txt', contents='t') + self.fs.create_file('/test/aa/bb.txt', contents='abc') + self.fs.create_file('/test/aa/cc.txt', contents='def') + self.fs.create_file('/test/aa/aa/aa.txt', contents='ghi') + self.fs.create_file('/test/aa/aa/dd.txt', contents='t') self.assertEqual(shell.get_directory_file_count('/test/aa'), 4) @@ -190,10 +190,10 @@ def setUp(self): def test(self): """Test get_directory_size.""" - self.fs.CreateFile('/test/aa/bb.txt', contents='abc') - self.fs.CreateFile('/test/aa/cc.txt', contents='def') - self.fs.CreateFile('/test/aa/aa/aa.txt', contents='ghi') - self.fs.CreateFile('/test/aa/aa/dd.txt', contents='t') + self.fs.create_file('/test/aa/bb.txt', contents='abc') + self.fs.create_file('/test/aa/cc.txt', contents='def') + self.fs.create_file('/test/aa/aa/aa.txt', contents='ghi') + self.fs.create_file('/test/aa/aa/dd.txt', contents='t') self.assertEqual(shell.get_directory_size('/test/aa'), 10) @@ -223,12 +223,12 @@ def setUp(self): def test(self): """Test clear_system_temp_directory works as expected.""" - self.fs.CreateFile('/tmp/aa/bb.txt', contents='abc') - self.fs.CreateFile('/tmp/cc/dd/ee.txt', contents='def') - self.fs.CreateDirectory('/tmp/ff/gg') - self.fs.CreateDirectory('/tmp/hh') - self.fs.CreateDirectory('/unrelated') - self.fs.CreateFile('/unrelated/zz.txt', contents='zzz') + self.fs.create_file('/tmp/aa/bb.txt', contents='abc') + self.fs.create_file('/tmp/cc/dd/ee.txt', contents='def') + self.fs.create_dir('/tmp/ff/gg') + self.fs.create_dir('/tmp/hh') + self.fs.create_dir('/unrelated') + self.fs.create_file('/unrelated/zz.txt', contents='zzz') os.symlink('/unrelated/zz.txt', '/tmp/hh/gg.txt') os.symlink('/unrelated', '/tmp/ii')