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

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

Issue 881733002: Add namespace sandbox class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Last round of comments. Created 5 years, 10 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/services/namespace_utils_unittest.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/base_switches.h"
7 #include "base/command_line.h"
6 #include "base/logging.h" 8 #include "base/logging.h"
7 #include "base/test/test_suite.h" 9 #include "base/test/test_suite.h"
8 #include "sandbox/linux/tests/test_utils.h" 10 #include "sandbox/linux/tests/test_utils.h"
9 #include "sandbox/linux/tests/unit_tests.h" 11 #include "sandbox/linux/tests/unit_tests.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/multiprocess_func_list.h"
11 14
12 namespace sandbox { 15 namespace sandbox {
13 namespace { 16 namespace {
14 17
15 // Check for leaks in our tests. 18 // Check for leaks in our tests.
16 void RunPostTestsChecks() { 19 void RunPostTestsChecks() {
17 if (TestUtils::CurrentProcessHasChildren()) { 20 if (TestUtils::CurrentProcessHasChildren()) {
18 LOG(ERROR) << "One of the tests created a child that was not waited for. " 21 LOG(ERROR) << "One of the tests created a child that was not waited for. "
19 << "Please, clean-up after your tests!"; 22 << "Please, clean-up after your tests!";
20 } 23 }
21 } 24 }
22 25
23 } // namespace 26 } // namespace
24 } // namespace sandbox 27 } // namespace sandbox
25 28
26 #if defined(OS_ANDROID) 29 #if defined(OS_ANDROID)
27 void UnitTestAssertHandler(const std::string& str) { 30 void UnitTestAssertHandler(const std::string& str) {
28 _exit(1); 31 _exit(1);
29 } 32 }
30 #endif 33 #endif
31 34
32 int main(int argc, char* argv[]) { 35 int main(int argc, char* argv[]) {
36 base::CommandLine::Init(argc, argv);
37 std::string client_func =
38 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
39 switches::kTestChildProcess);
40 if (!client_func.empty()) {
41 base::AtExitManager exit_manager;
42 return multi_process_function_list::InvokeChildProcessTest(client_func);
43 }
44
33 #if defined(OS_ANDROID) 45 #if defined(OS_ANDROID)
34 // The use of Callbacks requires an AtExitManager. 46 // The use of Callbacks requires an AtExitManager.
35 base::AtExitManager exit_manager; 47 base::AtExitManager exit_manager;
36 testing::InitGoogleTest(&argc, argv); 48 testing::InitGoogleTest(&argc, argv);
37 // Death tests rely on LOG(FATAL) triggering an exit (the default behavior is 49 // 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 50 // 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. 51 // we still do not use this on Android, we must install the handler ourselves.
40 logging::SetLogAssertHandler(UnitTestAssertHandler); 52 logging::SetLogAssertHandler(UnitTestAssertHandler);
41 #endif 53 #endif
42 // Always go through re-execution for death tests. 54 // Always go through re-execution for death tests.
43 // This makes gtest only marginally slower for us and has the 55 // This makes gtest only marginally slower for us and has the
44 // additional side effect of getting rid of gtest warnings about fork() 56 // additional side effect of getting rid of gtest warnings about fork()
45 // safety. 57 // safety.
46 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; 58 ::testing::FLAGS_gtest_death_test_style = "threadsafe";
47 #if defined(OS_ANDROID) 59 #if defined(OS_ANDROID)
48 int tests_result = RUN_ALL_TESTS(); 60 int tests_result = RUN_ALL_TESTS();
49 #else 61 #else
50 int tests_result = base::RunUnitTestsUsingBaseTestSuite(argc, argv); 62 int tests_result = base::RunUnitTestsUsingBaseTestSuite(argc, argv);
51 #endif 63 #endif
52 64
53 sandbox::RunPostTestsChecks(); 65 sandbox::RunPostTestsChecks();
54 return tests_result; 66 return tests_result;
55 } 67 }
OLDNEW
« no previous file with comments | « sandbox/linux/services/namespace_utils_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698