Skip to content

Commit b86b357

Browse files
committed
fix windows test
1 parent 7567bdd commit b86b357

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

test/unit/test_fuzz_preserve.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ def test(self):
4646
if i > self.min_iters and time.time() > stop_time:
4747
raise Exception('looked too long and still failed')
4848

49-
# Generate raw random data
49+
# Generate raw random data. Note we do not open() the file multiple
50+
# times as that fails on windows; instead, seek to the start and
51+
# write from there, then later resize and flush. (We do all this to
52+
# avoid the slowdown of securely creating many tiny temp files, as
53+
# this loop may go on for a long time.)
54+
temp_dat.seek(0)
5055
size = random.randint(1, self.max_size)
51-
with open(temp_dat.name, 'wb') as f:
52-
f.write(bytes([random.randint(0, 255) for x in range(size)]))
56+
temp_dat.write(bytes([random.randint(0, 255) for x in range(size)]))
57+
temp_dat.truncate()
58+
temp_dat.flush()
5359

5460
# Generate the fuzz testcase from the random data + the initial
5561
# contents.

0 commit comments

Comments
 (0)