|
23 | 23 | import os |
24 | 24 | import re |
25 | 25 | import subprocess |
| 26 | +import tarfile |
26 | 27 | import time |
27 | 28 |
|
28 | 29 | from clusterfuzz._internal.base import utils |
@@ -208,6 +209,39 @@ def create_gecko_tests_directory(tests_directory, gecko_checkout_subdirectory, |
208 | 209 | target_subdirectory) |
209 | 210 |
|
210 | 211 |
|
| 212 | +def create_fuzzilli_tests_directory(tests_directory): |
| 213 | + """Create Fuzzilli tests directory from the autozilli GCS archives.""" |
| 214 | + logs.info('Syncing fuzzilli tests.') |
| 215 | + fuzzilli_tests_directory = os.path.join(tests_directory, 'fuzzilli') |
| 216 | + remote_archive_tmpl = 'gs://autozilli/autozilli-%d.tgz' |
| 217 | + |
| 218 | + # Ensure we have an empty directory with no leftovers from a previous run. |
| 219 | + shell.remove_directory(fuzzilli_tests_directory, recreate=True) |
| 220 | + |
| 221 | + def filter_members(member, path): |
| 222 | + # We only need JS files and the settings.json from the archive. |
| 223 | + if member.name.endswith('fzil') or member.name.startswith('fuzzdir/stats'): |
| 224 | + return None |
| 225 | + return tarfile.data_filter(member, path) |
| 226 | + |
| 227 | + for i in range(1, 10): |
| 228 | + # Download archives number 1-9. |
| 229 | + remote_archive = remote_archive_tmpl % i |
| 230 | + logs.info(f'Processing {remote_archive}') |
| 231 | + local_archive = os.path.join(fuzzilli_tests_directory, 'tmp.tgz') |
| 232 | + subprocess.check_call(['gsutil', 'cp', remote_archive, local_archive]) |
| 233 | + |
| 234 | + # Extract relevant files. |
| 235 | + with tarfile.open(local_archive) as tar: |
| 236 | + tar.extractall(path=fuzzilli_tests_directory, filter=filter_members) |
| 237 | + |
| 238 | + # Clean up. |
| 239 | + os.rename( |
| 240 | + os.path.join(fuzzilli_tests_directory, 'fuzzdir'), |
| 241 | + os.path.join(fuzzilli_tests_directory, f'fuzzdir-{i}')) |
| 242 | + shell.remove_file(local_archive) |
| 243 | + |
| 244 | + |
211 | 245 | def sync_tests(tests_archive_bucket: str, tests_archive_name: str, |
212 | 246 | tests_directory: str): |
213 | 247 | """Main sync routine.""" |
@@ -264,6 +298,7 @@ def sync_tests(tests_archive_bucket: str, tests_archive_name: str, |
264 | 298 | 'WebKit/JSTests/es6', |
265 | 299 | 'WebKit/JSTests/stress', |
266 | 300 | 'WebKit/LayoutTests', |
| 301 | + 'fuzzilli', |
267 | 302 | 'gecko-tests', |
268 | 303 | 'v8/test/mjsunit', |
269 | 304 | 'spidermonkey', |
|
0 commit comments