testrunner.cc revision 2e71f90d6af955a5359853132085931f1e0479e0
1//
2// Copyright (C) 2012 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17// based on pam_google_testrunner.cc
18
19#include <xz.h>
20
21#include <base/at_exit.h>
22#include <base/command_line.h>
23#include <chromeos/test_helpers.h>
24#include <gtest/gtest.h>
25
26#include "update_engine/terminator.h"
27
28int main(int argc, char **argv) {
29  LOG(INFO) << "started";
30  base::AtExitManager exit_manager;
31  // xz-embedded requires to initialize its CRC-32 table once on startup.
32  xz_crc32_init();
33  // TODO(garnold) temporarily cause the unittest binary to exit with status
34  // code 2 upon catching a SIGTERM. This will help diagnose why the unittest
35  // binary is perceived as failing by the buildbot.  We should revert it to use
36  // the default exit status of 1.  Corresponding reverts are necessary in
37  // terminator_unittest.cc.
38  chromeos_update_engine::Terminator::Init(2);
39  LOG(INFO) << "parsing command line arguments";
40  base::CommandLine::Init(argc, argv);
41  LOG(INFO) << "initializing gtest";
42  SetUpTests(&argc, argv, true);
43  LOG(INFO) << "running unit tests";
44  int test_result = RUN_ALL_TESTS();
45  LOG(INFO) << "unittest return value: " << test_result;
46  return test_result;
47}
48