Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 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 | // |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 16 | |
| 17 | // based on pam_google_testrunner.cc |
| 18 | |
Alex Deymo | 2e71f90 | 2015-09-30 01:25:48 -0700 | [diff] [blame] | 19 | #include <xz.h> |
| 20 | |
Darin Petkov | 9c0baf8 | 2010-10-07 13:44:48 -0700 | [diff] [blame] | 21 | #include <base/at_exit.h> |
| 22 | #include <base/command_line.h> |
Alex Vakulenko | 3f39d5c | 2015-10-13 09:27:13 -0700 | [diff] [blame] | 23 | #include <brillo/test_helpers.h> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 24 | #include <gtest/gtest.h> |
Darin Petkov | 9c0baf8 | 2010-10-07 13:44:48 -0700 | [diff] [blame] | 25 | |
Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame^] | 26 | #include "update_engine/common/terminator.h" |
adlr@google.com | c98a7ed | 2009-12-04 18:54:03 +0000 | [diff] [blame] | 27 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 28 | int main(int argc, char **argv) { |
Gilad Arnold | fc35929 | 2012-04-30 22:04:24 -0700 | [diff] [blame] | 29 | LOG(INFO) << "started"; |
Darin Petkov | 5c0a8af | 2010-08-24 13:39:13 -0700 | [diff] [blame] | 30 | base::AtExitManager exit_manager; |
Alex Deymo | 2e71f90 | 2015-09-30 01:25:48 -0700 | [diff] [blame] | 31 | // xz-embedded requires to initialize its CRC-32 table once on startup. |
| 32 | xz_crc32_init(); |
Gilad Arnold | 0b4a6ff | 2012-04-30 13:13:03 -0700 | [diff] [blame] | 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); |
Gilad Arnold | fc35929 | 2012-04-30 22:04:24 -0700 | [diff] [blame] | 39 | LOG(INFO) << "parsing command line arguments"; |
Alex Vakulenko | b96ecda | 2015-04-02 14:31:10 -0700 | [diff] [blame] | 40 | base::CommandLine::Init(argc, argv); |
Gilad Arnold | fc35929 | 2012-04-30 22:04:24 -0700 | [diff] [blame] | 41 | LOG(INFO) << "initializing gtest"; |
Alex Deymo | 0bb2341 | 2015-06-19 00:04:46 -0700 | [diff] [blame] | 42 | SetUpTests(&argc, argv, true); |
Gilad Arnold | fc35929 | 2012-04-30 22:04:24 -0700 | [diff] [blame] | 43 | LOG(INFO) << "running unit tests"; |
Gilad Arnold | faac2a5 | 2012-04-26 14:44:17 -0700 | [diff] [blame] | 44 | int test_result = RUN_ALL_TESTS(); |
| 45 | LOG(INFO) << "unittest return value: " << test_result; |
| 46 | return test_result; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 47 | } |