From: Loic Dachary Date: Tue, 17 Dec 2013 19:26:01 +0000 (+0100) Subject: erasure-code: tests must use aligned buffers X-Git-Tag: v0.75~80^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b1530679a85c82a8ea79d23c3b0d0c11bd4da3c2;p=ceph.git erasure-code: tests must use aligned buffers 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 --- diff --git a/src/test/osd/TestErasureCodeJerasure.cc b/src/test/osd/TestErasureCodeJerasure.cc index a51cb853c8676..78f4ce1759c78 100644 --- a/src/test/osd/TestErasureCodeJerasure.cc +++ b/src/test/osd/TestErasureCodeJerasure.cc @@ -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 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(want_to_encode, want_to_encode+4), in,