]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/test/test/framework-ts/log-formatter-test.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / test / test / framework-ts / log-formatter-test.cpp
index 9566cec88762fad190049cbf3db4818a252f72aa..02df428f7924eeda01f7e7391b2c79c26f5e5138 100644 (file)
@@ -17,6 +17,8 @@
 #include <boost/test/framework.hpp>
 #include <boost/test/unit_test_parameters.hpp>
 #include <boost/test/utils/nullstream.hpp>
+#include <boost/test/execution_monitor.hpp>
+
 typedef boost::onullstream onullstream_type;
 
 // BOOST
@@ -31,7 +33,7 @@ typedef boost::onullstream onullstream_type;
 
 using boost::test_tools::output_test_stream;
 using namespace boost::unit_test;
-namespace utf = boost::unit_test;
+
 
 
 //____________________________________________________________________________//
@@ -74,6 +76,17 @@ void very_bad_exception()  {
     throw local_exception();
 }
 
+void bad_foo2() { bad_foo(); } // tests with clashing names
+
+void timeout_foo()
+{
+    using boost::execution_exception;
+    execution_exception::location dummy;
+    throw execution_exception(
+          execution_exception::timeout_error,
+          "fake  timeout",
+          dummy);
+}
 
 //____________________________________________________________________________//
 
@@ -123,15 +136,15 @@ struct guard {
 //____________________________________________________________________________//
 
 
-BOOST_AUTO_TEST_CASE( test_result_reports )
+BOOST_AUTO_TEST_CASE( test_logs )
 {
     guard G;
-    ut_detail::ignore_unused_variable_warning( G );
+    boost::ignore_unused( G );
 
 #define PATTERN_FILE_NAME "log-formatter-test.pattern"
 
     std::string pattern_file_name(
-        framework::master_test_suite().argc == 1
+        framework::master_test_suite().argc <= 1
             ? (runtime_config::save_pattern() ? PATTERN_FILE_NAME : "./baseline-outputs/" PATTERN_FILE_NAME )
             : framework::master_test_suite().argv[1] );
 
@@ -160,7 +173,7 @@ BOOST_AUTO_TEST_CASE( test_result_reports )
         ts_3->add( BOOST_TEST_CASE( bad_foo ) );
         test_case* tc1 = BOOST_TEST_CASE( very_bad_foo );
         ts_3->add( tc1 );
-        test_case* tc2 = BOOST_TEST_CASE( bad_foo );
+        test_case* tc2 = BOOST_TEST_CASE( bad_foo2 );
         ts_3->add( tc2 );
         tc2->depends_on( tc1 );
 
@@ -168,7 +181,7 @@ BOOST_AUTO_TEST_CASE( test_result_reports )
         ts_4->add( BOOST_TEST_CASE( bad_foo ) );
         ts_4->add( BOOST_TEST_CASE( very_bad_foo ) );
         ts_4->add( BOOST_TEST_CASE( very_bad_exception ) );
-        ts_4->add( BOOST_TEST_CASE( bad_foo ) );
+        ts_4->add( BOOST_TEST_CASE( bad_foo2 ) );
 
     test_suite* ts_main = BOOST_TEST_SUITE( "Fake Test Suite Hierarchy" );
         ts_main->add( ts_0 );
@@ -177,6 +190,20 @@ BOOST_AUTO_TEST_CASE( test_result_reports )
         ts_main->add( ts_3 );
         ts_main->add( ts_4 );
 
+    test_suite* ts_timeout = BOOST_TEST_SUITE( "Timeout" );
+        ts_timeout->add( BOOST_TEST_CASE( good_foo ) );
+        test_case * tc_timeout = BOOST_TEST_CASE( timeout_foo );
+        ts_timeout->add( tc_timeout );
+
+    test_suite* ts_timeout_nested = BOOST_TEST_SUITE( "Timeout-nested" );
+        ts_timeout_nested->add( BOOST_TEST_CASE( good_foo ) );
+        test_suite* ts_timeout_internal = BOOST_TEST_SUITE( "Timeout" );
+          ts_timeout_internal->add( BOOST_TEST_CASE( good_foo ) );
+          test_case * tc_timeout_internal = BOOST_TEST_CASE( timeout_foo );
+          ts_timeout_internal->add( tc_timeout_internal );
+        ts_timeout_nested->add( ts_timeout_internal );
+        ts_timeout_nested->add( BOOST_TEST_CASE_NAME( good_foo, "good_foo2" ) );
+
     check( test_output, ts_1 );
 
     check( test_output, ts_1b );
@@ -193,8 +220,63 @@ BOOST_AUTO_TEST_CASE( test_result_reports )
     ts_3->depends_on( ts_1 );
 
     check( test_output, ts_main );
+
+    check( test_output, ts_timeout );
+
+    check( test_output, ts_timeout_nested );
 }
 
 //____________________________________________________________________________//
 
+BOOST_AUTO_TEST_CASE( test_logs_junit_info_closing_tags )
+{
+    guard G;
+    boost::ignore_unused( G );
+
+#define PATTERN_FILE_NAME_JUNIT "log-formatter-test.pattern.junit"
+
+    std::string pattern_file_name(
+        framework::master_test_suite().argc <= 2
+            ? (runtime_config::save_pattern() ? PATTERN_FILE_NAME_JUNIT : "./baseline-outputs/" PATTERN_FILE_NAME_JUNIT )
+            : framework::master_test_suite().argv[2] );
+
+    output_test_stream_for_loggers test_output( pattern_file_name,
+                                                !runtime_config::save_pattern(),
+                                                true,
+                                                __FILE__ );
+
+#line 218
+    test_suite* ts_main = BOOST_TEST_SUITE( "1 test cases inside" );
+    ts_main->add( BOOST_TEST_CASE( almost_good_foo ) );
+
+    ts_main->p_default_status.value = test_unit::RS_ENABLED;
+    char const* argv[] = { "a.exe", "--run_test=*", "--build_info" };
+    int argc = sizeof(argv)/sizeof(argv[0]);
+    boost::unit_test::runtime_config::init( argc, (char**)argv );
+    boost::unit_test::framework::impl::setup_for_execution( *ts_main );
+
+    check( test_output, OF_JUNIT, ts_main->p_id, log_successful_tests );
+
+    test_suite* ts_timeout = BOOST_TEST_SUITE( "Timeout" );
+        ts_timeout->add( BOOST_TEST_CASE( good_foo ) );
+        test_case * tc_timeout = BOOST_TEST_CASE( timeout_foo );
+        ts_timeout->add( tc_timeout );
+
+    check( test_output, OF_JUNIT, ts_timeout->p_id, log_successful_tests );
+
+
+    test_suite* ts_account_failures = BOOST_TEST_SUITE( "1 junit failure is not error" );
+        ts_account_failures->add( BOOST_TEST_CASE( bad_foo ) );
+        ts_account_failures->add( BOOST_TEST_CASE( very_bad_foo ) );
+        ts_account_failures->add( BOOST_TEST_CASE( good_foo ) );
+        ts_account_failures->add( BOOST_TEST_CASE( bad_foo2 ) );
+
+    char const* argv2[] = { "a.exe", "--run_test=*", "--build_info=false"  };
+    int argc2 = sizeof(argv2)/sizeof(argv2[0]);
+    boost::unit_test::runtime_config::init( argc2, (char**)argv2 );
+    boost::unit_test::framework::impl::setup_for_execution( *ts_account_failures );
+
+    check( test_output, OF_JUNIT, ts_account_failures->p_id, log_messages );
+}
+
 // EOF