]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/test/test-organization-ts/test_unit-nested-suite-dependency.cpp
34d731e829534e5855e1a7640da7393a88501f82
[ceph.git] / ceph / src / boost / libs / test / test / test-organization-ts / test_unit-nested-suite-dependency.cpp
1 // (C) Copyright Raffi Enficiaud 2017.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org/libs/test for the library home page.
7 //
8 //! @file
9 //! checking the nested suites activation, ticket trac #13149
10 // *****************************************************************************
11
12 #define BOOST_TEST_MODULE test_nested_dependency
13 #include <boost/test/unit_test.hpp>
14 #include <boost/test/unit_test_parameters.hpp>
15 #include <boost/test/tree/test_case_counter.hpp>
16 #include <boost/test/tree/traverse.hpp>
17
18 // initial reproducing snippet on the corresponding ticket
19 #if 0
20 BOOST_AUTO_TEST_SUITE(suite1, *boost::unit_test::depends_on("suite2"))
21 BOOST_AUTO_TEST_SUITE(suite1_nested)
22 BOOST_AUTO_TEST_CASE(suite1_test1)
23 {
24 BOOST_CHECK(true);
25 }
26 BOOST_AUTO_TEST_SUITE_END()
27 BOOST_AUTO_TEST_SUITE_END()
28
29 BOOST_AUTO_TEST_SUITE(suite2)
30 BOOST_AUTO_TEST_CASE(suite2_test2)
31 {
32 BOOST_CHECK(true);
33 }
34 BOOST_AUTO_TEST_SUITE_END()
35 #endif
36
37 void suite1_test1()
38 {
39 BOOST_CHECK(true);
40 }
41
42 void suite2_test2()
43 {
44 BOOST_CHECK(true);
45 }
46
47 BOOST_AUTO_TEST_CASE( some_test )
48 {
49 using namespace boost::unit_test;
50
51 // test tree
52 test_suite* master_ts = BOOST_TEST_SUITE("local master");
53 test_suite* t_suite1 = BOOST_TEST_SUITE( "suite1" );
54 test_suite* t_suite1_nested = BOOST_TEST_SUITE( "suite1_nested" );
55 t_suite1_nested->add( BOOST_TEST_CASE( suite1_test1 ) );
56 t_suite1->add(t_suite1_nested);
57
58 test_suite* t_suite2 = BOOST_TEST_SUITE( "suite2" );
59 t_suite2->add( BOOST_TEST_CASE( suite2_test2 ) );
60
61 master_ts->add(t_suite1);
62 master_ts->add(t_suite2);
63
64 // dependencies
65 t_suite1->depends_on( t_suite2 );
66
67 // running
68 char const* argv[] = { "dummy-test-module.exe", "--log_level=all", "--run_test=suite1/suite1_nested"};
69 int argc = sizeof(argv)/sizeof(argv[0]);
70
71 master_ts->p_default_status.value = test_unit::RS_ENABLED;
72 framework::finalize_setup_phase( master_ts->p_id );
73
74 runtime_config::init( argc, (char**)argv );
75 framework::impl::setup_for_execution( *master_ts );
76
77 // no need to run
78 //framework::run( master_ts );
79
80 // we should have 2 test cases enabled with this run parameters
81 test_case_counter tcc;
82 traverse_test_tree( master_ts->p_id, tcc );
83 BOOST_TEST( tcc.p_count == 2 );
84 }