Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: components/nacl/zygote/nacl_fork_delegate_linux_unittest.cc

Issue 308073002: Clear environment variables for nacl_helper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nacl browser tests and android base tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "components/nacl/zygote/nacl_fork_delegate_linux.h"
6
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"
11
12 TEST(NaClForkDelegateLinuxTest, EnvPassthrough) {
13 scoped_ptr<base::Environment> env(base::Environment::Create());
14 const char passthrough1[] = "HELPER_PASSTHROUGH1";
15 const char passthrough2[] = "HELPER_PASSTHROUGH2";
16 const char passthrough3[] = "HELPER_PASSTHROUGH3";
17 const char passthrough4[] = "HELPER_PASSTHROUGH4";
18 const char passthrough5[] = "NACL_EXE_STDOUT";
19 const char value1[] = "passthrough_value1";
20 const char value3[] = "passthrough_value3";
21 const char value4[] = "passthrough_value4";
22 const char value5[] = "passthrough_value5";
23 std::string passthrough_value;
24 passthrough_value += passthrough1;
25 passthrough_value += ",";
26 passthrough_value += passthrough2;
27 passthrough_value += ",";
28 passthrough_value += passthrough3;
29 // Not adding passthrough4 to the passthrough variable.
30 // Not adding passthrough5 either because it is implicitly allowed.
31 env->SetVar("NACL_ENV_PASSTHROUGH", passthrough_value.c_str());
32 env->SetVar(passthrough1, value1);
33 // Intentionally skip setting a value for passthrough2.
34 env->SetVar(passthrough3, value3);
35 env->SetVar(passthrough4, value4);
36 env->SetVar(passthrough5, value5);
37
38 base::LaunchOptions options;
39 nacl::NaClForkDelegate::AddPassthroughEnvToOptions(options);
40 EXPECT_EQ(value1, options.environ[passthrough1]);
41 EXPECT_EQ(0U, options.environ.count(passthrough2));
42 EXPECT_EQ(value3, options.environ[passthrough3]);
43 EXPECT_EQ(0U, options.environ.count(passthrough4));
44 EXPECT_EQ(value5, options.environ[passthrough5]);
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698