blob: 4786c74a89b8fafde5c8682a6417d19ef7a40709 [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>
Alex Deymo0bb23412015-06-19 00:04:46 -07009#include <chromeos/test_helpers.h>
Andrew de los Reyesc7020782010-04-28 10:46:04 -070010#include <dbus/dbus-glib.h>
11#include <dbus/dbus-glib-bindings.h>
12#include <dbus/dbus-glib-lowlevel.h>
adlr@google.comc98a7ed2009-12-04 18:54:03 +000013#include <glib.h>
Andrew de los Reyesc7020782010-04-28 10:46:04 -070014#include <glib-object.h>
rspangler@google.com49fdf182009-10-10 00:57:34 +000015#include <gtest/gtest.h>
Darin Petkov9c0baf82010-10-07 13:44:48 -070016
adlr@google.comc98a7ed2009-12-04 18:54:03 +000017#include "update_engine/subprocess.h"
Darin Petkov9c0baf82010-10-07 13:44:48 -070018#include "update_engine/terminator.h"
adlr@google.comc98a7ed2009-12-04 18:54:03 +000019
rspangler@google.com49fdf182009-10-10 00:57:34 +000020int main(int argc, char **argv) {
Gilad Arnoldfc359292012-04-30 22:04:24 -070021 LOG(INFO) << "started";
Andrew de los Reyesc7020782010-04-28 10:46:04 -070022 ::g_type_init();
Ben Chan46bf5c82013-06-24 11:17:41 -070023 dbus_threads_init_default();
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";
Alex Vakulenkob96ecda2015-04-02 14:31:10 -070033 base::CommandLine::Init(argc, argv);
Gilad Arnoldfc359292012-04-30 22:04:24 -070034 LOG(INFO) << "initializing gtest";
Alex Deymo0bb23412015-06-19 00:04:46 -070035 SetUpTests(&argc, argv, true);
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}