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

Side by Side Diff: chrome/common/multi_process_lock_unittest.cc

Issue 191483002: Get rid of multiprocess_test's debug_on_start arguments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: restore ipc_switches.* Created 6 years, 9 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/environment.h" 6 #include "base/environment.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/process/kill.h" 9 #include "base/process/kill.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 = "MULTI_PROCESS_TEST_LOCK_NAME"; 44 = "MULTI_PROCESS_TEST_LOCK_NAME";
45 45
46 std::string MultiProcessLockTest::GenerateLockName() { 46 std::string MultiProcessLockTest::GenerateLockName() {
47 base::Time now = base::Time::NowFromSystemTime(); 47 base::Time now = base::Time::NowFromSystemTime();
48 return base::StringPrintf("multi_process_test_lock %lf%lf", 48 return base::StringPrintf("multi_process_test_lock %lf%lf",
49 now.ToDoubleT(), base::RandDouble()); 49 now.ToDoubleT(), base::RandDouble());
50 } 50 }
51 51
52 void MultiProcessLockTest::ExpectLockIsLocked(const std::string &name) { 52 void MultiProcessLockTest::ExpectLockIsLocked(const std::string &name) {
53 ScopedEnvironmentVariable var(kLockEnviromentVarName, name); 53 ScopedEnvironmentVariable var(kLockEnviromentVarName, name);
54 base::ProcessHandle handle = SpawnChild("MultiProcessLockTryFailMain", false); 54 base::ProcessHandle handle = SpawnChild("MultiProcessLockTryFailMain");
55 ASSERT_TRUE(handle); 55 ASSERT_TRUE(handle);
56 int exit_code = 0; 56 int exit_code = 0;
57 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code)); 57 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
58 EXPECT_EQ(exit_code, 0); 58 EXPECT_EQ(exit_code, 0);
59 } 59 }
60 60
61 void MultiProcessLockTest::ExpectLockIsUnlocked( 61 void MultiProcessLockTest::ExpectLockIsUnlocked(
62 const std::string &name) { 62 const std::string &name) {
63 ScopedEnvironmentVariable var(kLockEnviromentVarName, name); 63 ScopedEnvironmentVariable var(kLockEnviromentVarName, name);
64 base::ProcessHandle handle = SpawnChild("MultiProcessLockTrySucceedMain", 64 base::ProcessHandle handle = SpawnChild("MultiProcessLockTrySucceedMain");
65 false);
66 ASSERT_TRUE(handle); 65 ASSERT_TRUE(handle);
67 int exit_code = 0; 66 int exit_code = 0;
68 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code)); 67 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
69 EXPECT_EQ(exit_code, 0); 68 EXPECT_EQ(exit_code, 0);
70 } 69 }
71 70
72 TEST_F(MultiProcessLockTest, BasicCreationTest) { 71 TEST_F(MultiProcessLockTest, BasicCreationTest) {
73 // Test basic creation/destruction with no lock taken 72 // Test basic creation/destruction with no lock taken
74 std::string name = GenerateLockName(); 73 std::string name = GenerateLockName();
75 scoped_ptr<MultiProcessLock> scoped(MultiProcessLock::Create(name)); 74 scoped_ptr<MultiProcessLock> scoped(MultiProcessLock::Create(name));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 MULTIPROCESS_TEST_MAIN(MultiProcessLockTrySucceedMain) { 162 MULTIPROCESS_TEST_MAIN(MultiProcessLockTrySucceedMain) {
164 std::string name; 163 std::string name;
165 scoped_ptr<base::Environment> environment(base::Environment::Create()); 164 scoped_ptr<base::Environment> environment(base::Environment::Create());
166 EXPECT_TRUE(environment->GetVar(MultiProcessLockTest::kLockEnviromentVarName, 165 EXPECT_TRUE(environment->GetVar(MultiProcessLockTest::kLockEnviromentVarName,
167 &name)); 166 &name));
168 scoped_ptr<MultiProcessLock> test_lock( 167 scoped_ptr<MultiProcessLock> test_lock(
169 MultiProcessLock::Create(name)); 168 MultiProcessLock::Create(name));
170 EXPECT_TRUE(test_lock->TryLock()); 169 EXPECT_TRUE(test_lock->TryLock());
171 return 0; 170 return 0;
172 } 171 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698