|
27 | 27 | ''' |
28 | 28 |
|
29 | 29 | import contextlib |
30 | | -import os |
31 | 30 | import difflib |
32 | 31 | import json |
33 | 32 | import math |
34 | | -import shutil |
35 | | -import subprocess |
| 33 | +import os |
36 | 34 | import random |
37 | 35 | import re |
| 36 | +import shutil |
| 37 | +import subprocess |
38 | 38 | import sys |
39 | 39 | import tarfile |
40 | 40 | import time |
41 | 41 | import traceback |
42 | 42 | from os.path import abspath |
43 | 43 |
|
44 | | -from test import fuzzing |
45 | | -from test import shared |
46 | | -from test import support |
47 | | - |
| 44 | +from test import fuzzing, shared, support |
48 | 45 |
|
49 | 46 | assert sys.version_info >= (3, 10), 'requires Python 3.10' |
50 | 47 |
|
@@ -457,7 +454,7 @@ def compare(x, y, context, verbose=True): |
457 | 454 | if verbose: |
458 | 455 | raise Exception(context + " comparison error, expected to have '%s' == '%s', diff:\n\n%s" % ( |
459 | 456 | x, y, |
460 | | - message |
| 457 | + message, |
461 | 458 | )) |
462 | 459 | else: |
463 | 460 | raise Exception(context + "\nDiff:\n\n%s" % (message)) |
@@ -1007,7 +1004,7 @@ def run_vms(self, wasm): |
1007 | 1004 |
|
1008 | 1005 | # compare between the vms on this specific input |
1009 | 1006 | num_vms = len(relevant_vms) |
1010 | | - for i in range(0, num_vms): |
| 1007 | + for i in range(num_vms): |
1011 | 1008 | for j in range(i + 1, num_vms): |
1012 | 1009 | vm1 = relevant_vms[i] |
1013 | 1010 | vm2 = relevant_vms[j] |
@@ -1036,8 +1033,8 @@ def handle_pair(self, input, before_wasm, after_wasm, opts): |
1036 | 1033 | if (b1 != b2): |
1037 | 1034 | run([in_bin('wasm-dis'), abspath('b1.wasm'), '-o', abspath('b1.wat')] + FEATURE_OPTS) |
1038 | 1035 | run([in_bin('wasm-dis'), abspath('b2.wasm'), '-o', abspath('b2.wat')] + FEATURE_OPTS) |
1039 | | - t1 = open(abspath('b1.wat'), 'r').read() |
1040 | | - t2 = open(abspath('b2.wat'), 'r').read() |
| 1036 | + t1 = open(abspath('b1.wat')).read() |
| 1037 | + t2 = open(abspath('b2.wat')).read() |
1041 | 1038 | compare(t1, t2, 'Output must be deterministic.', verbose=False) |
1042 | 1039 |
|
1043 | 1040 |
|
@@ -1243,12 +1240,12 @@ def filter_exports(wasm, output, keep, keep_defaults=True): |
1243 | 1240 | graph = [{ |
1244 | 1241 | 'name': 'outside', |
1245 | 1242 | 'reaches': [f'export-{export}' for export in keep], |
1246 | | - 'root': True |
| 1243 | + 'root': True, |
1247 | 1244 | }] |
1248 | 1245 | for export in keep: |
1249 | 1246 | graph.append({ |
1250 | 1247 | 'name': f'export-{export}', |
1251 | | - 'export': export |
| 1248 | + 'export': export, |
1252 | 1249 | }) |
1253 | 1250 |
|
1254 | 1251 | with open('graph.json', 'w') as f: |
@@ -1741,7 +1738,7 @@ def handle_pair(self, input, before_wasm, after_wasm, opts): |
1741 | 1738 | cmd = [shared.V8] |
1742 | 1739 | # The flags are given in the flags file - we do *not* use our normal |
1743 | 1740 | # flags here! |
1744 | | - with open(flags_file, 'r') as f: |
| 1741 | + with open(flags_file) as f: |
1745 | 1742 | flags = f.read() |
1746 | 1743 | cmd += flags.split(' ') |
1747 | 1744 | # Get V8's extra fuzzing flags, the same as the ClusterFuzz runner does |
|
0 commit comments