MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gunit_test_main_server.cc
1 /* Copyright (c) 2009, 2012, 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 #include "test_utils.h"
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 
56 extern void install_tap_listener();
57 
58 int main(int argc, char **argv)
59 {
60  ::testing::InitGoogleTest(&argc, argv);
61  ::testing::InitGoogleMock(&argc, argv);
62  MY_INIT(argv[0]);
63 
64  if (handle_options(&argc, &argv, unittest_options, get_one_option))
65  return EXIT_FAILURE;
66  if (opt_use_tap)
67  install_tap_listener();
68  if (opt_help)
69  printf("\n\nTest options: [--[disable-]tap-output]\n");
70 
71  my_testing::setup_server_for_unit_tests();
72  int ret= RUN_ALL_TESTS();
73  my_testing::teardown_server_for_unit_tests();
74  return ret;
75 }