From b3175f115d5b34e1016934c395e5da64a79dae1e Mon Sep 17 00:00:00 2001 From: "Raphael S. Carvalho" Date: Fri, 27 Mar 2015 21:27:33 -0300 Subject: [PATCH] tests: sstables: move code to be reused for other components Also, semaphore was removed because it's useless there. Signed-off-by: Raphael S. Carvalho --- tests/urchin/sstable_test.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/urchin/sstable_test.cc b/tests/urchin/sstable_test.cc index 30bc565d42..9215aaec40 100644 --- a/tests/urchin/sstable_test.cc +++ b/tests/urchin/sstable_test.cc @@ -217,14 +217,12 @@ static future> read_file(sstring file_path) }); } -SEASTAR_TEST_CASE(check_compressed_info_func) { - auto sem = make_lw_shared(0); - - return write_sst_info("tests/urchin/sstables/compressed", 1).then([sem] { - auto file_path = filename("tests/urchin/sstables/compressed", "la", 1, "big", "CompressionInfo.db"); - return read_file(file_path).then([sem] (auto ret) { - auto file_path = filename("tests/urchin/sstables/compressed", "la", 2, "big", "CompressionInfo.db"); - return read_file(file_path).then([ret, sem] (auto ret2) { +static future<> check_component_integrity(sstring component) { + return write_sst_info("tests/urchin/sstables/compressed", 1).then([component] { + auto file_path = filename("tests/urchin/sstables/compressed", "la", 1, "big", component); + return read_file(file_path).then([component] (auto ret) { + auto file_path = filename("tests/urchin/sstables/compressed", "la", 2, "big", component); + return read_file(file_path).then([ret] (auto ret2) { // assert that both files have the same size. BOOST_REQUIRE(ret.second == ret2.second); // assert that both files have the same content. @@ -232,12 +230,13 @@ SEASTAR_TEST_CASE(check_compressed_info_func) { // free buf from both files. ::free(ret.first); ::free(ret2.first); - sem->signal(); }); }); }); +} - return sem->wait(); +SEASTAR_TEST_CASE(check_compressed_info_func) { + return check_component_integrity("CompressionInfo.db"); } // Data file reading tests.