summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorIgor Fedotov <ifedotov@mirantis.com>2016-05-24 19:05:14 +0200
committerSage Weil <sage@redhat.com>2016-06-01 17:40:48 +0200
commit183db05a35cc3bd84b45f12a05780f5157659895 (patch)
treec2a7d3975e2f7e01c34bf32ae58913ac07bcb8fa /src/test
parentos/bluestore: compress on write (diff)
downloadceph-183db05a35cc3bd84b45f12a05780f5157659895.tar.xz
ceph-183db05a35cc3bd84b45f12a05780f5157659895.zip
compressor: Extends decompressor interface to be able to provide compressed data length.
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compressor/compressor_example.h4
-rw-r--r--src/test/compressor/test_compression_snappy.cc7
-rw-r--r--src/test/compressor/test_compression_zlib.cc11
3 files changed, 18 insertions, 4 deletions
diff --git a/src/test/compressor/compressor_example.h b/src/test/compressor/compressor_example.h
index f02aafb1826..40ab660878c 100644
--- a/src/test/compressor/compressor_example.h
+++ b/src/test/compressor/compressor_example.h
@@ -43,9 +43,9 @@ public:
out = in;
return 0;
}
- virtual int decompress(bufferlist::iterator &p, bufferlist &out)
+ virtual int decompress(bufferlist::iterator &p, size_t compressed_len, bufferlist &out)
{
- p.copy(p.get_remaining(), out);
+ p.copy(MIN(p.get_remaining(), compressed_len), out);
return 0;
}
};
diff --git a/src/test/compressor/test_compression_snappy.cc b/src/test/compressor/test_compression_snappy.cc
index e8bfe1bba76..296de4103b2 100644
--- a/src/test/compressor/test_compression_snappy.cc
+++ b/src/test/compressor/test_compression_snappy.cc
@@ -36,6 +36,13 @@ TEST(SnappyCompressor, compress_decompress)
bufferlist after;
res = sp.decompress(out, after);
EXPECT_EQ(res, 0);
+
+ after.clear();
+ size_t compressed_len = out.length();
+ out.append_zero(12);
+ auto it = out.begin();
+ res = sp.decompress(it, compressed_len, after);
+ EXPECT_EQ(res, 0);
}
TEST(SnappyCompressor, sharded_input_decompress)
diff --git a/src/test/compressor/test_compression_zlib.cc b/src/test/compressor/test_compression_zlib.cc
index e3706018ce3..642264b3380 100644
--- a/src/test/compressor/test_compression_zlib.cc
+++ b/src/test/compressor/test_compression_zlib.cc
@@ -27,7 +27,7 @@
TEST(CompressionZlib, compress_decompress)
{
CompressionZlib sp;
- EXPECT_STREQ(sp.get_type(), "zlib");
+ EXPECT_STREQ(sp.get_type().c_str(), "zlib");
const char* test = "This is test text";
int len = strlen(test);
bufferlist in, out;
@@ -40,12 +40,19 @@ TEST(CompressionZlib, compress_decompress)
bufferlist exp;
exp.append(test);
EXPECT_TRUE(exp.contents_equal(after));
+ after.clear();
+ size_t compressed_len = out.length();
+ out.append_zero(12);
+ auto it = out.begin();
+ res = sp.decompress(it, compressed_len, after);
+ EXPECT_EQ(res, 0);
+ EXPECT_TRUE(exp.contents_equal(after));
}
TEST(CompressionZlib, compress_decompress_chunk)
{
CompressionZlib sp;
- EXPECT_STREQ(sp.get_type(), "zlib");
+ EXPECT_STREQ(sp.get_type().c_str(), "zlib");
const char* test = "This is test text";
buffer::ptr test2 ("1234567890", 10);
int len = strlen(test);