diff options
author | jvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 23:02:52 +0000 |
---|---|---|
committer | jvoung@google.com <jvoung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 23:02:52 +0000 |
commit | 23acfc08defd8db4cd54d91e86593baf47b461ea (patch) | |
tree | fe9e80355421a03b7fab0bf372834144adf4bd21 /chrome/test/nacl | |
parent | 9d098779ae0342c1bf8db56d0bacbb57c3858215 (diff) | |
download | chromium_src-23acfc08defd8db4cd54d91e86593baf47b461ea.zip chromium_src-23acfc08defd8db4cd54d91e86593baf47b461ea.tar.gz chromium_src-23acfc08defd8db4cd54d91e86593baf47b461ea.tar.bz2 |
Set up tests to exercise the chrome outersandbox from the nacl loader.
It is similar to the renderer sandbox tests in that the test code is
separated into a DLL and only loaded based on commandline flags.
Currently tests file open, process creation, and connect.
This is currently not set up for Linux. To set it up for Linux,
we need to be more careful about what tests are expected to pass,
and will need to look into zygote process for how to get the test
shared lib loaded.
BUG=39409
TEST=none
Review URL: http://codereview.chromium.org/1549046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/nacl')
-rw-r--r-- | chrome/test/nacl/nacl_sandbox_test.cc | 44 | ||||
-rw-r--r-- | chrome/test/nacl/nacl_sandbox_test.h | 24 | ||||
-rw-r--r-- | chrome/test/nacl/nacl_test.cc | 63 | ||||
-rw-r--r-- | chrome/test/nacl/nacl_ui_test.cc | 85 | ||||
-rw-r--r-- | chrome/test/nacl/nacl_ui_test.h | 18 |
5 files changed, 171 insertions, 63 deletions
diff --git a/chrome/test/nacl/nacl_sandbox_test.cc b/chrome/test/nacl/nacl_sandbox_test.cc new file mode 100644 index 0000000..1e1b856 --- /dev/null +++ b/chrome/test/nacl/nacl_sandbox_test.cc @@ -0,0 +1,44 @@ +// 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"); + +} // anonymous namespace + +NaClSandboxTest::NaClSandboxTest() : NaClTest() { + // Append the --test-nacl-sandbox=$TESTDLL flag before launching. + FilePath dylibDir; + PathService::Get(base::DIR_EXE, &dylibDir); +#if defined(OS_MACOSX) + dylibDir = dylibDir.AppendASCII("libnacl_security_tests.dylib"); + launch_arguments_.AppendSwitchWithValue(switches::kTestNaClSandbox, + dylibDir.value()); +#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. + dylibDir = dylibDir.AppendASCII("nacl_security_tests"); + launch_arguments_.AppendSwitchWithValue(switches::kTestNaClSandbox, + dylibDir.value()); +#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()); +} diff --git a/chrome/test/nacl/nacl_sandbox_test.h b/chrome/test/nacl/nacl_sandbox_test.h new file mode 100644 index 0000000..578535a --- /dev/null +++ b/chrome/test/nacl/nacl_sandbox_test.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef CHROME_TEST_NACL_NACL_SANDBOX_TEST_H_ +#define CHROME_TEST_NACL_NACL_SANDBOX_TEST_H_ + +#include "chrome/test/nacl/nacl_test.h" + +class FilePath; + +// This class implements integration tests for Native Client. +// Specifically, this tests that the sandbox is active by the time a +// NaCl module is loaded. To force a NaCl module to be loaded, +// it will navigate to a page containing a simple NaCl module. +// The NaCl module itself won't exercise the sandbox, but a DLL will be +// loaded into the same process that does exercise the sandbox. +class NaClSandboxTest : public NaClTest { + protected: + NaClSandboxTest(); + virtual ~NaClSandboxTest(); +}; + +#endif // CHROME_TEST_NACL_NACL_SANDBOX_TEST_H_ diff --git a/chrome/test/nacl/nacl_test.cc b/chrome/test/nacl/nacl_test.cc index 4f67bf5..5a249c3 100644 --- a/chrome/test/nacl/nacl_test.cc +++ b/chrome/test/nacl/nacl_test.cc @@ -21,29 +21,6 @@ const char kTestCompleteSuccess[] = "OK"; const FilePath::CharType kBaseUrl[] = FILE_PATH_LITERAL("http://localhost:5103/tests/prebuilt"); -const FilePath::CharType kSrpcHwHtmlFileName[] = - FILE_PATH_LITERAL("srpc_hw.html"); - -const FilePath::CharType kSrpcBasicHtmlFileName[] = - FILE_PATH_LITERAL("srpc_basic.html"); - -const FilePath::CharType kSrpcSockAddrHtmlFileName[] = - FILE_PATH_LITERAL("srpc_sockaddr.html"); - -const FilePath::CharType kSrpcShmHtmlFileName[] = - FILE_PATH_LITERAL("srpc_shm.html"); - -const FilePath::CharType kSrpcPluginHtmlFileName[] = - FILE_PATH_LITERAL("srpc_plugin.html"); - -const FilePath::CharType kSrpcNrdXferHtmlFileName[] = - FILE_PATH_LITERAL("srpc_nrd_xfer.html"); - -const FilePath::CharType kServerHtmlFileName[] = - FILE_PATH_LITERAL("server_test.html"); - -const FilePath::CharType kNpapiHwHtmlFileName[] = - FILE_PATH_LITERAL("npapi_hw.html"); } // anonymous namespace NaClTest::NaClTest() @@ -117,43 +94,3 @@ void NaClTest::TearDown() { StopHttpServer(); UITest::TearDown(); } - -TEST_F(NaClTest, ServerTest) { - FilePath test_file(kServerHtmlFileName); - RunTest(test_file, action_max_timeout_ms()); -} - -TEST_F(NaClTest, SrpcHelloWorld) { - FilePath test_file(kSrpcHwHtmlFileName); - RunTest(test_file, action_max_timeout_ms()); -} - -TEST_F(NaClTest, SrpcBasicTest) { - FilePath test_file(kSrpcBasicHtmlFileName); - RunTest(test_file, action_max_timeout_ms()); -} - -TEST_F(NaClTest, SrpcSockAddrTest) { - FilePath test_file(kSrpcSockAddrHtmlFileName); - RunTest(test_file, action_max_timeout_ms()); -} - -TEST_F(NaClTest, SrpcShmTest) { - FilePath test_file(kSrpcShmHtmlFileName); - RunTest(test_file, action_max_timeout_ms()); -} - -TEST_F(NaClTest, FLAKY_SrpcPluginTest) { - FilePath test_file(kSrpcPluginHtmlFileName); - RunTest(test_file, action_max_timeout_ms()); -} - -TEST_F(NaClTest, SrpcNrdXferTest) { - FilePath test_file(kSrpcNrdXferHtmlFileName); - RunTest(test_file, action_max_timeout_ms()); -} - -TEST_F(NaClTest, NpapiHwTest) { - FilePath test_file(kNpapiHwHtmlFileName); - RunTest(test_file, action_max_timeout_ms()); -} diff --git a/chrome/test/nacl/nacl_ui_test.cc b/chrome/test/nacl/nacl_ui_test.cc new file mode 100644 index 0000000..10af909 --- /dev/null +++ b/chrome/test/nacl/nacl_ui_test.cc @@ -0,0 +1,85 @@ +// 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_ui_test.h" + +// TODO(jvoung) see what includes we really need. +#include "base/file_util.h" +#include "base/path_service.h" +#include "chrome/common/chrome_paths.h" + +namespace { + + // base url specified in nacl_test + +const FilePath::CharType kSrpcHwHtmlFileName[] = + FILE_PATH_LITERAL("srpc_hw.html"); + +const FilePath::CharType kSrpcBasicHtmlFileName[] = + FILE_PATH_LITERAL("srpc_basic.html"); + +const FilePath::CharType kSrpcSockAddrHtmlFileName[] = + FILE_PATH_LITERAL("srpc_sockaddr.html"); + +const FilePath::CharType kSrpcShmHtmlFileName[] = + FILE_PATH_LITERAL("srpc_shm.html"); + +const FilePath::CharType kSrpcPluginHtmlFileName[] = + FILE_PATH_LITERAL("srpc_plugin.html"); + +const FilePath::CharType kSrpcNrdXferHtmlFileName[] = + FILE_PATH_LITERAL("srpc_nrd_xfer.html"); + +const FilePath::CharType kServerHtmlFileName[] = + FILE_PATH_LITERAL("server_test.html"); + +const FilePath::CharType kNpapiHwHtmlFileName[] = + FILE_PATH_LITERAL("npapi_hw.html"); +} // anonymous namespace + +NaClUITest::NaClUITest() : NaClTest() { + // NaClTest has all we need. +} + +NaClUITest::~NaClUITest() {} + +TEST_F(NaClUITest, ServerTest) { + FilePath test_file(kServerHtmlFileName); + RunTest(test_file, action_max_timeout_ms()); +} + +TEST_F(NaClUITest, SrpcHelloWorld) { + FilePath test_file(kSrpcHwHtmlFileName); + RunTest(test_file, action_max_timeout_ms()); +} + +TEST_F(NaClUITest, SrpcBasicTest) { + FilePath test_file(kSrpcBasicHtmlFileName); + RunTest(test_file, action_max_timeout_ms()); +} + +TEST_F(NaClUITest, SrpcSockAddrTest) { + FilePath test_file(kSrpcSockAddrHtmlFileName); + RunTest(test_file, action_max_timeout_ms()); +} + +TEST_F(NaClUITest, SrpcShmTest) { + FilePath test_file(kSrpcShmHtmlFileName); + RunTest(test_file, action_max_timeout_ms()); +} + +TEST_F(NaClUITest, FLAKY_SrpcPluginTest) { + FilePath test_file(kSrpcPluginHtmlFileName); + RunTest(test_file, action_max_timeout_ms()); +} + +TEST_F(NaClUITest, SrpcNrdXferTest) { + FilePath test_file(kSrpcNrdXferHtmlFileName); + RunTest(test_file, action_max_timeout_ms()); +} + +TEST_F(NaClUITest, NpapiHwTest) { + FilePath test_file(kNpapiHwHtmlFileName); + RunTest(test_file, action_max_timeout_ms()); +} diff --git a/chrome/test/nacl/nacl_ui_test.h b/chrome/test/nacl/nacl_ui_test.h new file mode 100644 index 0000000..1b82c12 --- /dev/null +++ b/chrome/test/nacl/nacl_ui_test.h @@ -0,0 +1,18 @@ +// 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. + +#ifndef CHROME_TEST_NACL_NACL_UI_TEST_H_ +#define CHROME_TEST_NACL_NACL_UI_TEST_H_ + +#include "chrome/test/nacl/nacl_test.h" + +// The actual NaCl ui tests are hooked onto this, so that the base class +// can be reused without running tests that require loading a NaCl module. +class NaClUITest : public NaClTest { + protected: + NaClUITest(); + virtual ~NaClUITest(); +}; + +#endif // CHROME_TEST_NACL_NACL_UI_TEST_H_ |