| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #include "base/command_line.h" |
| 6 #include "base/path_service.h" |
| 7 #include "base/process_util.h" |
| 8 #include "base/string_number_conversions.h" |
| 9 #include "chrome/browser/nacl_host/nacl_browser.h" |
| 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/test/ppapi/ppapi_test.h" |
| 12 #include "content/public/test/test_browser_thread.h" |
| 13 #include "content/public/test/test_utils.h" |
| 14 |
| 15 class NaClGdbDebugStubTest : public PPAPINaClNewlibTest { |
| 16 public: |
| 17 NaClGdbDebugStubTest() { |
| 18 } |
| 19 |
| 20 void SetUpCommandLine(CommandLine* command_line) OVERRIDE; |
| 21 |
| 22 void StartTestScript(base::ProcessHandle* test_process, |
| 23 std::string test_name, int debug_stub_port); |
| 24 |
| 25 }; |
| 26 |
| 27 void NaClGdbDebugStubTest::SetUpCommandLine(CommandLine* command_line) { |
| 28 PPAPINaClNewlibTest::SetUpCommandLine(command_line); |
| 29 command_line->AppendSwitch(switches::kEnableNaClDebug); |
| 30 } |
| 31 |
| 32 void NaClGdbDebugStubTest::StartTestScript(base::ProcessHandle* test_process, |
| 33 std::string test_name, |
| 34 int debug_stub_port) { |
| 35 // We call python script to reuse GDB RSP protocol implementation. |
| 36 CommandLine cmd(FilePath(FILE_PATH_LITERAL("python"))); |
| 37 FilePath script; |
| 38 PathService::Get(base::DIR_SOURCE_ROOT, &script); |
| 39 script = script.AppendASCII( |
| 40 "chrome/browser/nacl_host/test/debug_stub_browser_tests.py"); |
| 41 cmd.AppendArgPath(script); |
| 42 cmd.AppendArg(base::IntToString(debug_stub_port)); |
| 43 cmd.AppendArg(test_name); |
| 44 LOG(INFO) << cmd.GetCommandLineString(); |
| 45 base::LaunchProcess(cmd, base::LaunchOptions(), test_process); |
| 46 } |
| 47 |
| 48 // NaCl tests are disabled under ASAN because of qualification test. |
| 49 #if defined(ADDRESS_SANITIZER) |
| 50 #define MAYBE_Empty DISABLED_Empty |
| 51 #else |
| 52 #define MAYBE_Empty Empty |
| 53 #endif |
| 54 |
| 55 IN_PROC_BROWSER_TEST_F(NaClGdbDebugStubTest, MAYBE_Empty) { |
| 56 base::ProcessHandle test_script; |
| 57 NaClBrowser::GetInstance()->SetGdbDebugStubPortListener( |
| 58 base::Bind(&NaClGdbDebugStubTest::StartTestScript, |
| 59 base::Unretained(this), &test_script, "continue")); |
| 60 RunTestViaHTTP("Empty"); |
| 61 NaClBrowser::GetInstance()->ClearGdbDebugStubPortListener(); |
| 62 int exit_code; |
| 63 base::WaitForExitCode(test_script, &exit_code); |
| 64 EXPECT_EQ(0, exit_code); |
| 65 } |
| OLD | NEW |