From: Loic Dachary Date: Wed, 8 Jan 2014 19:14:52 +0000 (+0100) Subject: erasure-code: relax zero copy requirements in tests X-Git-Tag: v0.77~34^2~2^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1057%2Fhead;p=ceph.git erasure-code: relax zero copy requirements in tests The input buffer is copied when padding is required. Remove the tests that ensured the input buffer was not copied entirely when padding was added. Signed-off-by: Loic Dachary --- diff --git a/src/test/osd/TestErasureCodeJerasure.cc b/src/test/osd/TestErasureCodeJerasure.cc index 78f4ce1759c..0e2aaa15167 100644 --- a/src/test/osd/TestErasureCodeJerasure.cc +++ b/src/test/osd/TestErasureCodeJerasure.cc @@ -215,37 +215,10 @@ TEST(ErasureCodeTest, encode) jerasure.init(parameters); unsigned alignment = jerasure.get_alignment(); - { - // - // When the input bufferlist is perfectly aligned, it is - // pointed to unmodified by the returned encoded chunks. - // - bufferlist in; - map encoded; - int want_to_encode[] = { 0, 1, 2, 3 }; - 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, - &encoded)); - EXPECT_EQ(4u, encoded.size()); - for(int i = 0; i < 4; i++) - EXPECT_EQ(alignment, encoded[i].length()); - EXPECT_EQ(in.c_str(), encoded[0].c_str()); - EXPECT_EQ(in.c_str() + alignment, encoded[1].c_str()); - } - { // // When the input bufferlist needs to be padded because // it is not properly aligned, it is padded with zeros. - // The beginning of the input bufferlist is pointed to - // unmodified by the returned encoded chunk, only the - // trailing chunk is allocated and copied. // bufferlist in; map encoded; @@ -258,8 +231,6 @@ TEST(ErasureCodeTest, encode) EXPECT_EQ(4u, encoded.size()); for(int i = 0; i < 4; i++) EXPECT_EQ(alignment, encoded[i].length()); - EXPECT_EQ(in.c_str(), encoded[0].c_str()); - EXPECT_NE(in.c_str() + alignment, encoded[1].c_str()); char *last_chunk = encoded[1].c_str(); EXPECT_EQ('X', last_chunk[0]); EXPECT_EQ('\0', last_chunk[trail_length]); @@ -272,7 +243,7 @@ TEST(ErasureCodeTest, encode) // internally allocated a buffer because of padding requirements // and also computes the coding chunks, they are released before // the return of the method, as shown when running the tests thru - // valgrind that shows there is no leak. + // valgrind (there is no leak). // bufferlist in; map encoded; @@ -283,7 +254,6 @@ TEST(ErasureCodeTest, encode) EXPECT_EQ(0, jerasure.encode(want_to_encode, in, &encoded)); EXPECT_EQ(1u, encoded.size()); EXPECT_EQ(alignment, encoded[0].length()); - EXPECT_EQ(in.c_str(), encoded[0].c_str()); } }