From: Loic Dachary Date: Mon, 22 Sep 2014 12:11:07 +0000 (+0200) Subject: erasure-code: isa encode tests adapted to per chunk alignment X-Git-Tag: v0.86~29^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=af07d29e27baa5572eb447963328367d2cce30b8;p=ceph.git erasure-code: isa encode tests adapted to per chunk alignment The encode tests use the alignment constraints. It has been changed to be aligned on a per chunk basis instead of computing a more expensive object alignement constraint. The test function is modified to take the change into account but the logic is otherwise unmodified. Signed-off-by: Loic Dachary --- diff --git a/src/test/erasure-code/TestErasureCodeIsa.cc b/src/test/erasure-code/TestErasureCodeIsa.cc index 43526d0e64c9..e29256551a57 100644 --- a/src/test/erasure-code/TestErasureCodeIsa.cc +++ b/src/test/erasure-code/TestErasureCodeIsa.cc @@ -288,46 +288,44 @@ TEST_F(IsaErasureCodeTest, encode) parameters["m"] = "2"; Isa.init(parameters); - unsigned alignment = Isa.get_alignment(); + unsigned aligned_object_size = Isa.get_alignment() * 2; { // // When the input bufferlist needs to be padded because // it is not properly aligned, it is padded with zeros. // bufferlist in; - map encoded; - int want_to_encode[] = {0, 1, 2, 3}; - int trail_length = 2; - in.append(string(alignment + trail_length, 'X')); - EXPECT_EQ(0, Isa.encode(set(want_to_encode, want_to_encode + 4), - in, - &encoded)); + map encoded; + int want_to_encode[] = { 0, 1, 2, 3 }; + int trail_length = 1; + in.append(string(aligned_object_size + trail_length, 'X')); + EXPECT_EQ(0, Isa.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()); char *last_chunk = encoded[1].c_str(); + int length =encoded[1].length(); EXPECT_EQ('X', last_chunk[0]); - EXPECT_EQ('\0', last_chunk[trail_length]); + EXPECT_EQ('\0', last_chunk[length - trail_length]); } { // // When only the first chunk is required, the encoded map only - // contains the first chunk. Although the encode + // contains the first chunk. Although the Isa 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 (there is no leak). // bufferlist in; - map encoded; + map encoded; set want_to_encode; want_to_encode.insert(0); - int trail_length = 2; - in.append(string(alignment + trail_length, 'X')); + int trail_length = 1; + in.append(string(aligned_object_size + trail_length, 'X')); EXPECT_EQ(0, Isa.encode(want_to_encode, in, &encoded)); EXPECT_EQ(1u, encoded.size()); - EXPECT_EQ(alignment, encoded[0].length()); } }