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

Function TEST

src/test/compressor/test_compression.cc:417–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415#if defined(__x86_64__) || defined(__aarch64__) || defined(HAVE_RISCV_RVV)
416
417TEST(ZlibCompressor, zlib_isal_compatibility)
418{
419 g_conf().set_val("compressor_zlib_isal", "true");
420 g_ceph_context->_conf.apply_changes(nullptr);
421 CompressorRef isal = Compressor::create(g_ceph_context, "zlib");
422 if (!isal) {
423 // skip the test if the plugin is not ready
424 return;
425 }
426 g_conf().set_val("compressor_zlib_isal", "false");
427 g_ceph_context->_conf.apply_changes(nullptr);
428 CompressorRef zlib = Compressor::create(g_ceph_context, "zlib");
429 char test[101];
430 srand(time(0));
431 for (int i=0; i<100; ++i)
432 test[i] = 'a' + rand()%26;
433 test[100] = '\0';
434 int len = strlen(test);
435 bufferlist in, out;
436 in.append(test, len);
437 // isal -> zlib
438 std::optional<int32_t> compressor_message;
439 int res = isal->compress(in, out, compressor_message);
440 EXPECT_EQ(res, 0);
441 bufferlist after;
442 res = zlib->decompress(out, after, compressor_message);
443 EXPECT_EQ(res, 0);
444 bufferlist exp;
445 exp.append(static_cast<char*>(test));
446 EXPECT_TRUE(exp.contents_equal(after));
447 after.clear();
448 out.clear();
449 exp.clear();
450 // zlib -> isal
451 res = zlib->compress(in, out, compressor_message);
452 EXPECT_EQ(res, 0);
453 res = isal->decompress(out, after, compressor_message);
454 EXPECT_EQ(res, 0);
455 exp.append(static_cast<char*>(test));
456 EXPECT_TRUE(exp.contents_equal(after));
457}
458#endif
459
460TEST(CompressionPlugin, all)

Callers

nothing calls this directly

Calls 14

apply_changesMethod · 0.80
contents_equalMethod · 0.80
get_plugin_registryMethod · 0.80
get_with_loadMethod · 0.80
createFunction · 0.50
set_valMethod · 0.45
appendMethod · 0.45
compressMethod · 0.45
decompressMethod · 0.45
clearMethod · 0.45
factoryMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected