Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / nacl_host / test / gdb_debug_stub_browsertest.cc
blob32f1a58ba262b3017268a7c02bb2b865a3c66667
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/environment.h"
7 #include "base/path_service.h"
8 #include "base/process/kill.h"
9 #include "base/process/launch.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "chrome/test/ppapi/ppapi_test.h"
12 #include "components/nacl/browser/nacl_browser.h"
13 #include "components/nacl/common/nacl_switches.h"
14 #include "content/public/test/test_utils.h"
16 class NaClGdbDebugStubTest : public PPAPINaClNewlibTest {
17 public:
18 NaClGdbDebugStubTest() {
21 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
23 void StartTestScript(base::ProcessHandle* test_process,
24 std::string test_name, int debug_stub_port);
25 void RunDebugStubTest(const std::string& nacl_module,
26 const std::string& test_name);
29 void NaClGdbDebugStubTest::SetUpCommandLine(CommandLine* command_line) {
30 PPAPINaClNewlibTest::SetUpCommandLine(command_line);
31 command_line->AppendSwitch(switches::kEnableNaClDebug);
34 void NaClGdbDebugStubTest::StartTestScript(base::ProcessHandle* test_process,
35 std::string test_name,
36 int debug_stub_port) {
37 // We call python script to reuse GDB RSP protocol implementation.
38 CommandLine cmd(base::FilePath(FILE_PATH_LITERAL("python")));
39 base::FilePath script;
40 PathService::Get(base::DIR_SOURCE_ROOT, &script);
41 script = script.AppendASCII(
42 "chrome/browser/nacl_host/test/debug_stub_browser_tests.py");
43 cmd.AppendArgPath(script);
44 cmd.AppendArg(base::IntToString(debug_stub_port));
45 cmd.AppendArg(test_name);
46 LOG(INFO) << cmd.GetCommandLineString();
47 base::LaunchProcess(cmd, base::LaunchOptions(), test_process);
50 void NaClGdbDebugStubTest::RunDebugStubTest(const std::string& nacl_module,
51 const std::string& test_name) {
52 base::ProcessHandle test_script;
53 scoped_ptr<base::Environment> env(base::Environment::Create());
54 nacl::NaClBrowser::GetInstance()->SetGdbDebugStubPortListener(
55 base::Bind(&NaClGdbDebugStubTest::StartTestScript,
56 base::Unretained(this), &test_script, test_name));
57 // Turn on debug stub logging.
58 env->SetVar("NACLVERBOSITY", "1");
59 RunTestViaHTTP(nacl_module);
60 env->UnSetVar("NACLVERBOSITY");
61 nacl::NaClBrowser::GetInstance()->ClearGdbDebugStubPortListener();
62 int exit_code;
63 base::WaitForExitCode(test_script, &exit_code);
64 EXPECT_EQ(0, exit_code);
67 // NaCl tests are disabled under ASAN because of qualification test.
68 #if defined(ADDRESS_SANITIZER)
69 # define MAYBE_Empty DISABLED_Empty
70 #else
71 # define MAYBE_Empty Empty
72 #endif
74 IN_PROC_BROWSER_TEST_F(NaClGdbDebugStubTest, MAYBE_Empty) {
75 RunDebugStubTest("Empty", "continue");
78 #if defined(ADDRESS_SANITIZER)
79 # define MAYBE_Breakpoint DISABLED_Breakpoint
80 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
81 // Timing out on ARM linux: http://crbug.com/238469
82 # define MAYBE_Breakpoint DISABLED_Breakpoint
83 #else
84 # define MAYBE_Breakpoint Breakpoint
85 #endif
87 IN_PROC_BROWSER_TEST_F(NaClGdbDebugStubTest, MAYBE_Breakpoint) {
88 RunDebugStubTest("Empty", "breakpoint");