blob: db0b347abf8e01a4c0d6e28b3e87b13e629cf083 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
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.com49fdf182009-10-10 00:57:34 +000016
17// based on pam_google_testrunner.cc
18
Alex Deymo2e71f902015-09-30 01:25:48 -070019#include <xz.h>
20
Darin Petkov9c0baf82010-10-07 13:44:48 -070021#include <base/at_exit.h>
22#include <base/command_line.h>
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070023#include <brillo/test_helpers.h>
rspangler@google.com49fdf182009-10-10 00:57:34 +000024#include <gtest/gtest.h>
Darin Petkov9c0baf82010-10-07 13:44:48 -070025
Alex Deymo39910dc2015-11-09 17:04:30 -080026#include "update_engine/common/terminator.h"
Alex Deymo246bf212016-03-22 19:27:33 -070027#include "update_engine/payload_generator/xz.h"
adlr@google.comc98a7ed2009-12-04 18:54:03 +000028
Amin Hassani7cc8bb02019-01-14 16:29:47 -080029int main(int argc, char** argv) {
Gilad Arnoldfc359292012-04-30 22:04:24 -070030 LOG(INFO) << "started";
Darin Petkov5c0a8af2010-08-24 13:39:13 -070031 base::AtExitManager exit_manager;
Alex Deymo2e71f902015-09-30 01:25:48 -070032 // xz-embedded requires to initialize its CRC-32 table once on startup.
33 xz_crc32_init();
Alex Deymo246bf212016-03-22 19:27:33 -070034 // The LZMA SDK-based Xz compressor used in the payload generation requires
35 // this one-time initialization.
36 chromeos_update_engine::XzCompressInit();
Gilad Arnold0b4a6ff2012-04-30 13:13:03 -070037 // TODO(garnold) temporarily cause the unittest binary to exit with status
38 // code 2 upon catching a SIGTERM. This will help diagnose why the unittest
39 // binary is perceived as failing by the buildbot. We should revert it to use
40 // the default exit status of 1. Corresponding reverts are necessary in
41 // terminator_unittest.cc.
42 chromeos_update_engine::Terminator::Init(2);
Gilad Arnoldfc359292012-04-30 22:04:24 -070043 LOG(INFO) << "parsing command line arguments";
Alex Vakulenkob96ecda2015-04-02 14:31:10 -070044 base::CommandLine::Init(argc, argv);
Gilad Arnoldfc359292012-04-30 22:04:24 -070045 LOG(INFO) << "initializing gtest";
Alex Deymo0bb23412015-06-19 00:04:46 -070046 SetUpTests(&argc, argv, true);
Sen Jiang26d89772018-03-02 16:37:14 -080047 // Logging to string is not thread safe.
48 brillo::LogToString(false);
Gilad Arnoldfc359292012-04-30 22:04:24 -070049 LOG(INFO) << "running unit tests";
Gilad Arnoldfaac2a52012-04-26 14:44:17 -070050 int test_result = RUN_ALL_TESTS();
51 LOG(INFO) << "unittest return value: " << test_result;
52 return test_result;
rspangler@google.com49fdf182009-10-10 00:57:34 +000053}