MCPcopy Create free account
hub / github.com/ceph/ceph / TEST

Function TEST

src/test/erasure-code/TestErasureCodeJerasure.cc:232–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232TEST(ErasureCodeTest, encode)
233{
234 ErasureCodeJerasureReedSolomonVandermonde jerasure;
235 ErasureCodeProfile profile;
236 profile["k"] = "2";
237 profile["m"] = "2";
238 profile["w"] = "8";
239 jerasure.init(profile, &cerr);
240
241 unsigned aligned_object_size = jerasure.get_alignment() * 2;
242 {
243 //
244 // When the input bufferlist needs to be padded because
245 // it is not properly aligned, it is padded with zeros.
246 //
247 bufferlist in;
248 shard_id_map<bufferlist> encoded(jerasure.get_chunk_count());
249 int want_to_encode[] = { 0, 1, 2, 3 };
250 int trail_length = 1;
251 in.append(string(aligned_object_size + trail_length, 'X'));
252 EXPECT_EQ(0, jerasure.encode(shard_id_set(want_to_encode, want_to_encode+4),
253 in,
254 &encoded));
255 EXPECT_EQ(4u, encoded.size());
256 char *last_chunk = encoded[shard_id_t(1)].c_str();
257 int length =encoded[shard_id_t(1)].length();
258 EXPECT_EQ('X', last_chunk[0]);
259 EXPECT_EQ('\0', last_chunk[length - trail_length]);
260 }
261
262 {
263 //
264 // When only the first chunk is required, the encoded map only
265 // contains the first chunk. Although the jerasure encode
266 // internally allocated a buffer because of padding requirements
267 // and also computes the coding chunks, they are released before
268 // the return of the method, as shown when running the tests thru
269 // valgrind (there is no leak).
270 //
271 bufferlist in;
272 shard_id_map<bufferlist> encoded(jerasure.get_chunk_count());
273 shard_id_set want_to_encode;
274 want_to_encode.insert(shard_id_t(0));
275 int trail_length = 1;
276 in.append(string(aligned_object_size + trail_length, 'X'));
277 EXPECT_EQ(0, jerasure.encode(want_to_encode, in, &encoded));
278 EXPECT_EQ(1u, encoded.size());
279 }
280}
281
282TEST(ErasureCodeTest, create_rule)
283{

Callers

nothing calls this directly

Calls 15

stringifyFunction · 0.85
set_type_nameMethod · 0.80
add_bucketMethod · 0.80
set_item_nameMethod · 0.80
insert_itemMethod · 0.80
get_max_devicesMethod · 0.80
do_ruleMethod · 0.80
shard_id_tClass · 0.50
initMethod · 0.45
get_alignmentMethod · 0.45
get_chunk_countMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected