butil_unittest_main.cpp 1.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.
gejun's avatar
gejun committed
17 18 19 20

#include <sys/resource.h>
#include <gtest/gtest.h>
#include <gflags/gflags.h>
21
#include "butil/at_exit.h"
22
#include "butil/logging.h"
23
#include "multiprocess_func_list.h"
gejun's avatar
gejun committed
24

25
DEFINE_bool(disable_coredump, false, "Never core dump");
gejun's avatar
gejun committed
26 27

int main(int argc, char** argv) {
28
    butil::AtExitManager at_exit;
gejun's avatar
gejun committed
29 30
    testing::InitGoogleTest(&argc, argv);
    
31
    GFLAGS_NS::ParseCommandLineFlags(&argc, &argv, true);
gejun's avatar
gejun committed
32 33 34 35 36 37
    if (FLAGS_disable_coredump) {
        rlimit core_limit;
        core_limit.rlim_cur = 0;
        core_limit.rlim_max = 0;
        setrlimit(RLIMIT_CORE, &core_limit);
    }
38
#if !BRPC_WITH_GLOG
39
    CHECK(!GFLAGS_NS::SetCommandLineOption("crash_on_fatal_log", "true").empty());
40
#endif
gejun's avatar
gejun committed
41 42
    return RUN_ALL_TESTS();
}