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

Unified Diff: base/process_util_unittest.cc

Issue 8880: Port GetProcessCount(), KillProcesses(), and CleanupProcesses().... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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
« no previous file with comments | « base/process_util_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_unittest.cc
===================================================================
--- base/process_util_unittest.cc (revision 4223)
+++ base/process_util_unittest.cc (working copy)
@@ -5,6 +5,7 @@
#define _CRT_SECURE_NO_WARNINGS
#include "base/multiprocess_test.h"
+#include "base/platform_thread.h"
#include "base/process_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -29,6 +30,40 @@
EXPECT_TRUE(process_util::WaitForSingleProcess(handle, 1000));
}
+MULTIPROCESS_TEST_MAIN(SlowChildProcess) {
+ // Sleep until file "SlowChildProcess.die" is created.
+ FILE *fp;
+ do {
+ PlatformThread::Sleep(100);
+ fp = fopen("SlowChildProcess.die", "r");
+ } while (!fp);
+ fclose(fp);
+ remove("SlowChildProcess.die");
+ exit(0);
+ return 0;
+}
+
+#if defined(OS_WIN)
+#define EXE_SUFFIX ".exe"
+#else
+#define EXE_SUFFIX ""
+#endif
+
+TEST_F(ProcessUtilTest, KillSlowChild) {
+ remove("SlowChildProcess.die");
+ int oldcount = process_util::GetProcessCount(L"base_unittests" EXE_SUFFIX, 0);
+
+ ProcessHandle handle = this->SpawnChild(L"SlowChildProcess");
+
+ ASSERT_NE(static_cast<ProcessHandle>(NULL), handle);
+ EXPECT_EQ(oldcount+1, process_util::GetProcessCount(L"base_unittests" EXE_SUFFIX, 0));
+ FILE *fp = fopen("SlowChildProcess.die", "w");
+ fclose(fp);
+ // TODO(port): do something less racy here
+ PlatformThread::Sleep(1000);
+ EXPECT_EQ(oldcount, process_util::GetProcessCount(L"base_unittests" EXE_SUFFIX, 0));
+}
+
// TODO(estade): if possible, port these 2 tests.
#if defined(OS_WIN)
TEST_F(ProcessUtilTest, EnableLFH) {
« no previous file with comments | « base/process_util_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698