]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: tests must use aligned buffers 961/head
authorLoic Dachary <loic@dachary.org>
Tue, 17 Dec 2013 19:26:01 +0000 (20:26 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 17 Dec 2013 19:26:01 +0000 (20:26 +0100)
The underlying code assumes the memory buffer is aligned on a long
boundary which is not always the case. Using buffer::create_page_aligned
which calls posix_memalign ensure the allocated buffer starts at an
address that is properly aligned.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/osd/TestErasureCodeJerasure.cc

index a51cb853c8676f0c623900c5bd379e102d310271..78f4ce1759c7865d7a85a74739aa9bf3e76d679c 100644 (file)
@@ -48,7 +48,7 @@ TYPED_TEST(ErasureCodeTest, encode_decode)
   jerasure.init(parameters);
 
 #define LARGE_ENOUGH 2048
-  bufferptr in_ptr(LARGE_ENOUGH);
+  bufferptr in_ptr(buffer::create_page_aligned(LARGE_ENOUGH));
   in_ptr.zero();
   in_ptr.set_length(0);
   const char *payload =
@@ -223,7 +223,11 @@ TEST(ErasureCodeTest, encode)
     bufferlist in;
     map<int,bufferlist> encoded;
     int want_to_encode[] = { 0, 1, 2, 3 };
-    in.append(string(alignment * 2, 'X'));
+    bufferptr in_ptr(buffer::create_page_aligned(alignment * 2));
+    in_ptr.zero();
+    in_ptr.set_length(0);
+    in_ptr.append(string(alignment * 2, 'X').c_str(), alignment * 2);
+    in.append(in_ptr);
     EXPECT_EQ(alignment * 2, in.length());
     EXPECT_EQ(0, jerasure.encode(set<int>(want_to_encode, want_to_encode+4),
                                 in,