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

Unified Diff: base/process/process_util_unittest.cc

Issue 308073002: Clear environment variables for nacl_helper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: base/process/process_util_unittest.cc
diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc
index cfd23c90553074753d3958b5b9ae1581a7b624dd..bf9ade84ef944092214548203d3a1047d93b17e5 100644
--- a/base/process/process_util_unittest.cc
+++ b/base/process/process_util_unittest.cc
@@ -563,6 +563,7 @@ TEST_F(ProcessUtilTest, MAYBE_FDRemapping) {
namespace {
std::string TestLaunchProcess(const base::EnvironmentMap& env_changes,
+ const bool clear_environ,
const int clone_flags) {
std::vector<std::string> args;
base::FileHandleMappingVector fds_to_remap;
@@ -578,6 +579,7 @@ std::string TestLaunchProcess(const base::EnvironmentMap& env_changes,
base::LaunchOptions options;
options.wait = true;
options.environ = env_changes;
+ options.clear_environ = clear_environ;
options.fds_to_remap = &fds_to_remap;
#if defined(OS_LINUX)
options.clone_flags = clone_flags;
@@ -610,35 +612,45 @@ const char kLargeString[] =
TEST_F(ProcessUtilTest, LaunchProcess) {
base::EnvironmentMap env_changes;
const int no_clone_flags = 0;
+ const bool no_clear_environ = false;
const char kBaseTest[] = "BASE_TEST";
env_changes[kBaseTest] = "bar";
- EXPECT_EQ("bar\n", TestLaunchProcess(env_changes, no_clone_flags));
+ EXPECT_EQ("bar\n",
+ TestLaunchProcess(env_changes, no_clear_environ, no_clone_flags));
+ EXPECT_EQ("bar\n", TestLaunchProcess(env_changes, true, no_clone_flags));
env_changes.clear();
EXPECT_EQ(0, setenv(kBaseTest, "testing", 1 /* override */));
- EXPECT_EQ("testing\n", TestLaunchProcess(env_changes, no_clone_flags));
+ EXPECT_EQ("testing\n",
+ TestLaunchProcess(env_changes, no_clear_environ, no_clone_flags));
+ EXPECT_EQ("\n", TestLaunchProcess(env_changes, true, no_clone_flags));
env_changes[kBaseTest] = std::string();
- EXPECT_EQ("\n", TestLaunchProcess(env_changes, no_clone_flags));
+ EXPECT_EQ("\n",
+ TestLaunchProcess(env_changes, no_clear_environ, no_clone_flags));
env_changes[kBaseTest] = "foo";
- EXPECT_EQ("foo\n", TestLaunchProcess(env_changes, no_clone_flags));
+ EXPECT_EQ("foo\n",
+ TestLaunchProcess(env_changes, no_clear_environ, no_clone_flags));
env_changes.clear();
EXPECT_EQ(0, setenv(kBaseTest, kLargeString, 1 /* override */));
EXPECT_EQ(std::string(kLargeString) + "\n",
- TestLaunchProcess(env_changes, no_clone_flags));
+ TestLaunchProcess(env_changes, no_clear_environ, no_clone_flags));
env_changes[kBaseTest] = "wibble";
- EXPECT_EQ("wibble\n", TestLaunchProcess(env_changes, no_clone_flags));
+ EXPECT_EQ("wibble\n",
+ TestLaunchProcess(env_changes, no_clear_environ, no_clone_flags));
#if defined(OS_LINUX)
// Test a non-trival value for clone_flags.
// Don't test on Valgrind as it has limited support for clone().
if (!RunningOnValgrind()) {
- EXPECT_EQ("wibble\n", TestLaunchProcess(env_changes, CLONE_FS | SIGCHLD));
+ EXPECT_EQ(
+ "wibble\n",
+ TestLaunchProcess(env_changes, no_clear_environ, CLONE_FS | SIGCHLD));
}
jln (very slow on Chromium) 2014/06/02 21:31:47 Could you add a test with clear_environ set to tru
elijahtaylor1 2014/06/03 20:47:54 Done.
#endif
}

Powered by Google App Engine
This is Rietveld 408576698