blob: 139de7515f96b984faa0411990bc00a4899b06fe [file] [log] [blame]
Gilad Arnold0b4a6ff2012-04-30 13:13:03 -07001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
rspangler@google.com49fdf182009-10-10 00:57:34 +00002// 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 Petkov9c0baf82010-10-07 13:44:48 -07007#include <base/at_exit.h>
8#include <base/command_line.h>
Andrew de los Reyesc7020782010-04-28 10:46:04 -07009#include <dbus/dbus-glib.h>
10#include <dbus/dbus-glib-bindings.h>
11#include <dbus/dbus-glib-lowlevel.h>
adlr@google.comc98a7ed2009-12-04 18:54:03 +000012#include <glib.h>
Andrew de los Reyesc7020782010-04-28 10:46:04 -070013#include <glib-object.h>
rspangler@google.com49fdf182009-10-10 00:57:34 +000014#include <gtest/gtest.h>
Darin Petkov9c0baf82010-10-07 13:44:48 -070015
adlr@google.comc98a7ed2009-12-04 18:54:03 +000016#include "update_engine/subprocess.h"
Darin Petkov9c0baf82010-10-07 13:44:48 -070017#include "update_engine/terminator.h"
adlr@google.comc98a7ed2009-12-04 18:54:03 +000018
rspangler@google.com49fdf182009-10-10 00:57:34 +000019int main(int argc, char **argv) {
Gilad Arnoldfc359292012-04-30 22:04:24 -070020 LOG(INFO) << "started";
Andrew de los Reyesc7020782010-04-28 10:46:04 -070021 ::g_type_init();
Ben Chan46bf5c82013-06-24 11:17:41 -070022 dbus_threads_init_default();
Darin Petkov5c0a8af2010-08-24 13:39:13 -070023 base::AtExitManager exit_manager;
Gilad Arnold0b4a6ff2012-04-30 13:13:03 -070024 // TODO(garnold) temporarily cause the unittest binary to exit with status
25 // code 2 upon catching a SIGTERM. This will help diagnose why the unittest
26 // binary is perceived as failing by the buildbot. We should revert it to use
27 // the default exit status of 1. Corresponding reverts are necessary in
28 // terminator_unittest.cc.
29 chromeos_update_engine::Terminator::Init(2);
adlr@google.comc98a7ed2009-12-04 18:54:03 +000030 chromeos_update_engine::Subprocess::Init();
Gilad Arnoldfc359292012-04-30 22:04:24 -070031 LOG(INFO) << "parsing command line arguments";
Andrew de los Reyesc7020782010-04-28 10:46:04 -070032 CommandLine::Init(argc, argv);
Gilad Arnoldfc359292012-04-30 22:04:24 -070033 LOG(INFO) << "initializing gtest";
rspangler@google.com49fdf182009-10-10 00:57:34 +000034 ::testing::InitGoogleTest(&argc, argv);
Gilad Arnoldfc359292012-04-30 22:04:24 -070035 LOG(INFO) << "running unit tests";
Gilad Arnoldfaac2a52012-04-26 14:44:17 -070036 int test_result = RUN_ALL_TESTS();
37 LOG(INFO) << "unittest return value: " << test_result;
38 return test_result;
rspangler@google.com49fdf182009-10-10 00:57:34 +000039}