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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/nacl/nacl_browsertest.cc
diff --git a/chrome/test/nacl/nacl_browsertest.cc b/chrome/test/nacl/nacl_browsertest.cc
index fbd0536cc1f61b256fa15a72add75da94dea9a64..8f3c2dbd8542cf11ef83cbaca6b1ecc43b52eac4 100644
--- a/chrome/test/nacl/nacl_browsertest.cc
+++ b/chrome/test/nacl/nacl_browsertest.cc
@@ -14,9 +14,13 @@
#include "base/command_line.h"
#include "base/environment.h"
#include "base/path_service.h"
+#include "base/process/kill.h"
+#include "base/process/launch.h"
+#include "base/strings/string_number_conversions.h"
#include "base/win/windows_version.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/nacl/nacl_browsertest_util.h"
+#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/common/nacl_switches.h"
#include "content/public/common/content_switches.h"
@@ -201,7 +205,8 @@ IN_PROC_BROWSER_TEST_F(NaClBrowserTestStatic, RelativeManifest) {
RunLoadTest(FILE_PATH_LITERAL("manifest/relative_manifest.html"));
}
-class NaClBrowserTestPnaclDebugURL : public NaClBrowserTestPnacl {
+// Test with the NaCl debug flag turned on.
+class NaClBrowserTestPnaclDebug : public NaClBrowserTestPnacl {
public:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
NaClBrowserTestPnacl::SetUpCommandLine(command_line);
@@ -212,40 +217,78 @@ class NaClBrowserTestPnaclDebugURL : public NaClBrowserTestPnacl {
#if defined(OS_WIN)
command_line->AppendSwitch(switches::kNoSandbox);
#endif
- // Don't actually debug the app though.
+ }
+
+ // On some platforms this test does not work.
+ bool TestIsBroken() {
+ // TODO(jvoung): Make this test work on Windows 32-bit. When --no-sandbox
+ // is used, the required 1GB sandbox address space is not reserved.
+ // (see note in chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc)
+#if defined(OS_WIN)
+ if (base::win::OSInfo::GetInstance()->wow64_status() ==
+ base::win::OSInfo::WOW64_DISABLED &&
+ base::win::OSInfo::GetInstance()->architecture() ==
+ base::win::OSInfo::X86_ARCHITECTURE) {
+ return true;
+ }
+#endif
+ return false;
+ }
+
+ void StartTestScript(base::ProcessHandle* test_process,
+ int debug_stub_port) {
+ // We call a python script that speaks to the debug stub, and
+ // lets the app continue, so that the load progress event completes.
+ CommandLine cmd(base::FilePath(FILE_PATH_LITERAL("python")));
+ base::FilePath script;
+ PathService::Get(base::DIR_SOURCE_ROOT, &script);
+ script = script.AppendASCII(
+ "chrome/browser/nacl_host/test/debug_stub_browser_tests.py");
+ cmd.AppendArgPath(script);
+ cmd.AppendArg(base::IntToString(debug_stub_port));
+ cmd.AppendArg("continue");
+ LOG(INFO) << cmd.GetCommandLineString();
+ base::LaunchProcess(cmd, base::LaunchOptions(), test_process);
+ }
+
+ void RunWithTestDebugger(const base::FilePath::StringType& test_url) {
+ base::ProcessHandle test_script;
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ nacl::NaClBrowser::GetInstance()->SetGdbDebugStubPortListener(
+ base::Bind(&NaClBrowserTestPnaclDebug::StartTestScript,
+ base::Unretained(this), &test_script));
+ // Turn on debug stub logging.
+ env->SetVar("NACLVERBOSITY", "1");
+ RunLoadTest(test_url);
+ env->UnSetVar("NACLVERBOSITY");
+ nacl::NaClBrowser::GetInstance()->ClearGdbDebugStubPortListener();
+ int exit_code;
+ LOG(INFO) << "Waiting for script to exit (which waits for embed to die).";
+ base::WaitForExitCode(test_script, &exit_code);
+ EXPECT_EQ(0, exit_code);
+ }
+};
+
+// Test with the NaCl debug flag turned on, but mask off every URL
+// so that nothing is actually debugged.
+class NaClBrowserTestPnaclDebugMasked : public NaClBrowserTestPnaclDebug {
+ public:
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ NaClBrowserTestPnaclDebug::SetUpCommandLine(command_line);
command_line->AppendSwitchASCII(switches::kNaClDebugMask,
"!<all_urls>");
}
};
-IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL,
+IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebug,
MAYBE_PNACL(PnaclDebugURLFlagAndURL)) {
- // TODO(jvoung): Make this test work on Windows 32-bit. When --no-sandbox
- // is used, the required 1GB sandbox address space is not reserved.
- // (see note in chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc)
-#if defined(OS_WIN)
- if (base::win::OSInfo::GetInstance()->wow64_status() ==
- base::win::OSInfo::WOW64_DISABLED &&
- base::win::OSInfo::GetInstance()->architecture() ==
- base::win::OSInfo::X86_ARCHITECTURE) {
- return;
- }
-#endif
- RunLoadTest(FILE_PATH_LITERAL(
+ RunWithTestDebugger(FILE_PATH_LITERAL(
"pnacl_debug_url.html?nmf_file=pnacl_has_debug.nmf"));
}
-IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugURL,
+IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebug,
MAYBE_PNACL(PnaclDebugURLFlagNoURL)) {
-#if defined(OS_WIN)
- if (base::win::OSInfo::GetInstance()->wow64_status() ==
- base::win::OSInfo::WOW64_DISABLED &&
- base::win::OSInfo::GetInstance()->architecture() ==
- base::win::OSInfo::X86_ARCHITECTURE) {
- return;
- }
-#endif
- RunLoadTest(FILE_PATH_LITERAL(
+ RunWithTestDebugger(FILE_PATH_LITERAL(
"pnacl_debug_url.html?nmf_file=pnacl_no_debug.nmf"));
}
@@ -255,6 +298,16 @@ IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
"pnacl_debug_url.html?nmf_file=pnacl_has_debug_flag_off.nmf"));
}
+IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnaclDebugMasked,
+ MAYBE_PNACL(PnaclDebugURLFlagMaskedOff)) {
+ if (TestIsBroken()) {
+ return;
+ }
+ // If the mask excludes debugging, it's as if the flag was off.
+ RunLoadTest(FILE_PATH_LITERAL(
+ "pnacl_debug_url.html?nmf_file=pnacl_has_debug_flag_off.nmf"));
+}
+
IN_PROC_BROWSER_TEST_F(NaClBrowserTestPnacl,
MAYBE_PNACL(PnaclErrorHandling)) {
RunNaClIntegrationTest(FILE_PATH_LITERAL("pnacl_error_handling.html"));

Powered by Google App Engine
This is Rietveld 408576698