blob: d42ef078a595b15e163dbe277d917eecfe1cfaf7 [file] [log] [blame]
Paul Stewart75897df2011-04-27 09:05:53 -07001// 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 Masone0e1d1042011-05-09 18:07:03 -07005#include <base/at_exit.h>
Darin Petkov35694152011-08-17 16:55:04 -07006#include <base/command_line.h>
7#include <chromeos/syslog_logging.h>
Paul Stewart75897df2011-04-27 09:05:53 -07008#include <gtest/gtest.h>
Paul Stewart75897df2011-04-27 09:05:53 -07009
Peter Qiu40a01482014-10-31 11:54:23 -070010#include "shill/glib_io_handler_factory.h"
Prathmesh Prabhuf002cdb2014-09-17 22:41:05 -070011#include "shill/logging.h"
Peter Qiu40a01482014-10-31 11:54:23 -070012#include "shill/net/io_handler_factory_container.h"
Prathmesh Prabhuf002cdb2014-09-17 22:41:05 -070013
14namespace switches {
15
16static const char kHelp[] = "help";
17
18static 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 Stewart75897df2011-04-27 09:05:53 -070029int main(int argc, char** argv) {
Chris Masone0e1d1042011-05-09 18:07:03 -070030 base::AtExitManager exit_manager;
Alex Vakulenko127f2562015-04-02 14:31:10 -070031 base::CommandLine::Init(argc, argv);
Paul Stewart1a212a62015-06-16 13:13:10 -070032 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
Darin Petkov35694152011-08-17 16:55:04 -070033 chromeos::InitLog(chromeos::kLogToStderr);
Prathmesh Prabhuf002cdb2014-09-17 22:41:05 -070034 shill::SetLogLevelFromCommandLine(cl);
Paul Stewart75897df2011-04-27 09:05:53 -070035 ::testing::InitGoogleTest(&argc, argv);
Prathmesh Prabhuf002cdb2014-09-17 22:41:05 -070036
37 if (cl->HasSwitch(switches::kHelp)) {
38 std::cerr << switches::kHelpMessage;
39 }
Peter Qiu40a01482014-10-31 11:54:23 -070040
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 Stewart75897df2011-04-27 09:05:53 -070046 return RUN_ALL_TESTS();
47}