Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / nacl_host / test / nacl_gdb_browsertest.cc
blobb7d7f4c0230d14a9ddfd86ed76959825a9e1b1c2
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/files/file_util.h"
8 #include "base/path_service.h"
9 #include "base/win/windows_version.h"
10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/test/ppapi/ppapi_test.h"
12 #include "components/nacl/common/nacl_switches.h"
14 static const base::FilePath::CharType kMockNaClGdb[] =
15 #if defined(OS_WIN)
16 FILE_PATH_LITERAL("mock_nacl_gdb.exe");
17 #else
18 FILE_PATH_LITERAL("mock_nacl_gdb");
19 #endif
21 class NaClGdbTest : public PPAPINaClNewlibTest {
22 public:
23 NaClGdbTest() {
26 void SetUpCommandLine(base::CommandLine* command_line) override {
27 PPAPINaClNewlibTest::SetUpCommandLine(command_line);
29 base::FilePath mock_nacl_gdb;
30 EXPECT_TRUE(PathService::Get(base::DIR_EXE, &mock_nacl_gdb));
31 mock_nacl_gdb = mock_nacl_gdb.Append(kMockNaClGdb);
32 command_line->AppendSwitchPath(switches::kNaClGdb, mock_nacl_gdb);
33 EXPECT_TRUE(base::CreateTemporaryFile(&script_));
34 command_line->AppendSwitchPath(switches::kNaClGdbScript, script_);
37 void RunWithNaClGdb(std::string test_name) {
38 base::FilePath mock_nacl_gdb_file;
39 scoped_ptr<base::Environment> env(base::Environment::Create());
40 std::string content;
41 // TODO(halyavin): Make this test work on Windows 32-bit. Currently this
42 // is not possible because NaCl doesn't work without sandbox since 1Gb of
43 // space is not reserved. We can't reserve 1Gb of space because
44 // base::LaunchProcess doesn't support creating suspended processes. We need
45 // to either add suspended process support to base::LaunchProcess or use
46 // Win API.
47 #if defined(OS_WIN)
48 if (base::win::OSInfo::GetInstance()->wow64_status() ==
49 base::win::OSInfo::WOW64_DISABLED) {
50 return;
52 #endif
53 EXPECT_TRUE(base::CreateTemporaryFile(&mock_nacl_gdb_file));
54 env->SetVar("MOCK_NACL_GDB", mock_nacl_gdb_file.AsUTF8Unsafe());
55 RunTestViaHTTP(test_name);
56 env->UnSetVar("MOCK_NACL_GDB");
58 EXPECT_TRUE(base::ReadFileToString(mock_nacl_gdb_file, &content));
59 EXPECT_STREQ("PASS", content.c_str());
60 EXPECT_TRUE(base::DeleteFile(mock_nacl_gdb_file, false));
62 content.clear();
63 EXPECT_TRUE(base::ReadFileToString(script_, &content));
64 EXPECT_STREQ("PASS", content.c_str());
65 EXPECT_TRUE(base::DeleteFile(script_, false));
68 private:
69 base::FilePath script_;
72 // Fails on the ASAN test bot. See http://crbug.com/122219
73 #if defined(ADDRESS_SANITIZER)
74 #define MAYBE_Empty DISABLED_Empty
75 #else
76 #define MAYBE_Empty Empty
77 #endif
78 IN_PROC_BROWSER_TEST_F(NaClGdbTest, MAYBE_Empty) {
79 RunWithNaClGdb("Empty");