]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/dll/test/library_info_test.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / dll / test / library_info_test.cpp
1 // Copyright 2011-2012 Renato Tegon Forti
2 // Copyright 2015-2019 Antony Polukhin
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt
6 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 // For more information, see http://www.boost.org
9
10 // MinGW related workaround
11 #define BOOST_DLL_FORCE_ALIAS_INSTANTIATION
12 #include "../example/b2_workarounds.hpp"
13
14 #include <boost/dll/library_info.hpp>
15 #include <boost/core/lightweight_test.hpp>
16 #include "../example/tutorial4/static_plugin.hpp"
17
18 // Unit Tests
19
20 #include <iterator>
21
22 int main(int argc, char* argv[])
23 {
24 boost::dll::fs::path shared_library_path = b2_workarounds::first_lib_from_argv(argc, argv);
25 BOOST_TEST(shared_library_path.string().find("test_library") != std::string::npos);
26
27 boost::dll::library_info lib_info(shared_library_path);
28 std::vector<std::string> sec = lib_info.sections();
29 std::copy(sec.begin(), sec.end(), std::ostream_iterator<std::string>(std::cout, ", "));
30 BOOST_TEST(std::find(sec.begin(), sec.end(), "boostdll") != sec.end());
31
32
33 std::cout << "\n\n\n";
34 std::vector<std::string> symb = lib_info.symbols();
35 std::copy(symb.begin(), symb.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
36 BOOST_TEST(std::find(symb.begin(), symb.end(), "const_integer_g") != symb.end());
37 BOOST_TEST(std::find(symb.begin(), symb.end(), "say_hello") != symb.end());
38
39 symb = lib_info.symbols("boostdll");
40 std::copy(symb.begin(), symb.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
41 BOOST_TEST(std::find(symb.begin(), symb.end(), "const_integer_g_alias") != symb.end());
42 BOOST_TEST(std::find(symb.begin(), symb.end(), "foo_variable") != symb.end());
43 BOOST_TEST(std::find(symb.begin(), symb.end(), "const_integer_g") == symb.end());
44 BOOST_TEST(std::find(symb.begin(), symb.end(), "say_hello") == symb.end());
45 BOOST_TEST(lib_info.symbols(std::string("boostdll")) == symb);
46
47 std::vector<std::string> empty = lib_info.symbols("empty");
48 BOOST_TEST(empty.empty() == true);
49
50 BOOST_TEST(lib_info.symbols("section_that_does_not_exist").empty());
51
52 // Self testing
53 std::cout << "Self: " << argv[0];
54 boost::dll::library_info self_info(argv[0]);
55
56 sec = self_info.sections();
57 //std::copy(sec.begin(), sec.end(), std::ostream_iterator<std::string>(std::cout, ", "));
58 BOOST_TEST(std::find(sec.begin(), sec.end(), "boostdll") != sec.end());
59
60 symb = self_info.symbols("boostdll");
61 std::copy(symb.begin(), symb.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
62 BOOST_TEST(std::find(symb.begin(), symb.end(), "create_plugin") != symb.end());
63
64 return boost::report_errors();
65 }