Gilad Arnold | 0b4a6ff | 2012-04-30 13:13:03 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // based on pam_google_testrunner.cc |
| 6 | |
Darin Petkov | 9c0baf8 | 2010-10-07 13:44:48 -0700 | [diff] [blame] | 7 | #include <base/at_exit.h> |
| 8 | #include <base/command_line.h> |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 9 | #include <dbus/dbus-glib.h> |
| 10 | #include <dbus/dbus-glib-bindings.h> |
| 11 | #include <dbus/dbus-glib-lowlevel.h> |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 12 | #include <glib.h> |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 13 | #include <glib-object.h> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 14 | #include <gtest/gtest.h> |
Darin Petkov | 9c0baf8 | 2010-10-07 13:44:48 -0700 | [diff] [blame] | 15 | |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 16 | #include "update_engine/subprocess.h" |
Darin Petkov | 9c0baf8 | 2010-10-07 13:44:48 -0700 | [diff] [blame] | 17 | #include "update_engine/terminator.h" |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 18 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 19 | int main(int argc, char **argv) { |
Gilad Arnold | fc35929 | 2012-04-30 22:04:24 -0700 | [diff] [blame^] | 20 | LOG(INFO) << "started"; |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 21 | ::g_type_init(); |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 22 | g_thread_init(NULL); |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 23 | dbus_g_thread_init(); |
Darin Petkov | 5c0a8af | 2010-08-24 13:39:13 -0700 | [diff] [blame] | 24 | base::AtExitManager exit_manager; |
Gilad Arnold | 0b4a6ff | 2012-04-30 13:13:03 -0700 | [diff] [blame] | 25 | // TODO(garnold) temporarily cause the unittest binary to exit with status |
| 26 | // code 2 upon catching a SIGTERM. This will help diagnose why the unittest |
| 27 | // binary is perceived as failing by the buildbot. We should revert it to use |
| 28 | // the default exit status of 1. Corresponding reverts are necessary in |
| 29 | // terminator_unittest.cc. |
| 30 | chromeos_update_engine::Terminator::Init(2); |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 31 | chromeos_update_engine::Subprocess::Init(); |
Gilad Arnold | fc35929 | 2012-04-30 22:04:24 -0700 | [diff] [blame^] | 32 | LOG(INFO) << "parsing command line arguments"; |
Andrew de los Reyes | c702078 | 2010-04-28 10:46:04 -0700 | [diff] [blame] | 33 | CommandLine::Init(argc, argv); |
Gilad Arnold | fc35929 | 2012-04-30 22:04:24 -0700 | [diff] [blame^] | 34 | LOG(INFO) << "initializing gtest"; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 35 | ::testing::InitGoogleTest(&argc, argv); |
Gilad Arnold | fc35929 | 2012-04-30 22:04:24 -0700 | [diff] [blame^] | 36 | LOG(INFO) << "running unit tests"; |
Gilad Arnold | faac2a5 | 2012-04-26 14:44:17 -0700 | [diff] [blame] | 37 | int test_result = RUN_ALL_TESTS(); |
| 38 | LOG(INFO) << "unittest return value: " << test_result; |
| 39 | return test_result; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 40 | } |