]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
erasure-code: isa encode tests adapted to per chunk alignment
authorLoic Dachary <loic-201408@dachary.org>
Mon, 22 Sep 2014 12:11:07 +0000 (14:11 +0200)
committerLoic Dachary <loic-201408@dachary.org>
Thu, 25 Sep 2014 15:39:16 +0000 (17:39 +0200)
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 <loic-201408@dachary.org>
src/test/erasure-code/TestErasureCodeIsa.cc

index 43526d0e64c9f673cdfb4da26169374c148b1964..e29256551a57ece522705866573b120200052a72 100644 (file)
@@ -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<int, bufferlist> 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<int>(want_to_encode, want_to_encode + 4),
-                            in,
-                            &encoded));
+    map<int,bufferlist> 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<int>(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<int, bufferlist> encoded;
+    map<int,bufferlist> encoded;
     set<int> 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());
   }
 }