]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test/test_mutable: test for incorrect div_ceil equations trac-5200
authorKevan Carstensen <kevan@isnotajoke.com>
Sat, 13 Aug 2011 18:39:36 +0000 (11:39 -0700)
committerKevan Carstensen <kevan@isnotajoke.com>
Sat, 13 Aug 2011 18:39:36 +0000 (11:39 -0700)
src/allmydata/test/test_mutable.py

index 1b7fc9fb2f3caa0ebcba998996c8882c1bfa7f02..365ca97776a228d91fc0a44d0ad3f882c5c441fa 100644 (file)
@@ -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()