summaryrefslogtreecommitdiffstats
path: root/chrome/test/test_launcher
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 20:31:41 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-09 20:31:41 +0000
commit87bf974e05e6d0f9dcc28f3c51cf46fd4b9a3145 (patch)
treeff4d2ef0b6c90739fd1feee1454cf41e05abbb78 /chrome/test/test_launcher
parente88079e395bf606c55e746bd618414abbcc6bc31 (diff)
downloadchromium_src-87bf974e05e6d0f9dcc28f3c51cf46fd4b9a3145.zip
chromium_src-87bf974e05e6d0f9dcc28f3c51cf46fd4b9a3145.tar.gz
chromium_src-87bf974e05e6d0f9dcc28f3c51cf46fd4b9a3145.tar.bz2
Run in-process browser tests using the sandbox.
Review URL: http://codereview.chromium.org/2729002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49308 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/test_launcher')
-rw-r--r--chrome/test/test_launcher/out_of_proc_test_runner.cc47
1 files changed, 46 insertions, 1 deletions
diff --git a/chrome/test/test_launcher/out_of_proc_test_runner.cc b/chrome/test/test_launcher/out_of_proc_test_runner.cc
index c27b051..766314c 100644
--- a/chrome/test/test_launcher/out_of_proc_test_runner.cc
+++ b/chrome/test/test_launcher/out_of_proc_test_runner.cc
@@ -8,10 +8,21 @@
#include "base/logging.h"
#include "base/process_util.h"
#include "base/test/test_suite.h"
-
#include "chrome/test/test_launcher/test_runner.h"
#include "chrome/test/unit/chrome_test_suite.h"
+#if defined(OS_WIN)
+#include "base/base_switches.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/sandbox_policy.h"
+#include "sandbox/src/dep.h"
+#include "sandbox/src/sandbox_factory.h"
+#include "sandbox/src/sandbox_types.h"
+
+// The entry point signature of chrome.dll.
+typedef int (*DLL_MAIN)(HINSTANCE, sandbox::SandboxInterfaceInfo*, wchar_t*);
+#endif
+
// This version of the test launcher forks a new process for each test it runs.
namespace {
@@ -146,9 +157,43 @@ int main(int argc, char** argv) {
command_line->HasSwitch(kSingleProcessTestsAndChromeFlag) ||
command_line->HasSwitch(kGTestListTestsFlag) ||
command_line->HasSwitch(kGTestHelpFlag)) {
+
+#if defined(OS_WIN)
+ if (command_line->HasSwitch(kChildProcessFlag)) {
+ // This is the browser process, so setup the sandbox broker.
+ sandbox::BrokerServices* broker_services =
+ sandbox::SandboxFactory::GetBrokerServices();
+ if (broker_services) {
+ sandbox::InitBrokerServices(broker_services);
+ // Precreate the desktop and window station used by the renderers.
+ sandbox::TargetPolicy* policy = broker_services->CreatePolicy();
+ sandbox::ResultCode result = policy->CreateAlternateDesktop(true);
+ CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result);
+ policy->Release();
+ }
+ }
+#endif
return ChromeTestSuite(argc, argv).Run();
}
+#if defined(OS_WIN)
+ if (command_line->HasSwitch(switches::kProcessType)) {
+ // This is a child process, call ChromeMain.
+ FilePath chrome_path(command_line->GetProgram().DirName());
+ chrome_path = chrome_path.Append(chrome::kBrowserResourcesDll);
+ HMODULE dll = LoadLibrary(chrome_path.value().c_str());
+ DLL_MAIN entry_point =
+ reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll, "ChromeMain"));
+ if (!entry_point)
+ return -1;
+
+ // Initialize the sandbox services.
+ sandbox::SandboxInterfaceInfo sandbox_info = {0};
+ sandbox_info.target_services = sandbox::SandboxFactory::GetTargetServices();
+ return entry_point(GetModuleHandle(NULL), &sandbox_info, GetCommandLineW());
+ }
+#endif
+
fprintf(stdout,
"Starting tests...\n"
"IMPORTANT DEBUGGING NOTE: each test is run inside its own process.\n"