summaryrefslogtreecommitdiffstats
path: root/src/test/compressor
diff options
context:
space:
mode:
authorAdam Kupczyk <akupczyk@mirantis.com>2016-10-12 15:40:29 +0200
committerAdam Kupczyk <akupczyk@mirantis.com>2016-11-02 12:14:10 +0100
commit1fa1a2e06137ea7f19b14d158efd0f4533fb621c (patch)
tree723637aa964a41e7741854021a47c6429c23ee7f /src/test/compressor
parentFixed missing param to processor->complete(). (diff)
downloadceph-1fa1a2e06137ea7f19b14d158efd0f4533fb621c.tar.xz
ceph-1fa1a2e06137ea7f19b14d158efd0f4533fb621c.zip
Fixed problem with isal-regular gzip compatibility.
Added tests. Signed-off-by: Adam Kupczyk <akupczyk@mirantis.com>
Diffstat (limited to 'src/test/compressor')
-rw-r--r--src/test/compressor/test_compression.cc68
1 files changed, 68 insertions, 0 deletions
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; i<size; ++i)
+ test[i] = rand()%256;
+ bufferlist in, out;
+ in.append(test, size);
+
+ int res = isal->compress(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; i<size; ++i)
+ test[i] = test[i-1] + rand()%(range*2+1) - range;
+ bufferlist in, out;
+ in.append(test, size);
+
+ int res = isal->compress(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<const char*> args;
argv_to_vec(argc, (const char **)argv, args);