From: Adam Kupczyk Date: Wed, 12 Oct 2016 13:40:29 +0000 (+0200) Subject: Fixed problem with isal-regular gzip compatibility. X-Git-Tag: v11.1.0~429^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1fa1a2e06137ea7f19b14d158efd0f4533fb621c;p=ceph.git Fixed problem with isal-regular gzip compatibility. Added tests. Signed-off-by: Adam Kupczyk --- diff --git a/src/test/compressor/test_compression.cc b/src/test/compressor/test_compression.cc index 464427a2aa3..d7c24d5a827 100644 --- a/src/test/compressor/test_compression.cc +++ b/src/test/compressor/test_compression.cc @@ -387,6 +387,74 @@ TEST(CompressionPlugin, all) } } +TEST(ZlibCompressor, isal_compress_zlib_decompress_random) +{ + g_conf->set_val("compressor_zlib_isal", "true"); + g_ceph_context->_conf->apply_changes(NULL); + CompressorRef isal = Compressor::create(g_ceph_context, "zlib"); + g_conf->set_val("compressor_zlib_isal", "false"); + g_ceph_context->_conf->apply_changes(NULL); + CompressorRef zlib = Compressor::create(g_ceph_context, "zlib"); + + for (int cnt=0; cnt<1000; cnt++) + { + srand(cnt + 1000); + int log2 = (rand()%18) + 1; + int size = (rand() % (1 << log2)) + 1; + + char test[size]; + for (int i=0; icompress(in, out); + EXPECT_EQ(res, 0); + bufferlist after; + res = zlib->decompress(out, after); + EXPECT_EQ(res, 0); + bufferlist exp; + exp.append(test, size); + EXPECT_TRUE(exp.contents_equal(after)); + } +} + +TEST(ZlibCompressor, isal_compress_zlib_decompress_walk) +{ + g_conf->set_val("compressor_zlib_isal", "true"); + g_ceph_context->_conf->apply_changes(NULL); + CompressorRef isal = Compressor::create(g_ceph_context, "zlib"); + g_conf->set_val("compressor_zlib_isal", "false"); + g_ceph_context->_conf->apply_changes(NULL); + CompressorRef zlib = Compressor::create(g_ceph_context, "zlib"); + + for (int cnt=0; cnt<1000; cnt++) + { + srand(cnt + 1000); + int log2 = (rand()%18) + 1; + int size = (rand() % (1 << log2)) + 1; + + int range = 1; + + char test[size]; + test[0] = rand()%256; + for (int i=1; icompress(in, out); + EXPECT_EQ(res, 0); + bufferlist after; + res = zlib->decompress(out, after); + EXPECT_EQ(res, 0); + bufferlist exp; + exp.append(test, size); + EXPECT_TRUE(exp.contents_equal(after)); + } +} + + int main(int argc, char **argv) { vector args; argv_to_vec(argc, (const char **)argv, args);