| Index: content/common/sandbox_mac_unittest_helper.mm
|
| diff --git a/content/common/sandbox_mac_unittest_helper.mm b/content/common/sandbox_mac_unittest_helper.mm
|
| index 3b0345d05d80171a6c5ad6d7b1f637f010610bd6..ea555bc9ca8152f3eef117d199c550c401b137d5 100644
|
| --- a/content/common/sandbox_mac_unittest_helper.mm
|
| +++ b/content/common/sandbox_mac_unittest_helper.mm
|
| @@ -14,6 +14,8 @@ extern "C" {
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "content/common/sandbox_mac.h"
|
| +#include "content/test/test_content_client.h"
|
| +#include "grit/content_resources.h"
|
| #include "testing/multiprocess_func_list.h"
|
|
|
| using sandbox::Sandbox;
|
| @@ -24,6 +26,15 @@ const char* kSandboxTypeKey = "CHROMIUM_SANDBOX_SANDBOX_TYPE";
|
| const char* kSandboxTestNameKey = "CHROMIUM_SANDBOX_TEST_NAME";
|
| const char* kTestDataKey = "CHROMIUM_SANDBOX_USER_DATA";
|
|
|
| +const int kSandboxDefinitionResourceIds[] = {
|
| + IDR_GPU_SANDBOX_DEFINITION,
|
| + IDR_WORKER_SANDBOX_DEFINITION,
|
| + IDR_COMMON_SANDBOX_DEFINITION,
|
| + IDR_PPAPI_SANDBOX_DEFINITION,
|
| + IDR_RENDERER_SANDBOX_DEFINITION,
|
| + IDR_UTILITY_SANDBOX_DEFINITION,
|
| +};
|
| +
|
| } // namespace
|
|
|
| namespace sandboxtest {
|
| @@ -54,26 +65,24 @@ bool MacSandboxTest::RunTestInAllSandboxTypes(const char* test_name,
|
| const char* test_data) {
|
| // Go through all the sandbox types, and run the test case in each of them
|
| // if one fails, abort.
|
| - for(int i = static_cast<int>(Sandbox::SANDBOX_TYPE_FIRST_TYPE);
|
| - i < Sandbox::SANDBOX_AFTER_TYPE_LAST_TYPE;
|
| - ++i) {
|
| + for(unsigned i = 0; i < arraysize(kSandboxDefinitionResourceIds); ++i) {
|
|
|
| - if (!RunTestInSandbox(static_cast<Sandbox::SandboxProcessType>(i),
|
| + if (!RunTestInSandbox(kSandboxDefinitionResourceIds[i],
|
| test_name, test_data)) {
|
| LOG(ERROR) << "Sandboxed test (" << test_name << ")" <<
|
| "Failed in sandbox type " << i <<
|
| - "user data: (" << test_data << ")";
|
| + " user data: (" << test_data << ")";
|
| return false;
|
| }
|
| }
|
| return true;
|
| }
|
|
|
| -bool MacSandboxTest::RunTestInSandbox(Sandbox::SandboxProcessType sandbox_type,
|
| +bool MacSandboxTest::RunTestInSandbox(int sandbox_definition_resource_id,
|
| const char* test_name,
|
| const char* test_data) {
|
| std::stringstream s;
|
| - s << static_cast<int>(static_cast<int>(sandbox_type));
|
| + s << sandbox_definition_resource_id;
|
| setenv(kSandboxTypeKey, s.str().c_str(), 1);
|
| setenv(kSandboxTestNameKey, test_name, 1);
|
| if (test_data)
|
| @@ -125,14 +134,15 @@ namespace {
|
| // Main function for driver process that enables the sandbox and runs test
|
| // code.
|
| MULTIPROCESS_TEST_MAIN(mac_sandbox_test_runner) {
|
| + TestContentClient content_client;
|
| + content::SetContentClient(&content_client);
|
| // Extract parameters.
|
| char* sandbox_type_str = getenv(kSandboxTypeKey);
|
| if (!sandbox_type_str) {
|
| LOG(ERROR) << "Sandbox type not specified";
|
| return -1;
|
| }
|
| - Sandbox::SandboxProcessType sandbox_type =
|
| - static_cast<Sandbox::SandboxProcessType>(atoi(sandbox_type_str));
|
| + int sandbox_definition_resource_id = atoi(sandbox_type_str);
|
| char* sandbox_test_name = getenv(kSandboxTestNameKey);
|
| if (!sandbox_test_name) {
|
| LOG(ERROR) << "Sandbox test name not specified";
|
| @@ -156,10 +166,11 @@ MULTIPROCESS_TEST_MAIN(mac_sandbox_test_runner) {
|
| return -1;
|
| }
|
|
|
| - Sandbox::SandboxWarmup(sandbox_type);
|
| + Sandbox::SandboxWarmup(sandbox_definition_resource_id);
|
|
|
| - if (!Sandbox::EnableSandbox(sandbox_type, FilePath())) {
|
| - LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type;
|
| + if (!Sandbox::EnableSandbox(sandbox_definition_resource_id, FilePath())) {
|
| + LOG(ERROR) << "Failed to initialize sandbox (definition resource id "
|
| + << sandbox_definition_resource_id << ")";
|
| return -1;
|
| }
|
|
|
|
|