Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: sandbox/linux/tests/main.cc

Issue 278583005: Linux Sandbox: Add support for SECCOMP_RET_TRACE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix LOG(FATAL) behavior on Android. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/linux/seccomp-bpf/verifier.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/test/test_suite.h" 7 #include "base/test/test_suite.h"
8 #include "sandbox/linux/tests/test_utils.h" 8 #include "sandbox/linux/tests/test_utils.h"
9 #include "sandbox/linux/tests/unit_tests.h" 9 #include "sandbox/linux/tests/unit_tests.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace sandbox { 12 namespace sandbox {
13 namespace { 13 namespace {
14 14
15 // Check for leaks in our tests. 15 // Check for leaks in our tests.
16 void RunPostTestsChecks() { 16 void RunPostTestsChecks() {
17 if (TestUtils::CurrentProcessHasChildren()) { 17 if (TestUtils::CurrentProcessHasChildren()) {
18 LOG(ERROR) << "One of the tests created a child that was not waited for. " 18 LOG(ERROR) << "One of the tests created a child that was not waited for. "
19 << "Please, clean-up after your tests!"; 19 << "Please, clean-up after your tests!";
20 } 20 }
21 } 21 }
22 22
23 } // namespace 23 } // namespace
24 } // namespace sandbox 24 } // namespace sandbox
25 25
26 #if defined(OS_ANDROID)
27 void UnitTestAssertHandler(const std::string& str) {
28 _exit(1);
29 }
30 #endif
31
26 int main(int argc, char* argv[]) { 32 int main(int argc, char* argv[]) {
27 #if defined(OS_ANDROID) 33 #if defined(OS_ANDROID)
28 // The use of Callbacks requires an AtExitManager. 34 // The use of Callbacks requires an AtExitManager.
29 base::AtExitManager exit_manager; 35 base::AtExitManager exit_manager;
30 testing::InitGoogleTest(&argc, argv); 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);
31 #endif 41 #endif
32 // Always go through re-execution for death tests. 42 // Always go through re-execution for death tests.
33 // This makes gtest only marginally slower for us and has the 43 // This makes gtest only marginally slower for us and has the
34 // additional side effect of getting rid of gtest warnings about fork() 44 // additional side effect of getting rid of gtest warnings about fork()
35 // safety. 45 // safety.
36 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; 46 ::testing::FLAGS_gtest_death_test_style = "threadsafe";
37 #if defined(OS_ANDROID) 47 #if defined(OS_ANDROID)
38 int tests_result = RUN_ALL_TESTS(); 48 int tests_result = RUN_ALL_TESTS();
39 #else 49 #else
40 int tests_result = base::RunUnitTestsUsingBaseTestSuite(argc, argv); 50 int tests_result = base::RunUnitTestsUsingBaseTestSuite(argc, argv);
41 #endif 51 #endif
42 52
43 sandbox::RunPostTestsChecks(); 53 sandbox::RunPostTestsChecks();
44 return tests_result; 54 return tests_result;
45 } 55 }
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/verifier.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698