diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/fuzz_opt.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index 72a6666fd..e4299639f 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -275,12 +275,28 @@ def compare(x, y, context): )) +# converts a possibly-signed integer to an unsigned integer +def unsign(x, bits): + return x & ((1 << bits) - 1) + + # numbers are "close enough" if they just differ in printing, as different # vms may print at different precision levels and verbosity def numbers_are_close_enough(x, y): # handle nan comparisons like -nan:0x7ffff0 vs NaN, ignoring the bits if 'nan' in x.lower() and 'nan' in y.lower(): return True + # if one input is a pair, then it is in fact a 64-bit integer that is + # reported as two 32-bit chunks. convert such 'low high' pairs into a 64-bit + # integer for comparison to the other value + if ' ' in x or ' ' in y: + def to_64_bit(a): + if ' ' not in a: + return unsign(int(a), bits=64) + low, high = a.split(' ') + return unsign(int(low), 32) + (1 << 32) * unsign(int(high), 32) + + return to_64_bit(x) == to_64_bit(y) # float() on the strings will handle many minor differences, like # float('1.0') == float('1') , float('inf') == float('Infinity'), etc. try: |