From cb2c91850c88343ae87080da83052298507f60d9 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Fri, 13 Mar 2015 11:08:50 -0700 Subject: [PATCH] Don't run some tests is snappy is not present Summary: Currently, we have `ifdef SNAPPY` around bunch of db_test code. Some tests that don't even use compression are also blocked when running system doesn't have snappy. This also causes hard-to-catch bugs, like D34983. We should dynamically figure out if compression is supported or not. Test Plan: compiles Reviewers: sdong, meyering Reviewed By: meyering Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D34989 --- db/db_test.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index b6b67b4fe..f763eaab7 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -66,6 +66,11 @@ static bool SnappyCompressionSupported(const CompressionOptions& options) { return Snappy_Compress(options, in.data(), in.size(), &out); } +static bool SnappyCompressionSupported() { + CompressionOptions options; + return SnappyCompressionSupported(options); +} + static bool ZlibCompressionSupported(const CompressionOptions& options) { std::string out; Slice in = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; @@ -4110,8 +4115,10 @@ TEST(DBTest, UniversalCompactionStopStyleSimilarSize) { ASSERT_EQ(NumTableFilesAtLevel(0), 4); } -#if defined(SNAPPY) TEST(DBTest, CompressedCache) { + if (!SnappyCompressionSupported()) { + return; + } int num_iter = 80; // Run this test three iterations. @@ -4233,6 +4240,9 @@ static std::string CompressibleString(Random* rnd, int len) { } TEST(DBTest, UniversalCompactionCompressRatio1) { + if (!SnappyCompressionSupported()) { + return; + } Options options; options.compaction_style = kCompactionStyleUniversal; options.write_buffer_size = 100<<10; //100KB @@ -4298,6 +4308,9 @@ TEST(DBTest, UniversalCompactionCompressRatio1) { } TEST(DBTest, UniversalCompactionCompressRatio2) { + if (!SnappyCompressionSupported()) { + return; + } Options options; options.compaction_style = kCompactionStyleUniversal; options.write_buffer_size = 100<<10; //100KB @@ -4336,6 +4349,9 @@ TEST(DBTest, FailMoreDbPaths) { } TEST(DBTest, UniversalCompactionSecondPathRatio) { + if (!SnappyCompressionSupported()) { + return; + } Options options; options.db_paths.emplace_back(dbname_, 500 * 1024); options.db_paths.emplace_back(dbname_ + "_2", 1024 * 1024 * 1024); @@ -4755,8 +4771,6 @@ TEST(DBTest, UniversalCompactionFourPaths) { Destroy(options); } -#endif - void CheckColumnFamilyMeta(const ColumnFamilyMetaData& cf_meta) { uint64_t cf_size = 0; uint64_t cf_csize = 0;