1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/at_exit.h"
6 #include "base/logging.h"
7 #include "base/test/test_suite.h"
8 #include "sandbox/linux/tests/test_utils.h"
9 #include "sandbox/linux/tests/unit_tests.h"
10 #include "testing/gtest/include/gtest/gtest.h"
15 // Check for leaks in our tests.
16 void RunPostTestsChecks() {
17 if (TestUtils::CurrentProcessHasChildren()) {
18 LOG(ERROR
) << "One of the tests created a child that was not waited for. "
19 << "Please, clean-up after your tests!";
24 } // namespace sandbox
26 #if defined(OS_ANDROID)
27 void UnitTestAssertHandler(const std::string
& str
) {
32 int main(int argc
, char* argv
[]) {
33 #if defined(OS_ANDROID)
34 // The use of Callbacks requires an AtExitManager.
35 base::AtExitManager exit_manager
;
36 testing::InitGoogleTest(&argc
, argv
);
37 // Death tests rely on LOG(FATAL) triggering an exit (the default behavior is
38 // SIGABRT). The normal test launcher does this at initialization, but since
39 // we still do not use this on Android, we must install the handler ourselves.
40 logging::SetLogAssertHandler(UnitTestAssertHandler
);
42 // Always go through re-execution for death tests.
43 // This makes gtest only marginally slower for us and has the
44 // additional side effect of getting rid of gtest warnings about fork()
46 ::testing::FLAGS_gtest_death_test_style
= "threadsafe";
47 #if defined(OS_ANDROID)
48 int tests_result
= RUN_ALL_TESTS();
50 int tests_result
= base::RunUnitTestsUsingBaseTestSuite(argc
, argv
);
53 sandbox::RunPostTestsChecks();