OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/public/test/content_browser_test.h" | 5 #include "content/public/test/content_browser_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/process/launch.h" | 9 #include "base/process/launch.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir; | 83 base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir; |
84 base::ScopedTempDir temp_dir; | 84 base::ScopedTempDir temp_dir; |
85 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 85 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
86 base::CommandLine new_test = | 86 base::CommandLine new_test = |
87 base::CommandLine(base::CommandLine::ForCurrentProcess()->GetProgram()); | 87 base::CommandLine(base::CommandLine::ForCurrentProcess()->GetProgram()); |
88 new_test.AppendSwitchASCII(base::kGTestFilterFlag, | 88 new_test.AppendSwitchASCII(base::kGTestFilterFlag, |
89 "ContentBrowserTest.MANUAL_RendererCrash"); | 89 "ContentBrowserTest.MANUAL_RendererCrash"); |
90 new_test.AppendSwitch(kRunManualTestsFlag); | 90 new_test.AppendSwitch(kRunManualTestsFlag); |
91 new_test.AppendSwitch(kSingleProcessTestsFlag); | 91 new_test.AppendSwitch(kSingleProcessTestsFlag); |
92 | 92 |
93 // Per https://www.chromium.org/developers/testing/addresssanitizer, there are | |
94 // ASAN bots that run without the sandbox which this test will pass for. The | |
95 // other ones pipe the output to a symbolizer script. | |
96 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoSandbox)) { | |
97 new_test.AppendSwitch(switches::kNoSandbox); | |
98 } else { | |
99 #if defined(ADDRESS_SANITIZER) | |
100 LOG(INFO) << "Couldn't run ContentBrowserTest.RendererCrashCallStack since " | |
101 << "sandbox is enabled and ASAN requires piping to an external " | |
102 << "script."; | |
103 return; | |
104 #endif | |
105 } | |
106 | |
107 std::string output; | 93 std::string output; |
108 base::GetAppOutputAndError(new_test, &output); | 94 base::GetAppOutputAndError(new_test, &output); |
109 | 95 |
| 96 // In sanitizer builds, an external script is responsible for symbolizing, |
| 97 // so the stack that the tests sees here looks like: |
| 98 // "#0 0x0000007ea911 (...content_browsertests+0x7ea910)" |
110 std::string crash_string = | 99 std::string crash_string = |
| 100 #if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \ |
| 101 !defined(MEMORY_SANITIZER) && !defined(THREAD_SANITIZER) |
111 "content::RenderFrameImpl::PrepareRenderViewForNavigation"; | 102 "content::RenderFrameImpl::PrepareRenderViewForNavigation"; |
| 103 #else |
| 104 "#0 "; |
| 105 #endif |
112 | 106 |
113 if (output.find(crash_string) == std::string::npos) { | 107 if (output.find(crash_string) == std::string::npos) { |
114 GTEST_FAIL() << "Couldn't find\n" << crash_string << "\n in output\n " | 108 GTEST_FAIL() << "Couldn't find\n" << crash_string << "\n in output\n " |
115 << output; | 109 << output; |
116 } | 110 } |
117 } | 111 } |
118 | 112 |
119 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, MANUAL_BrowserCrash) { | 113 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, MANUAL_BrowserCrash) { |
120 CHECK(false); | 114 CHECK(false); |
121 } | 115 } |
122 | 116 |
123 // Tests that browser tests print the callstack on asserts. | 117 // Tests that browser tests print the callstack on asserts. |
124 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, BrowserCrashCallStack) { | 118 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, BrowserCrashCallStack) { |
125 base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir; | 119 base::ThreadRestrictions::ScopedAllowIO allow_io_for_temp_dir; |
126 base::ScopedTempDir temp_dir; | 120 base::ScopedTempDir temp_dir; |
127 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 121 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
128 base::CommandLine new_test = | 122 base::CommandLine new_test = |
129 base::CommandLine(base::CommandLine::ForCurrentProcess()->GetProgram()); | 123 base::CommandLine(base::CommandLine::ForCurrentProcess()->GetProgram()); |
130 new_test.AppendSwitchASCII(base::kGTestFilterFlag, | 124 new_test.AppendSwitchASCII(base::kGTestFilterFlag, |
131 "ContentBrowserTest.MANUAL_BrowserCrash"); | 125 "ContentBrowserTest.MANUAL_BrowserCrash"); |
132 new_test.AppendSwitch(kRunManualTestsFlag); | 126 new_test.AppendSwitch(kRunManualTestsFlag); |
133 new_test.AppendSwitch(kSingleProcessTestsFlag); | 127 new_test.AppendSwitch(kSingleProcessTestsFlag); |
134 std::string output; | 128 std::string output; |
135 base::GetAppOutputAndError(new_test, &output); | 129 base::GetAppOutputAndError(new_test, &output); |
136 | 130 |
| 131 // In sanitizer builds, an external script is responsible for symbolizing, |
| 132 // so the stack that the test sees here looks like: |
| 133 // "#0 0x0000007ea911 (...content_browsertests+0x7ea910)" |
137 std::string crash_string = | 134 std::string crash_string = |
138 "content::ContentBrowserTest_MANUAL_BrowserCrash_Test::RunTestOnMainThread
"; | 135 #if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && \ |
| 136 !defined(MEMORY_SANITIZER) && !defined(THREAD_SANITIZER) |
| 137 "content::ContentBrowserTest_MANUAL_BrowserCrash_Test::" |
| 138 "RunTestOnMainThread"; |
| 139 #else |
| 140 "#0 "; |
| 141 #endif |
139 | 142 |
140 if (output.find(crash_string) == std::string::npos) { | 143 if (output.find(crash_string) == std::string::npos) { |
141 GTEST_FAIL() << "Couldn't find\n" << crash_string << "\n in output\n " | 144 GTEST_FAIL() << "Couldn't find\n" << crash_string << "\n in output\n " |
142 << output; | 145 << output; |
143 } | 146 } |
144 } | 147 } |
145 | 148 |
146 #endif | 149 #endif |
147 | 150 |
148 class ContentBrowserTestSanityTest : public ContentBrowserTest { | 151 class ContentBrowserTestSanityTest : public ContentBrowserTest { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 186 |
184 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, NonNestableTask) { | 187 IN_PROC_BROWSER_TEST_F(ContentBrowserTest, NonNestableTask) { |
185 bool non_nested_task_ran = false; | 188 bool non_nested_task_ran = false; |
186 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( | 189 base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( |
187 FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran)); | 190 FROM_HERE, base::Bind(&CallbackChecker, &non_nested_task_ran)); |
188 content::RunAllPendingInMessageLoop(); | 191 content::RunAllPendingInMessageLoop(); |
189 ASSERT_TRUE(non_nested_task_ran); | 192 ASSERT_TRUE(non_nested_task_ran); |
190 } | 193 } |
191 | 194 |
192 } // namespace content | 195 } // namespace content |
OLD | NEW |