| Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 
|  | 2 | // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 | // found in the LICENSE file. | 
|  | 4 |  | 
| Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 5 | #include <base/at_exit.h> | 
| Darin Petkov | 3569415 | 2011-08-17 16:55:04 -0700 | [diff] [blame] | 6 | #include <base/command_line.h> | 
|  | 7 | #include <chromeos/syslog_logging.h> | 
| Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 8 | #include <gtest/gtest.h> | 
| Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 9 |  | 
| Peter Qiu | 40a0148 | 2014-10-31 11:54:23 -0700 | [diff] [blame] | 10 | #include "shill/glib_io_handler_factory.h" | 
| Prathmesh Prabhu | f002cdb | 2014-09-17 22:41:05 -0700 | [diff] [blame] | 11 | #include "shill/logging.h" | 
| Peter Qiu | 40a0148 | 2014-10-31 11:54:23 -0700 | [diff] [blame] | 12 | #include "shill/net/io_handler_factory_container.h" | 
| Prathmesh Prabhu | f002cdb | 2014-09-17 22:41:05 -0700 | [diff] [blame] | 13 |  | 
|  | 14 | namespace switches { | 
|  | 15 |  | 
|  | 16 | static const char kHelp[] = "help"; | 
|  | 17 |  | 
|  | 18 | static const char kHelpMessage[] = "\n" | 
|  | 19 | "Additional (non-gtest) switches:\n" | 
|  | 20 | "  --log-level=N\n" | 
|  | 21 | "    Logging level:\n" | 
|  | 22 | "      0 = LOG(INFO), 1 = LOG(WARNING), 2 = LOG(ERROR),\n" | 
|  | 23 | "      -1 = SLOG(..., 1), -2 = SLOG(..., 2), etc.\n" | 
|  | 24 | "  --log-scopes=\"*scope1+scope2\".\n" | 
|  | 25 | "    Scopes to enable for SLOG()-based logging.\n"; | 
|  | 26 |  | 
|  | 27 | }  // namespace switches | 
|  | 28 |  | 
| Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 29 | int main(int argc, char** argv) { | 
| Chris Masone | 0e1d104 | 2011-05-09 18:07:03 -0700 | [diff] [blame] | 30 | base::AtExitManager exit_manager; | 
| Alex Vakulenko | 127f256 | 2015-04-02 14:31:10 -0700 | [diff] [blame] | 31 | base::CommandLine::Init(argc, argv); | 
| Paul Stewart | 1a212a6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 32 | base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | 
| Darin Petkov | 3569415 | 2011-08-17 16:55:04 -0700 | [diff] [blame] | 33 | chromeos::InitLog(chromeos::kLogToStderr); | 
| Prathmesh Prabhu | f002cdb | 2014-09-17 22:41:05 -0700 | [diff] [blame] | 34 | shill::SetLogLevelFromCommandLine(cl); | 
| Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 35 | ::testing::InitGoogleTest(&argc, argv); | 
| Prathmesh Prabhu | f002cdb | 2014-09-17 22:41:05 -0700 | [diff] [blame] | 36 |  | 
|  | 37 | if (cl->HasSwitch(switches::kHelp)) { | 
|  | 38 | std::cerr << switches::kHelpMessage; | 
|  | 39 | } | 
| Peter Qiu | 40a0148 | 2014-10-31 11:54:23 -0700 | [diff] [blame] | 40 |  | 
|  | 41 | // Overwrite default IOHandlerFactory with the glib version of it. This needs | 
|  | 42 | // to be placed before any reference to the IOHandlerFactory. | 
|  | 43 | shill::IOHandlerFactoryContainer::GetInstance()->SetIOHandlerFactory( | 
|  | 44 | new shill::GlibIOHandlerFactory()); | 
|  | 45 |  | 
| Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 46 | return RUN_ALL_TESTS(); | 
|  | 47 | } |