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/nacl/nacl_main.cc | |
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/nacl/nacl_main.cc')
-rw-r--r-- | chrome/nacl/nacl_main.cc | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc index 760eb85..d1cf8e1 100644 --- a/chrome/nacl/nacl_main.cc +++ b/chrome/nacl/nacl_main.cc @@ -25,6 +25,7 @@ #if defined(OS_WIN) #include "chrome/nacl/broker_thread.h" #endif +#include "chrome/nacl/nacl_main_platform_delegate.h" #include "chrome/nacl/nacl_thread.h" #ifdef _WIN64 @@ -86,28 +87,11 @@ static void HandleNaClTestParameters(const CommandLine& command_line) { } } -// Launch the NaCl child process in its own thread. -#if defined (OS_WIN) -static void LaunchNaClChildProcess(bool no_sandbox, - sandbox::TargetServices* target_services) { - ChildProcess nacl_process; - nacl_process.set_main_thread(new NaClThread()); - if (!no_sandbox && target_services) { - // Cause advapi32 to load before the sandbox is turned on. - unsigned int dummy_rand; - rand_s(&dummy_rand); - // Turn the sanbox on. - target_services->LowerToken(); - } - MessageLoop::current()->Run(); -} -#elif defined(OS_MACOSX) || defined(OS_LINUX) static void LaunchNaClChildProcess() { ChildProcess nacl_process; nacl_process.set_main_thread(new NaClThread()); MessageLoop::current()->Run(); } -#endif // main() routine for the NaCl loader process. int NaClMain(const MainFunctionParams& parameters) { @@ -126,33 +110,25 @@ int NaClMain(const MainFunctionParams& parameters) { SystemMonitor system_monitor; HighResolutionTimerManager hi_res_timer_manager; -#if defined(OS_WIN) - sandbox::TargetServices* target_services = - parameters.sandbox_info_.TargetServices(); - - DLOG(INFO) << "Started NaCl loader with " << - parsed_command_line.command_line_string(); +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) + NaClMainPlatformDelegate platform(parameters); - HMODULE sandbox_test_module = NULL; + platform.PlatformInitialize(); bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); - if (target_services && !no_sandbox) { - // The command line might specify a test plugin to load. - if (parsed_command_line.HasSwitch(switches::kTestSandbox)) { - std::wstring test_plugin_name = - parsed_command_line.GetSwitchValue(switches::kTestSandbox); - sandbox_test_module = LoadLibrary(test_plugin_name.c_str()); - DCHECK(sandbox_test_module); - } + platform.InitSandboxTests(no_sandbox); + + if (!no_sandbox) { + platform.EnableSandbox(); } - LaunchNaClChildProcess(no_sandbox, target_services); + platform.RunSandboxTests(); -#elif defined(OS_MACOSX) || defined(OS_LINUX) LaunchNaClChildProcess(); #else NOTIMPLEMENTED() << " not implemented startup, plugin startup dialog etc."; #endif + platform.PlatformUninitialize(); return 0; } |