From: David Reiss Date: Wed, 6 Oct 2010 17:10:42 +0000 (+0000) Subject: THRIFT-929. cpp: Convert tests to use boost 1.37 X-Git-Tag: 0.6.0~98 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=109693c82a63b321b540cb3c993d918fc946dfbe;p=common%2Fthrift.git THRIFT-929. cpp: Convert tests to use boost 1.37 The boost test framework has changed significantly from boost 1.34 to 1.37. Quite a few new features have been added, and some annoying bugs have been fixed. This change now builds the thrift tests against boost 1.37, and updates them to use some of the newer features. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1005162 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/cpp/test/TFileTransportTest.cpp b/lib/cpp/test/TFileTransportTest.cpp index 45583449..d402d5d1 100644 --- a/lib/cpp/test/TFileTransportTest.cpp +++ b/lib/cpp/test/TFileTransportTest.cpp @@ -164,7 +164,7 @@ int time_diff(const struct timeval* t1, const struct timeval* t2) { * wall-clock time. This could result in false failures on slower systems, or * on heavily loaded machines. */ -void test_destructor() { +BOOST_AUTO_TEST_CASE(test_destructor) { TempFile f(tmp_dir, "thrift.TFileTransportTest."); unsigned int const NUM_ITERATIONS = 1000; @@ -286,17 +286,17 @@ void test_flush_max_us_impl(uint32_t flush_us, uint32_t write_us, } } -void test_flush_max_us1() { +BOOST_AUTO_TEST_CASE(test_flush_max_us1) { // fsync every 10ms, write every 5ms, for 500ms test_flush_max_us_impl(10000, 5000, 500000); } -void test_flush_max_us2() { +BOOST_AUTO_TEST_CASE(test_flush_max_us2) { // fsync every 50ms, write every 20ms, for 500ms test_flush_max_us_impl(50000, 20000, 500000); } -void test_flush_max_us3() { +BOOST_AUTO_TEST_CASE(test_flush_max_us3) { // fsync every 400ms, write every 300ms, for 1s test_flush_max_us_impl(400000, 300000, 1000000); } @@ -307,7 +307,7 @@ void test_flush_max_us3() { * TFileTransport used to have a bug where flush() would wait for the fsync * timeout to expire. */ -void test_noop_flush() { +BOOST_AUTO_TEST_CASE(test_noop_flush) { TempFile f(tmp_dir, "thrift.TFileTransportTest."); TFileTransport transport(f.getPath()); @@ -381,17 +381,10 @@ void parse_args(int argc, char* argv[]) { } boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { + boost::unit_test::framework::master_test_suite().p_name.value = + "TFileTransportTest"; + // Parse arguments parse_args(argc, argv); - - boost::unit_test::test_suite* suite = - BOOST_TEST_SUITE("TFileTransportTests"); - - suite->add(BOOST_TEST_CASE(test_destructor)); - suite->add(BOOST_TEST_CASE(test_flush_max_us1)); - suite->add(BOOST_TEST_CASE(test_flush_max_us2)); - suite->add(BOOST_TEST_CASE(test_flush_max_us3)); - suite->add(BOOST_TEST_CASE(test_noop_flush)); - - return suite; + return NULL; } diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp index c42b6acc..dceb708d 100644 --- a/lib/cpp/test/TransportTest.cpp +++ b/lib/cpp/test/TransportTest.cpp @@ -1037,9 +1037,11 @@ boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { initrand(options.seed); - boost::unit_test::test_suite* suite = BOOST_TEST_SUITE("TransportTests"); + boost::unit_test::test_suite* suite = + &boost::unit_test::framework::master_test_suite(); + suite->p_name.value = "TransportTest"; TransportTestGen transport_test_generator(suite, options.sizeMultiplier); transport_test_generator.generate(); - return suite; + return NULL; } diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp index d2e6252d..c9d3f389 100644 --- a/lib/cpp/test/ZlibTest.cpp +++ b/lib/cpp/test/ZlibTest.cpp @@ -440,7 +440,9 @@ void parse_args(int argc, char* argv[]) { unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { parse_args(argc, argv); - unit_test::test_suite* suite = BOOST_TEST_SUITE("ZlibTests"); + unit_test::test_suite* suite = + &boost::unit_test::framework::master_test_suite(); + suite->p_name.value = "ZlibTest"; uint32_t buf_len = 1024*32; add_tests(suite, gen_uniform_buffer(buf_len, 'a'), buf_len, "uniform"); @@ -449,5 +451,5 @@ unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { suite->add(BOOST_TEST_CASE(test_no_write)); - return suite; + return NULL; }