From 9b77276e38ea2663a37edec04efa50a714328d20 Mon Sep 17 00:00:00 2001 From: Dylan Jew Date: Wed, 12 Aug 2026 16:02:39 -0400 Subject: [PATCH] [WIP] temporarily create config to correct folder this breaks the tests --- .../scripts/download_fuzzer_config_test.py | 27 +++++++++++++------ .../butler/scripts/download_fuzzer_config.py | 6 ++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/clusterfuzz/_internal/tests/core/local/butler/scripts/download_fuzzer_config_test.py b/src/clusterfuzz/_internal/tests/core/local/butler/scripts/download_fuzzer_config_test.py index d1529ff1af9..6f0c0b5e9ce 100644 --- a/src/clusterfuzz/_internal/tests/core/local/butler/scripts/download_fuzzer_config_test.py +++ b/src/clusterfuzz/_internal/tests/core/local/butler/scripts/download_fuzzer_config_test.py @@ -15,6 +15,7 @@ import json import os +import shutil import unittest from clusterfuzz._internal.datastore import data_types @@ -69,23 +70,28 @@ def setUp(self): self.fuzzer2.put() def tearDown(self): - if os.path.exists('fuzzer1_config.json'): - os.remove('fuzzer1_config.json') - if os.path.exists('fuzzer2_config.json'): - os.remove('fuzzer2_config.json') + for fuzzer_name in ['fuzzer1', 'fuzzer2', 'fuzzer_missing']: + config_dir = os.path.join('..', 'clusterfuzz-data', 'fuzzers', + fuzzer_name) + if os.path.exists(config_dir): + shutil.rmtree(config_dir) def test_execute_success(self): """Test successful download.""" args = Args(['fuzzer1', 'fuzzer2']) download_fuzzer_config.execute(args) - with open('fuzzer1_config.json') as f: + path1 = os.path.join('..', 'clusterfuzz-data', 'fuzzers', 'fuzzer1', + 'clusterfuzz_config', 'fuzzer1_config.json') + with open(path1) as f: config1 = json.load(f) self.assertEqual(['job1'], config1['jobs']) self.assertEqual('data_bundle1', config1['data_bundle_name']) self.assertEqual(10, config1['timeout']) - with open('fuzzer2_config.json') as f: + path2 = os.path.join('..', 'clusterfuzz-data', 'fuzzers', 'fuzzer2', + 'clusterfuzz_config', 'fuzzer2_config.json') + with open(path2) as f: config2 = json.load(f) self.assertEqual([], config2['jobs']) self.assertEqual('data_bundle2', config2['data_bundle_name']) @@ -96,5 +102,10 @@ def test_execute_not_found(self): args = Args(['fuzzer1', 'fuzzer_missing']) download_fuzzer_config.execute(args) - self.assertTrue(os.path.exists('fuzzer1_config.json')) - self.assertFalse(os.path.exists('fuzzer_missing_config.json')) + path1 = os.path.join('..', 'clusterfuzz-data', 'fuzzers', 'fuzzer1', + 'clusterfuzz_config', 'fuzzer1_config.json') + missing_path = os.path.join('..', 'clusterfuzz-data', 'fuzzers', + 'fuzzer_missing', 'clusterfuzz_config', + 'fuzzer_missing_config.json') + self.assertTrue(os.path.exists(path1)) + self.assertFalse(os.path.exists(missing_path)) diff --git a/src/local/butler/scripts/download_fuzzer_config.py b/src/local/butler/scripts/download_fuzzer_config.py index 12d8c998c34..8f4fdd324fe 100644 --- a/src/local/butler/scripts/download_fuzzer_config.py +++ b/src/local/butler/scripts/download_fuzzer_config.py @@ -14,6 +14,7 @@ """Download fuzzer config as a JSON file.""" import json +import os import sys from clusterfuzz._internal.datastore import data_types @@ -40,7 +41,10 @@ def execute(args): for fuzzer in fuzzers: config = fuzzer.get_config_dict() - filename = f'{fuzzer.name}_config.json' + output_dir = os.path.join('..', 'clusterfuzz-data', 'fuzzers', fuzzer.name, + 'clusterfuzz_config') + os.makedirs(output_dir, exist_ok=True) + filename = os.path.join(output_dir, f'{fuzzer.name}_config.json') with open(filename, 'w') as f: json.dump(config, f, indent=4)