MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gunit_test_main.cc
1 /* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 // First include (the generated) my_config.h, to get correct platform defines.
17 #include "my_config.h"
18 #include <gtest/gtest.h>
19 #include <gmock/gmock.h>
20 
21 #include "my_getopt.h"
22 
23 #include <stdlib.h>
24 
25 namespace {
26 
27 my_bool opt_use_tap= true;
28 my_bool opt_help= false;
29 
30 struct my_option unittest_options[] =
31 {
32  { "tap-output", 1, "TAP (default) or gunit output.",
33  &opt_use_tap, &opt_use_tap, NULL,
34  GET_BOOL, OPT_ARG,
35  opt_use_tap, 0, 1, 0,
36  0, NULL
37  },
38  { "help", 2, "Help.",
39  &opt_help, &opt_help, NULL,
40  GET_BOOL, NO_ARG,
41  opt_help, 0, 1, 0,
42  0, NULL
43  },
44  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
45 };
46 
47 
48 extern "C" my_bool get_one_option(int, const struct my_option *, char *)
49 {
50  return FALSE;
51 }
52 
53 } // namespace
54 
55 // Some globals needed for merge_small_tests.cc
57 uint opt_debug_sync_timeout= 0;
58 pthread_key(MEM_ROOT**,THR_MALLOC);
59 pthread_key(THD*, THR_THD);
60 
61 extern "C" void sql_alloc_error_handler(void)
62 {
63  ADD_FAILURE();
64 }
65 
66 
67 extern void install_tap_listener();
68 
69 int main(int argc, char **argv)
70 {
71  ::testing::InitGoogleTest(&argc, argv);
72  ::testing::InitGoogleMock(&argc, argv);
73  MY_INIT(argv[0]);
74 
75  if (handle_options(&argc, &argv, unittest_options, get_one_option))
76  return EXIT_FAILURE;
77  if (opt_use_tap)
78  install_tap_listener();
79  if (opt_help)
80  printf("\n\nTest options: [--[disable-]tap-output]\n");
81 
82  return RUN_ALL_TESTS();
83 }