blob: 008ef05cdfa9b74cdf37803d2b9d0f5c1f92c9c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# -*- coding: utf-8 -*-
import sys
import random
random.seed("Yeah babe")
text = open(sys.argv[1]).read()
fin = open(sys.argv[1])
for _ in xrange(1000):
offset = random.randint(0, len(text))
size = random.randint(0, min(len(text) - offset - 1, 10 * 1024))
fin.seek(offset)
chunk = fin.read(size)
assert len(chunk) <= size
assert len(chunk) != 0
if text[offset:offset + len(chunk)] != chunk:
s = "Read fails for file {} with offset {} and size {}"
raise IOError(s.format(sys.argv[1], offset, size))
print "Success!"
|