| 415 | #if defined(__x86_64__) || defined(__aarch64__) || defined(HAVE_RISCV_RVV) |
| 416 | |
| 417 | TEST(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 | |
| 460 | TEST(CompressionPlugin, all) |
nothing calls this directly
no test coverage detected