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

Function TEST

src/test/erasure-code/TestErasureCode.cc:112–138  ·  view source on GitHub ↗

* If we have a buffer of 5 bytes (X below) and a chunk size of 3 * bytes, for k=3, m=1 an additional 7 bytes (P and C below) will * need to be allocated for padding (P) and the 3 coding bytes (C). * * X -+ +----------+ +-X * X | | data 0 | | X * X | +----------+ | X * X | +----------+ | X -> +-X * X -+ | data 1 | +-X -> | X * P -+ +----------+ | P * P | +--------

Source from the content-addressed store, hash-verified

110 * underlying allocation function enforces it.
111 */
112TEST(ErasureCodeTest, encode_memory_align)
113{
114 int k = 3;
115 int m = 1;
116 unsigned chunk_size = ErasureCode::SIMD_ALIGN * 7;
117 ErasureCodeTest erasure_code(k, m, chunk_size);
118
119 shard_id_set want_to_encode;
120 want_to_encode.insert_range(shard_id_t(0), erasure_code.get_chunk_count());
121 string data(chunk_size + chunk_size / 2, 'X'); // uses 1.5 chunks out of 3
122 // make sure nothing is memory aligned
123 bufferptr ptr(buffer::create_aligned(data.length() + 1, ErasureCode::SIMD_ALIGN));
124 ptr.copy_in(1, data.length(), data.c_str());
125 ptr.set_offset(1);
126 ptr.set_length(data.length());
127 bufferlist in;
128 in.append(ptr);
129 shard_id_map<bufferlist> encoded(k+m);
130
131 ASSERT_FALSE(in.is_aligned(ErasureCode::SIMD_ALIGN));
132 ASSERT_EQ(0, erasure_code.encode(want_to_encode, in, &encoded));
133 for (shard_id_t i; i < erasure_code.get_chunk_count(); ++i)
134 ASSERT_TRUE(encoded[i].is_aligned(ErasureCode::SIMD_ALIGN));
135 for (unsigned i = 0; i < chunk_size / 2; i++)
136 ASSERT_EQ(encoded[shard_id_t(1)][i], 'X');
137 ASSERT_NE(encoded[shard_id_t(1)][chunk_size / 2], 'X');
138}
139
140TEST(ErasureCodeTest, encode_misaligned_non_contiguous)
141{

Callers

nothing calls this directly

Calls 15

insert_rangeMethod · 0.80
set_lengthMethod · 0.80
is_contiguousMethod · 0.80
is_n_align_sizedMethod · 0.80
shard_id_tClass · 0.50
get_chunk_countMethod · 0.45
lengthMethod · 0.45
copy_inMethod · 0.45
c_strMethod · 0.45
appendMethod · 0.45
is_alignedMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected