diff options
author | Matias Linares <matiaslina@opmbx.org> | 2015-04-26 21:43:42 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@opmbx.org> | 2015-04-26 21:43:42 -0300 |
commit | 2dd5cf430edaae01594d566c9f27d780c3ffb4ef (patch) | |
tree | 13111bc82a73e951d5d7c07865a206c025d15529 /tests/read_diferentes_offsets.py | |
download | medianinfs-2dd5cf430edaae01594d566c9f27d780c3ffb4ef.tar.gz |
Initial commit
Diffstat (limited to 'tests/read_diferentes_offsets.py')
-rw-r--r-- | tests/read_diferentes_offsets.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/read_diferentes_offsets.py b/tests/read_diferentes_offsets.py new file mode 100644 index 0000000..008ef05 --- /dev/null +++ b/tests/read_diferentes_offsets.py @@ -0,0 +1,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!" |