From 5afddf4681d6ce651164c5486a15b41a0b098ac4 Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Thu, 8 Mar 2012 11:55:01 -0800 Subject: Rename main.cpp to xorg-gtest_main.cpp This matches the library name and will help with understanding what the includes since we are now shipping the source code. Signed-off-by: Chase Douglas Reviewed-By: Christopher Halse Rogers --- src/Makefile.am | 2 +- src/main.cpp | 131 ------------------------------------------------ src/xorg-gtest_main.cpp | 131 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 132 deletions(-) delete mode 100644 src/main.cpp create mode 100644 src/xorg-gtest_main.cpp diff --git a/src/Makefile.am b/src/Makefile.am index c675bab..bfe1b16 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,7 +39,7 @@ libxorg_gtest_la_CPPFLAGS = \ libxorg_gtest_main_la_SOURCES = \ defines.h \ - main.cpp + xorg-gtest_main.cpp libxorg_gtest_main_la_LIBADD = libxorg-gtest.la diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 5e5a748..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * - * X testing environment - Google Test environment feat. dummy x server - * - * Copyright (C) 2011, 2012 Canonical Ltd. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - ******************************************************************************/ - -#include - -#include - -#include "xorg/gtest/environment.h" -#include "defines.h" - -namespace { - -int help = false; -int no_dummy_server = false; -int xorg_conf_specified = false; -int xorg_display_specified = false; -int xorg_logfile_specified = false; -int server_specified = false; - -const struct option longopts[] = { - { "help", no_argument, &help, true, }, - { "no-dummy-server", no_argument, &no_dummy_server, true, }, - { "xorg-conf", required_argument, &xorg_conf_specified, true, }, - { "xorg-display", required_argument, &xorg_display_specified, true, }, - { "xorg-logfile", required_argument, &xorg_logfile_specified, true, }, - { "server", required_argument, &server_specified, true, }, - { NULL, 0, NULL, 0 } -}; - -} // namespace - -int main(int argc, char *argv[]) { - std::string xorg_conf_path; - std::string xorg_log_file_path; - int xorg_display = -1; - std::string server; - - testing::InitGoogleTest(&argc, argv); - - /* Reset getopt state */ - optind = 0; - - while (true) { - int ret; - int index; - ret = getopt_long(argc, argv, "", longopts, &index); - - if (ret == -1) - break; - - if (ret == '?') - exit(-1); - - switch (index) { - case 2: - xorg_conf_path = optarg; - break; - - case 3: - xorg_display = atoi(optarg); - break; - - case 4: - xorg_log_file_path = optarg; - break; - - case 5: - server = optarg; - break; - - default: - break; - } - } - - if (help) { - std::cout << "\nAdditional options:\n"; - std::cout << " --no-dummy-server: Use the currently running X server " - "for testing\n"; - std::cout << " --xorg-conf: Path to xorg dummy configuration file\n"; - std::cout << " --server: Path to X server executable\n"; - std::cout << " --xorg-display: xorg dummy display port\n"; - std::cout << " --xorg-logfile: xorg logfile filename. See -logfile in \"man Xorg\".\n" - " Its default value is "DEFAULT_XORG_LOGFILE".\n"; - exit(-1); - } - - if (!no_dummy_server) { - xorg::testing::Environment* environment = new xorg::testing::Environment; - - if (xorg_conf_specified) - environment->set_conf_file(xorg_conf_path); - - if (server_specified) - environment->set_server(server); - - if (xorg_display_specified) - environment->set_display(xorg_display); - - if (xorg_logfile_specified) - environment->set_log_file(xorg_log_file_path); - - testing::AddGlobalTestEnvironment(environment); - } - - return RUN_ALL_TESTS(); -} diff --git a/src/xorg-gtest_main.cpp b/src/xorg-gtest_main.cpp new file mode 100644 index 0000000..5e5a748 --- /dev/null +++ b/src/xorg-gtest_main.cpp @@ -0,0 +1,131 @@ +/******************************************************************************* + * + * X testing environment - Google Test environment feat. dummy x server + * + * Copyright (C) 2011, 2012 Canonical Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + ******************************************************************************/ + +#include + +#include + +#include "xorg/gtest/environment.h" +#include "defines.h" + +namespace { + +int help = false; +int no_dummy_server = false; +int xorg_conf_specified = false; +int xorg_display_specified = false; +int xorg_logfile_specified = false; +int server_specified = false; + +const struct option longopts[] = { + { "help", no_argument, &help, true, }, + { "no-dummy-server", no_argument, &no_dummy_server, true, }, + { "xorg-conf", required_argument, &xorg_conf_specified, true, }, + { "xorg-display", required_argument, &xorg_display_specified, true, }, + { "xorg-logfile", required_argument, &xorg_logfile_specified, true, }, + { "server", required_argument, &server_specified, true, }, + { NULL, 0, NULL, 0 } +}; + +} // namespace + +int main(int argc, char *argv[]) { + std::string xorg_conf_path; + std::string xorg_log_file_path; + int xorg_display = -1; + std::string server; + + testing::InitGoogleTest(&argc, argv); + + /* Reset getopt state */ + optind = 0; + + while (true) { + int ret; + int index; + ret = getopt_long(argc, argv, "", longopts, &index); + + if (ret == -1) + break; + + if (ret == '?') + exit(-1); + + switch (index) { + case 2: + xorg_conf_path = optarg; + break; + + case 3: + xorg_display = atoi(optarg); + break; + + case 4: + xorg_log_file_path = optarg; + break; + + case 5: + server = optarg; + break; + + default: + break; + } + } + + if (help) { + std::cout << "\nAdditional options:\n"; + std::cout << " --no-dummy-server: Use the currently running X server " + "for testing\n"; + std::cout << " --xorg-conf: Path to xorg dummy configuration file\n"; + std::cout << " --server: Path to X server executable\n"; + std::cout << " --xorg-display: xorg dummy display port\n"; + std::cout << " --xorg-logfile: xorg logfile filename. See -logfile in \"man Xorg\".\n" + " Its default value is "DEFAULT_XORG_LOGFILE".\n"; + exit(-1); + } + + if (!no_dummy_server) { + xorg::testing::Environment* environment = new xorg::testing::Environment; + + if (xorg_conf_specified) + environment->set_conf_file(xorg_conf_path); + + if (server_specified) + environment->set_server(server); + + if (xorg_display_specified) + environment->set_display(xorg_display); + + if (xorg_logfile_specified) + environment->set_log_file(xorg_log_file_path); + + testing::AddGlobalTestEnvironment(environment); + } + + return RUN_ALL_TESTS(); +} -- cgit v1.2.3