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

Side by Side Diff: chrome/test/nacl/nacl_browsertest.cc

Issue 212103002: Check NaCl debug mask (not just flag) before choosing PNaCl debug URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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 | Annotate | Revision Log
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 <stdio.h> 5 #include <stdio.h>
6 #if defined(OS_POSIX) 6 #if defined(OS_POSIX)
7 #include <unistd.h> 7 #include <unistd.h>
8 #elif defined(OS_WIN) 8 #elif defined(OS_WIN)
9 #include <windows.h> 9 #include <windows.h>
10 #endif 10 #endif
11 11
12 #define TELEMETRY 1 12 #define TELEMETRY 1
13 13
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/environment.h" 15 #include "base/environment.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/process/kill.h"
18 #include "base/process/launch.h"
19 #include "base/strings/string_number_conversions.h"
17 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
18 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/nacl/nacl_browsertest_util.h" 22 #include "chrome/test/nacl/nacl_browsertest_util.h"
23 #include "components/nacl/browser/nacl_browser.h"
20 #include "components/nacl/common/nacl_switches.h" 24 #include "components/nacl/common/nacl_switches.h"
21 #include "content/public/common/content_switches.h" 25 #include "content/public/common/content_switches.h"
22 26
23 namespace { 27 namespace {
24 28
25 #if defined(OS_WIN) 29 #if defined(OS_WIN)
26 // crbug.com/98721 30 // crbug.com/98721
27 # define MAYBE_Crash DISABLED_Crash 31 # define MAYBE_Crash DISABLED_Crash
28 # define MAYBE_SysconfNprocessorsOnln DISABLED_SysconfNprocessorsOnln 32 # define MAYBE_SysconfNprocessorsOnln DISABLED_SysconfNprocessorsOnln
29 #else 33 #else
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 198 }
195 199
196 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, CORSNoCookie) { 200 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, CORSNoCookie) {
197 RunLoadTest(FILE_PATH_LITERAL("cross_origin/cors_no_cookie.html")); 201 RunLoadTest(FILE_PATH_LITERAL("cross_origin/cors_no_cookie.html"));
198 } 202 }
199 203
200 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, RelativeManifest) { 204 IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, RelativeManifest) {
201 RunLoadTest(FILE_PATH_LITERAL("manifest/relative_manifest.html")); 205 RunLoadTest(FILE_PATH_LITERAL("manifest/relative_manifest.html"));
202 } 206 }
203 207
204 class NaClBrowserTestPnaclDebugURL : public NaClBrowserTestPnacl { 208 // Test with the NaCl debug flag turned on.
209 class NaClBrowserTestPnaclDebug : public NaClBrowserTestPnacl {
205 public: 210 public:
206 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 211 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
207 NaClBrowserTestPnacl::SetUpCommandLine(command_line); 212 NaClBrowserTestPnacl::SetUpCommandLine(command_line);
208 // Turn on debugging to influence the PNaCl URL loaded 213 // Turn on debugging to influence the PNaCl URL loaded
209 command_line->AppendSwitch(switches::kEnableNaClDebug); 214 command_line->AppendSwitch(switches::kEnableNaClDebug);
210 // On windows, the debug stub requires --no-sandbox: 215 // On windows, the debug stub requires --no-sandbox:
211 // crbug.com/265624 216 // crbug.com/265624
212 #if defined(OS_WIN) 217 #if defined(OS_WIN)
213 command_line->AppendSwitch(switches::kNoSandbox); 218 command_line->AppendSwitch(switches::kNoSandbox);
214 #endif 219 #endif
215 // Don't actually debug the app though. 220 }
221
222 // On some platforms this test does not work.
223 bool TestIsBroken() {
224 // TODO(jvoung): Make this test work on Windows 32-bit. When --no-sandbox
225 // is used, the required 1GB sandbox address space is not reserved.
226 // (see note in chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc)
227 #if defined(OS_WIN)
228 if (base::win::OSInfo::GetInstance()->wow64_status() ==
229 base::win::OSInfo::WOW64_DISABLED &&
230 base::win::OSInfo::GetInstance()->architecture() ==
231 base::win::OSInfo::X86_ARCHITECTURE) {
232 return true;
233 }
234 #endif
235 return false;
236 }
237
238 void StartTestScript(base::ProcessHandle* test_process,
239 int debug_stub_port) {
240 // We call a python script that speaks to the debug stub, and
241 // lets the app continue, so that the load progress event completes.
242 CommandLine cmd(base::FilePath(FILE_PATH_LITERAL("python")));
243 base::FilePath script;
244 PathService::Get(base::DIR_SOURCE_ROOT, &script);
245 script = script.AppendASCII(
246 "chrome/browser/nacl_host/test/debug_stub_browser_tests.py");
247 cmd.AppendArgPath(script);
248 cmd.AppendArg(base::IntToString(debug_stub_port));
249 cmd.AppendArg("continue");
250 LOG(INFO) << cmd.GetCommandLineString();
251 base::LaunchProcess(cmd, base::LaunchOptions(), test_process);
252 }
253
254 void RunWithTestDebugger(const base::FilePath::StringType& test_url) {
255 base::ProcessHandle test_script;
256 scoped_ptr<base::Environment> env(base::Environment::Create());
257 nacl::NaClBrowser::GetInstance()->SetGdbDebugStubPortListener(
258 base::Bind(&NaClBrowserTestPnaclDebug::StartTestScript,
259 base::Unretained(this), &test_script));
260 // Turn on debug stub logging.
261 env->SetVar("NACLVERBOSITY", "1");
262 RunLoadTest(test_url);
263 env->UnSetVar("NACLVERBOSITY");
264 nacl::NaClBrowser::GetInstance()->ClearGdbDebugStubPortListener();
265 int exit_code;
266 LOG(INFO) << "Waiting for script to exit (which waits for embed to die).";
267 base::WaitForExitCode(test_script, &exit_code);
268 EXPECT_EQ(0, exit_code);
269 }
270 };
271
272 // Test with the NaCl debug flag turned on, but mask off every URL
273 // so that nothing is actually debugged.
274 class NaClBrowserTestPnaclDebugMasked : public NaClBrowserTestPnaclDebug {
275 public:
276 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
277 NaClBrowserTestPnaclDebug::SetUpCommandLine(command_line);
216 command_line->AppendSwitchASCII(switches::kNaClDebugMask, 278 command_line->AppendSwitchASCII(switches::kNaClDebugMask,
217 "!<all_urls>"); 279 "!<all_urls>");
218 } 280 }
219 }; 281 };
220 282
221 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL, 283 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebug,
222 MAYBE_PNACL(PnaclDebugURLFlagAndURL)) { 284 MAYBE_PNACL(PnaclDebugURLFlagAndURL)) {
223 // TODO(jvoung): Make this test work on Windows 32-bit. When --no-sandbox 285 RunWithTestDebugger(FILE_PATH_LITERAL(
224 // is used, the required 1GB sandbox address space is not reserved.
225 // (see note in chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc)
226 #if defined(OS_WIN)
227 if (base::win::OSInfo::GetInstance()->wow64_status() ==
228 base::win::OSInfo::WOW64_DISABLED &&
229 base::win::OSInfo::GetInstance()->architecture() ==
230 base::win::OSInfo::X86_ARCHITECTURE) {
231 return;
232 }
233 #endif
234 RunLoadTest(FILE_PATH_LITERAL(
235 "pnacl_debug_url.html?nmf_file=pnacl_has_debug.nmf")); 286 "pnacl_debug_url.html?nmf_file=pnacl_has_debug.nmf"));
236 } 287 }
237 288
238 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL, 289 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebug,
239 MAYBE_PNACL(PnaclDebugURLFlagNoURL)) { 290 MAYBE_PNACL(PnaclDebugURLFlagNoURL)) {
240 #if defined(OS_WIN) 291 RunWithTestDebugger(FILE_PATH_LITERAL(
241 if (base::win::OSInfo::GetInstance()->wow64_status() ==
242 base::win::OSInfo::WOW64_DISABLED &&
243 base::win::OSInfo::GetInstance()->architecture() ==
244 base::win::OSInfo::X86_ARCHITECTURE) {
245 return;
246 }
247 #endif
248 RunLoadTest(FILE_PATH_LITERAL(
249 "pnacl_debug_url.html?nmf_file=pnacl_no_debug.nmf")); 292 "pnacl_debug_url.html?nmf_file=pnacl_no_debug.nmf"));
250 } 293 }
251 294
252 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, 295 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
253 MAYBE_PNACL(PnaclDebugURLFlagOff)) { 296 MAYBE_PNACL(PnaclDebugURLFlagOff)) {
254 RunLoadTest(FILE_PATH_LITERAL( 297 RunLoadTest(FILE_PATH_LITERAL(
255 "pnacl_debug_url.html?nmf_file=pnacl_has_debug_flag_off.nmf")); 298 "pnacl_debug_url.html?nmf_file=pnacl_has_debug_flag_off.nmf"));
256 } 299 }
257 300
301 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugMasked,
302 MAYBE_PNACL(PnaclDebugURLFlagMaskedOff)) {
303 if (TestIsBroken()) {
304 return;
305 }
306 // If the mask excludes debugging, it's as if the flag was off.
307 RunLoadTest(FILE_PATH_LITERAL(
308 "pnacl_debug_url.html?nmf_file=pnacl_has_debug_flag_off.nmf"));
309 }
310
258 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, 311 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
259 MAYBE_PNACL(PnaclErrorHandling)) { 312 MAYBE_PNACL(PnaclErrorHandling)) {
260 RunNaClIntegrationTest(FILE_PATH_LITERAL("pnacl_error_handling.html")); 313 RunNaClIntegrationTest(FILE_PATH_LITERAL("pnacl_error_handling.html"));
261 } 314 }
262 315
263 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl, 316 IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
264 MAYBE_PNACL(PnaclNMFOptionsO0)) { 317 MAYBE_PNACL(PnaclNMFOptionsO0)) {
265 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0")); 318 RunLoadTest(FILE_PATH_LITERAL("pnacl_options.html?use_nmf=o_0"));
266 } 319 }
267 320
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 426 }
374 }; 427 };
375 428
376 // TODO(ncbray) support glibc and PNaCl 429 // TODO(ncbray) support glibc and PNaCl
377 IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibExtension, MimeHandler) { 430 IN_PROC_BROWSER_TEST_F(NaClBrowserTestNewlibExtension, MimeHandler) {
378 RunNaClIntegrationTest(FILE_PATH_LITERAL( 431 RunNaClIntegrationTest(FILE_PATH_LITERAL(
379 "ppapi_extension_mime_handler.html")); 432 "ppapi_extension_mime_handler.html"));
380 } 433 }
381 434
382 } // namespace 435 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698