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

Side by Side Diff: chrome/browser/nacl_host/test/nacl_gdb_browsertest.cc

Issue 10447012: Add nacl-gdb-script switch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/environment.h" 6 #include "base/environment.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 24
25 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 25 void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
26 PPAPINaClTest::SetUpCommandLine(command_line); 26 PPAPINaClTest::SetUpCommandLine(command_line);
27 27
28 FilePath mock_nacl_gdb; 28 FilePath mock_nacl_gdb;
29 EXPECT_TRUE(PathService::Get(base::DIR_EXE, &mock_nacl_gdb)); 29 EXPECT_TRUE(PathService::Get(base::DIR_EXE, &mock_nacl_gdb));
30 mock_nacl_gdb = mock_nacl_gdb.Append(kMockNaClGdb); 30 mock_nacl_gdb = mock_nacl_gdb.Append(kMockNaClGdb);
31 command_line->AppendSwitchPath(switches::kNaClGdb, mock_nacl_gdb); 31 command_line->AppendSwitchPath(switches::kNaClGdb, mock_nacl_gdb);
32 } 32 }
33
34 void RunWithNaClGdb(std::string test_name) {
35 FilePath mock_nacl_gdb_file;
36 scoped_ptr<base::Environment> env(base::Environment::Create());
37 std::string content;
38 // TODO(halyavin): Make this test to work on Windows 32-bit. Currently this
Mark Seaborn 2012/05/24 17:25:58 "Make this test work"
halyavin 2012/05/25 09:37:45 Done.
39 // is not possible because NaCl doesn't work without sandbox since 1Gb of
40 // space is not reserved. We can't reserve 1Gb of space because
41 // base::LaunchProcess doesn't support creating suspended processes. We need
42 // to either add suspended process support to base::LaunchProcess or use
43 // Win API.
44 #if defined(OS_WIN)
45 if (base::win::OSInfo::GetInstance()->wow64_status() ==
46 base::win::OSInfo::WOW64_DISABLED) {
47 return;
48 }
49 #endif
50 EXPECT_TRUE(file_util::CreateTemporaryFile(&mock_nacl_gdb_file));
51 env->SetVar("MOCK_NACL_GDB", mock_nacl_gdb_file.AsUTF8Unsafe());
52 RunTestViaHTTP(test_name);
53 env->UnSetVar("MOCK_NACL_GDB");
54 EXPECT_TRUE(file_util::ReadFileToString(mock_nacl_gdb_file, &content));
55 EXPECT_STREQ("PASS", content.c_str());
56 EXPECT_TRUE(file_util::Delete(mock_nacl_gdb_file, false));
57 }
33 }; 58 };
34 59
35 // Fails on the ASAN test bot. See http://crbug.com/122219 60 // Fails on the ASAN test bot. See http://crbug.com/122219
36 #if defined(ADDRESS_SANITIZER) 61 #if defined(ADDRESS_SANITIZER)
37 #define MAYBE_Empty DISABLED_Empty 62 #define MAYBE_Empty DISABLED_Empty
38 #else 63 #else
39 #define MAYBE_Empty Empty 64 #define MAYBE_Empty Empty
40 #endif 65 #endif
41 IN_PROC_BROWSER_TEST_F(NaClGdbTest, MAYBE_Empty) { 66 IN_PROC_BROWSER_TEST_F(NaClGdbTest, MAYBE_Empty) {
42 FilePath mock_nacl_gdb_file; 67 RunWithNaClGdb("Empty");
43 scoped_ptr<base::Environment> env(base::Environment::Create()); 68 }
44 std::string content; 69
45 // TODO(halyavin): Make this test to work on Windows 32-bit. Currently this 70 class NaClGdbScriptTest : public NaClGdbTest {
46 // is not possible because NaCl doesn't work without sandbox since 1Gb of 71 public:
47 // space is not reserved. We can't reserve 1Gb of space because 72 NaClGdbScriptTest() {
48 // base::LaunchProcess doesn't support creating suspended processes. We need
49 // to either add suspended process support to base::LaunchProcess or use
50 // Win API.
51 #if defined(OS_WIN)
52 if (base::win::OSInfo::GetInstance()->wow64_status() ==
53 base::win::OSInfo::WOW64_DISABLED) {
54 return;
55 } 73 }
56 #endif 74
57 EXPECT_TRUE(file_util::CreateTemporaryFile(&mock_nacl_gdb_file)); 75 void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
58 env->SetVar("MOCK_NACL_GDB", mock_nacl_gdb_file.AsUTF8Unsafe()); 76 NaClGdbTest::SetUpCommandLine(command_line);
59 RunTestViaHTTP("Empty"); 77 EXPECT_TRUE(file_util::CreateTemporaryFile(&script_));
60 env->UnSetVar("MOCK_NACL_GDB"); 78 command_line->AppendSwitchPath("nacl-gdb-script", script_);
61 EXPECT_TRUE(file_util::ReadFileToString(mock_nacl_gdb_file, &content)); 79 }
62 EXPECT_STREQ("PASS", content.c_str()); 80
63 EXPECT_TRUE(file_util::Delete(mock_nacl_gdb_file, false)); 81 void RunWithNaClGdb(std::string test_name) {
82 scoped_ptr<base::Environment> env(base::Environment::Create());
83 env->SetVar("NACL_GDB_SCRIPT", script_.AsUTF8Unsafe());
84 NaClGdbTest::RunWithNaClGdb("Empty");
Mark Seaborn 2012/05/24 17:25:58 I don't like this use of inheritance. It's kind o
halyavin 2012/05/25 09:37:45 It will make extending it easier. All tests could
85 env->UnSetVar("NACL_GDB_SCRIPT");
86 EXPECT_TRUE(file_util::Delete(script_, false));
87 }
88 private:
89 FilePath script_;
90 };
91
92 IN_PROC_BROWSER_TEST_F(NaClGdbScriptTest, MAYBE_Empty) {
93 RunWithNaClGdb("Empty");
64 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698