From: Kevan Carstensen Date: Sat, 13 Aug 2011 18:39:36 +0000 (-0700) Subject: test/test_mutable: test for incorrect div_ceil equations X-Git-Tag: trac-5200 X-Git-Url: https://git.rkrishnan.org/vdrive/%22file:/COPYING.GPL?a=commitdiff_plain;h=b49986f80115289021ccffe31e9f11f6c34ff64c;p=tahoe-lafs%2Ftahoe-lafs.git test/test_mutable: test for incorrect div_ceil equations --- diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 1b7fc9fb..365ca977 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -7,7 +7,7 @@ from twisted.internet.interfaces import IConsumer from zope.interface import implements from allmydata import uri, client from allmydata.nodemaker import NodeMaker -from allmydata.util import base32, consumer, fileutil +from allmydata.util import base32, consumer, fileutil, mathutil from allmydata.util.hashutil import tagged_hash, ssk_writekey_hash, \ ssk_pubkey_fingerprint_hash from allmydata.util.deferredutil import gatherResults @@ -3222,6 +3222,28 @@ class Version(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin, \ d.addCallback(_read_data) return d + def test_partial_read_starting_on_segment_boundary(self): + d = self.mdmf_node.get_best_readable_version() + c = consumer.MemoryConsumer() + offset = mathutil.next_multiple(128 * 1024, 3) + d.addCallback(lambda version: + version.read(c, offset, 50)) + expected = self.data[offset:offset+50] + d.addCallback(lambda ignored: + self.failUnlessEqual(expected, "".join(c.chunks))) + return d + + def test_partial_read_ending_on_segment_boundary(self): + d = self.mdmf_node.get_best_readable_version() + c = consumer.MemoryConsumer() + offset = mathutil.next_multiple(128 * 1024, 3) + start = offset - 50 + d.addCallback(lambda version: + version.read(c, start, 51)) + expected = self.data[offset-50:offset+1] + d.addCallback(lambda ignored: + self.failUnlessEqual(expected, "".join(c.chunks))) + return d def test_read(self): d = self.mdmf_node.get_best_readable_version()