blob: aa75495628e447d4f66b742339b2ddf393ab27ee [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();
adlr@google.comc98a7ed2009-12-04 18:54:03 +000022 g_thread_init(NULL);
Andrew de los Reyesc7020782010-04-28 10:46:04 -070023 dbus_g_thread_init();
Darin Petkov5c0a8af2010-08-24 13:39:13 -070024 base::AtExitManager exit_manager;
Gilad Arnold0b4a6ff2012-04-30 13:13:03 -070025 // 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.comc98a7ed2009-12-04 18:54:03 +000031 chromeos_update_engine::Subprocess::Init();
Gilad Arnoldfc359292012-04-30 22:04:24 -070032 LOG(INFO) << "parsing command line arguments";
Andrew de los Reyesc7020782010-04-28 10:46:04 -070033 CommandLine::Init(argc, argv);
Gilad Arnoldfc359292012-04-30 22:04:24 -070034 LOG(INFO) << "initializing gtest";
rspangler@google.com49fdf182009-10-10 00:57:34 +000035 ::testing::InitGoogleTest(&argc, argv);
Gilad Arnoldfc359292012-04-30 22:04:24 -070036 LOG(INFO) << "running unit tests";
Gilad Arnoldfaac2a52012-04-26 14:44:17 -070037 int test_result = RUN_ALL_TESTS();
38 LOG(INFO) << "unittest return value: " << test_result;
39 return test_result;
rspangler@google.com49fdf182009-10-10 00:57:34 +000040}