utest: add error exception
[platform/core/uifw/wayland-tbm.git] / utests / src / ut_main.cpp
1 /*
2 Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved.
3
4 Contact:
5       SooChan Lim <sc1.lim@samsung.com>,
6       Sangjin Lee <lsj119@samsung.com>,
7       Boram Park <boram1288.park@samsung.com>,
8       Changyeon Lee <cyeon.lee@samsung.com>
9
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the "Software"),
12 to deal in the Software without restriction, including without limitation
13 the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 and/or sell copies of the Software, and to permit persons to whom the
15 Software is furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice (including the next
18 paragraph) shall be included in all copies or substantial portions of the
19 Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 */
29
30 #include "gtest/gtest.h"
31
32 #ifdef TIZEN_TEST_GCOV
33 extern "C" void __gcov_flush(void);
34 #endif
35
36 int main(int argc, char **argv)
37 {
38         auto AllTestSuccess = false;
39
40 #ifdef TIZEN_TEST_GCOV
41         setenv("GCOV_PREFIX", "/tmp", 1);
42 #endif
43
44         try {
45                 ::testing::InitGoogleTest(&argc, argv);
46                 ::testing::FLAGS_gtest_death_test_style = "fast";
47         } catch ( ... ) {
48                 std::cout << "error while trying to init google tests.\n";
49                 exit(EXIT_FAILURE);
50         }
51
52         try {
53                 AllTestSuccess = RUN_ALL_TESTS() == 0 ? true : false;
54         } catch (const ::testing::internal::GoogleTestFailureException & e) {
55                 AllTestSuccess = false;
56                 std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
57                 std::cout << "\n";
58         }
59
60 #ifdef TIZEN_TEST_GCOV
61         __gcov_flush();
62 #endif
63
64         return AllTestSuccess;
65 }