summaryrefslogtreecommitdiffstats
path: root/chrome/test/nacl/nacl_sandbox_test.cc
blob: c1935b1922947a9d35d3e77c9f6fa6d9420df401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/test/nacl/nacl_sandbox_test.h"

#include "base/file_util.h"
#include "base/path_service.h"
#include "chrome/common/chrome_switches.h"

namespace {

// Base url is specified in nacl_test.
const FilePath::CharType kSrpcHwHtmlFileName[] =
    FILE_PATH_LITERAL("srpc_hw.html");

}  // namespace

NaClSandboxTest::NaClSandboxTest() {
  // Append the --test-nacl-sandbox=$TESTDLL flag before launching.
  FilePath dylib_dir;
  PathService::Get(base::DIR_EXE, &dylib_dir);
#if defined(OS_MACOSX)
  dylib_dir = dylib_dir.AppendASCII("libnacl_security_tests.dylib");
  launch_arguments_.AppendSwitchPath(switches::kTestNaClSandbox, dylib_dir);
#elif defined(OS_WIN)
  // Let the NaCl process detect if it is 64-bit or not and hack on
  // the appropriate suffix to this dll.
  dylib_dir = dylib_dir.AppendASCII("nacl_security_tests");
  launch_arguments_.AppendSwitchPath(switches::kTestNaClSandbox, dylib_dir);
#elif defined(OS_LINUX)
  // We currently do not test the Chrome Linux SUID or seccomp sandboxes.
#endif
}

NaClSandboxTest::~NaClSandboxTest() {
}

TEST_F(NaClSandboxTest, NaClOuterSBTest) {
  // Load a helloworld .nexe to trigger the nacl loader test.
  FilePath test_file(kSrpcHwHtmlFileName);
  RunTest(test_file, action_max_timeout_ms());
}