Fix build break with boost 1.71.0
[platform/core/security/key-manager.git] / tests / main.cpp
1 /*
2  *  Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16 /*
17  * @file       main.cpp
18  * @author     Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
19  * @version    1.0
20  */
21
22 #include <iostream>
23 #include <key-provider.h>
24 #include <boost/test/unit_test.hpp>
25 #include <boost/test/unit_test_log.hpp>
26 #include <boost/test/results_reporter.hpp>
27 #include <colour_log_formatter.h>
28 #include <dpl/log/log.h>
29 #include <log-setup.h>
30
31 #include <exception.h>
32
33 struct TestConfig {
34         TestConfig()
35         {
36                 boost::unit_test::unit_test_log.set_threshold_level(
37                         boost::unit_test::log_test_units);
38                 boost::unit_test::results_reporter::set_level(boost::unit_test::SHORT_REPORT);
39                 boost::unit_test::unit_test_log.set_formatter(new CKM::colour_log_formatter);
40         }
41         ~TestConfig()
42         {
43         }
44 };
45
46 bool isLibInitialized = false;
47
48 struct KeyProviderLib {
49         KeyProviderLib()
50         {
51                 try {
52                         CKM::KeyProvider::initializeLibrary();
53                         isLibInitialized = true;
54                 } catch (const CKM::Exc::Exception &) {
55                         std::cout << "Library initialization failed!" << std::endl;
56                 }
57         }
58         ~KeyProviderLib()
59         {
60                 try {
61                         CKM::KeyProvider::closeLibrary();
62                 } catch (const CKM::Exc::Exception &) {
63                         std::cout << "Library deinitialization failed!" << std::endl;
64                 }
65         }
66 };
67
68 struct LogSetup {
69         LogSetup()
70         {
71                 CKM::SetupClientLogSystem();
72                 CKM::Singleton<CKM::Log::LogSystem>::Instance().SetTag("CKM_INTERNAL_TESTS");
73         }
74         ~LogSetup() {}
75 };
76
77 BOOST_GLOBAL_FIXTURE(KeyProviderLib);
78 BOOST_GLOBAL_FIXTURE(TestConfig);
79 BOOST_GLOBAL_FIXTURE(LogSetup);
80