OLD | NEW |
---|---|
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 11 matching lines...) Expand all Loading... | |
22 NaClGdbTest() { | 22 NaClGdbTest() { |
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 EXPECT_TRUE(file_util::CreateTemporaryFile(&script_)); | |
33 command_line->AppendSwitchASCII("nacl-gdb-script", script_.AsUTF8Unsafe()); | |
Mark Seaborn
2012/05/29 18:19:44
You use AppendSwitchPath() above. Can't it be the
halyavin
2012/05/30 08:12:05
I tried to support non-latin TMP directories. But
| |
32 } | 34 } |
35 | |
36 void RunWithNaClGdb(std::string test_name) { | |
37 FilePath mock_nacl_gdb_file; | |
38 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
39 std::string content; | |
40 // TODO(halyavin): Make this test work on Windows 32-bit. Currently this | |
41 // is not possible because NaCl doesn't work without sandbox since 1Gb of | |
42 // space is not reserved. We can't reserve 1Gb of space because | |
43 // base::LaunchProcess doesn't support creating suspended processes. We need | |
44 // to either add suspended process support to base::LaunchProcess or use | |
45 // Win API. | |
46 #if defined(OS_WIN) | |
47 if (base::win::OSInfo::GetInstance()->wow64_status() == | |
48 base::win::OSInfo::WOW64_DISABLED) { | |
49 return; | |
50 } | |
51 #endif | |
52 EXPECT_TRUE(file_util::CreateTemporaryFile(&mock_nacl_gdb_file)); | |
53 env->SetVar("MOCK_NACL_GDB", mock_nacl_gdb_file.AsUTF8Unsafe()); | |
54 RunTestViaHTTP(test_name); | |
55 env->UnSetVar("MOCK_NACL_GDB"); | |
56 | |
57 EXPECT_TRUE(file_util::ReadFileToString(mock_nacl_gdb_file, &content)); | |
58 EXPECT_STREQ("PASS", content.c_str()); | |
59 EXPECT_TRUE(file_util::Delete(mock_nacl_gdb_file, false)); | |
60 | |
61 content.clear(); | |
62 EXPECT_TRUE(file_util::ReadFileToString(script_, &content)); | |
63 EXPECT_STREQ("PASS", content.c_str()); | |
64 EXPECT_TRUE(file_util::Delete(script_, false)); | |
65 } | |
66 | |
67 private: | |
68 FilePath script_; | |
33 }; | 69 }; |
34 | 70 |
35 // Fails on the ASAN test bot. See http://crbug.com/122219 | 71 // Fails on the ASAN test bot. See http://crbug.com/122219 |
36 #if defined(ADDRESS_SANITIZER) | 72 #if defined(ADDRESS_SANITIZER) |
37 #define MAYBE_Empty DISABLED_Empty | 73 #define MAYBE_Empty DISABLED_Empty |
38 #else | 74 #else |
39 #define MAYBE_Empty Empty | 75 #define MAYBE_Empty Empty |
40 #endif | 76 #endif |
41 IN_PROC_BROWSER_TEST_F(NaClGdbTest, MAYBE_Empty) { | 77 IN_PROC_BROWSER_TEST_F(NaClGdbTest, MAYBE_Empty) { |
42 FilePath mock_nacl_gdb_file; | 78 RunWithNaClGdb("Empty"); |
43 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
44 std::string content; | |
45 // TODO(halyavin): Make this test to work on Windows 32-bit. Currently this | |
46 // is not possible because NaCl doesn't work without sandbox since 1Gb of | |
47 // space is not reserved. We can't reserve 1Gb of space because | |
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 } | |
56 #endif | |
57 EXPECT_TRUE(file_util::CreateTemporaryFile(&mock_nacl_gdb_file)); | |
58 env->SetVar("MOCK_NACL_GDB", mock_nacl_gdb_file.AsUTF8Unsafe()); | |
59 RunTestViaHTTP("Empty"); | |
60 env->UnSetVar("MOCK_NACL_GDB"); | |
61 EXPECT_TRUE(file_util::ReadFileToString(mock_nacl_gdb_file, &content)); | |
62 EXPECT_STREQ("PASS", content.c_str()); | |
63 EXPECT_TRUE(file_util::Delete(mock_nacl_gdb_file, false)); | |
64 } | 79 } |
OLD | NEW |