]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/bufferlist: do not expect !is_page_aligned() after unaligned rebuild 8272/head
authorKefu Chai <kchai@redhat.com>
Thu, 3 Sep 2015 17:23:31 +0000 (01:23 +0800)
committerYan Jun <yan.jun8@zte.com.cn>
Wed, 23 Mar 2016 06:24:02 +0000 (14:24 +0800)
if the size of a bufferlist is page aligned we allocate page aligned
memory chunk for it when rebuild() is called. otherwise we just call
the plain new() to allocate new memory chunk for holding the continuous
buffer. but we should not expect that `new` allocator always returns
unaligned memory chunks. instead, it *could* return page aligned
memory chunk as long as the allocator feels appropriate. so, the
`EXPECT_FALSE(bl.is_page_aligned())` after the `rebuild()` call is
removed.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 8ed724222651812c2ee8cc3804dc1f54c973897d)

src/test/bufferlist.cc

index 3c8d0473bae23fd1b10aa51f7f442e39a17f3008..6ea987b0c3d43bdb7a53ddf6cc3a01a82e7dee42 100644 (file)
@@ -1403,12 +1403,15 @@ TEST(BufferList, rebuild) {
   {
     bufferlist bl;
     bufferptr ptr(buffer::create_page_aligned(2));
+    ptr[0] = 'X';
+    ptr[1] = 'Y';
     ptr.set_offset(1);
     ptr.set_length(1);
     bl.append(ptr);
     EXPECT_FALSE(bl.is_page_aligned());
     bl.rebuild();
-    EXPECT_FALSE(bl.is_page_aligned());
+    EXPECT_EQ(1U, bl.length());
+    EXPECT_EQ('Y', *bl.begin());
   }
   {
     bufferlist bl;