]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/test/doc/adv_scenarios/shared_lib_customizations.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / test / doc / adv_scenarios / shared_lib_customizations.qbk
1 [/
2 / Copyright (c) 2003 Boost.Test contributors
3 /
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 /]
7
8 [section:shared_lib_customizations Shared-library variant customizations]
9
10 [caution Macro __BOOST_TEST_DYN_LINK__ (which instructs the compiler/linker to dynamically link against a shared library variant) may be implicitly defined when macro `BOOST_ALL_DYN_LINK` is defined.]
11
12 [caution In order to be able to run a test built with the dynamic variant, the operating system should be able
13 to find the dynamic library of the __UTF__. This means, for example on Linux and MacOSX respectively, setting the environment
14 variable `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` properly prior to the execution of the test module.]
15
16 [section:entry_point Customizing the module's entry point]
17
18 In this variant, in one of the source files, you now have to define your custom entry point, and invoke the default [link boost_test.adv_scenarios.test_module_runner_overview test runner] `unit_test_main` manually with the default [link boost_test.adv_scenarios.test_module_init_overview initialization function] `init_unit_test` as argument. You need to define __BOOST_TEST_NO_MAIN__ (its value is irrelevant) in the main file:
19
20 [table
21 [[In *exactly one* file][In all other files]]
22 [[```#define BOOST_TEST_MODULE test module name
23 #define BOOST_TEST_DYN_LINK
24 #define BOOST_TEST_NO_MAIN
25 #include <boost/test/unit_test.hpp>
26
27 // entry point:
28 int main(int argc, char* argv[], char* envp[])
29 {
30 return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
31 }
32 ```]
33 [```#define BOOST_TEST_DYN_LINK
34 #include <boost/test/unit_test.hpp>
35
36 //
37 // test cases
38 //
39
40 //
41 // test cases
42 //
43 ```]]
44 ]
45
46 [endsect] [/section:entry_point]
47
48 [section:init_func Customizing the module's initialization function]
49
50 In the shared-library variant, it is impossible to customize the initialization function without [link boost_test.adv_scenarios.shared_lib_customizations.entry_point customizing the entry point]. We have to customize both. In one of the source files, you now have to define your custom entry point and [link boost_test.adv_scenarios.test_module_init_overview initialization function] `init_unit_test`; next invoke the default [link boost_test.adv_scenarios.test_module_runner_overview test runner] `unit_test_main` manually with `init_unit_test` as argument. You ['do not] define __BOOST_TEST_MODULE__ in the main file:
51
52 [table
53 [[In *exactly one* file][In all other files]]
54 [[```#define BOOST_TEST_DYN_LINK
55 #include <boost/test/unit_test.hpp>
56
57 // initialization function:
58 bool init_unit_test()
59 {
60 return true;
61 }
62
63 // entry point:
64 int main(int argc, char* argv[])
65 {
66 return boost::unit_test::unit_test_main( &init_unit_test, argc, argv );
67 }
68 ```]
69 [```#define BOOST_TEST_DYN_LINK
70 #include <boost/test/unit_test.hpp>
71
72 //
73 // test cases
74 //
75
76 //
77 // test cases
78 //
79
80 //
81 // test cases
82 //
83 ```]]
84 ]
85
86 [endsect] [/section:init_func]
87
88 [endsect] [/section:shared_lib_customizations]