Nukes ViewTree::SetAccessPolicy
[chromium-blink-merge.git] / components / nacl / zygote / nacl_fork_delegate_linux_unittest.cc
blob45e1faa789f6b0894188385f28849af92ec3a1d3
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/nacl/zygote/nacl_fork_delegate_linux.h"
7 #include "base/environment.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/process/launch.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace nacl {
14 TEST(NaClForkDelegateLinuxTest, EnvPassthrough) {
15 scoped_ptr<base::Environment> env(base::Environment::Create());
16 const char passthrough1[] = "HELPER_PASSTHROUGH1";
17 const char passthrough2[] = "HELPER_PASSTHROUGH2";
18 const char passthrough3[] = "HELPER_PASSTHROUGH3";
19 const char passthrough4[] = "HELPER_PASSTHROUGH4";
20 const char passthrough5[] = "NACL_EXE_STDOUT";
21 const char value1[] = "passthrough_value1";
22 const char value3[] = "passthrough_value3";
23 const char value4[] = "passthrough_value4";
24 const char value5[] = "passthrough_value5";
25 std::string passthrough_value;
26 passthrough_value += passthrough1;
27 passthrough_value += ",";
28 passthrough_value += passthrough2;
29 passthrough_value += ",";
30 passthrough_value += passthrough3;
31 // Not adding passthrough4 to the passthrough variable.
32 // Not adding passthrough5 either because it is implicitly allowed.
33 env->SetVar("NACL_ENV_PASSTHROUGH", passthrough_value.c_str());
34 env->SetVar(passthrough1, value1);
35 // Intentionally skip setting a value for passthrough2.
36 env->SetVar(passthrough3, value3);
37 env->SetVar(passthrough4, value4);
38 env->SetVar(passthrough5, value5);
40 base::LaunchOptions options;
41 NaClForkDelegate::AddPassthroughEnvToOptions(&options);
42 EXPECT_EQ(value1, options.environ[passthrough1]);
43 EXPECT_EQ(0U, options.environ.count(passthrough2));
44 EXPECT_EQ(value3, options.environ[passthrough3]);
45 EXPECT_EQ(0U, options.environ.count(passthrough4));
46 EXPECT_EQ(value5, options.environ[passthrough5]);
49 } // namespace nacl