• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--- a/base/process/process_metrics_unittest.cc
2+++ b/base/process/process_metrics_unittest.cc
3@@ -569,6 +569,9 @@ MULTIPROCESS_TEST_MAIN(ChildMain) {
4
5 }  // namespace
6
7+// ARC note: don't compile as SpawnMultiProcessTestChild brings in a lot of
8+// extra dependency.
9+#if !defined(OS_ANDROID) && !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
10 TEST(ProcessMetricsTest, GetChildOpenFdCount) {
11   ScopedTempDir temp_dir;
12   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
13@@ -582,9 +585,23 @@ TEST(ProcessMetricsTest, GetChildOpenFdCount) {
14
15   std::unique_ptr<ProcessMetrics> metrics(
16       ProcessMetrics::CreateProcessMetrics(child.Handle()));
17-  EXPECT_EQ(0, metrics->GetOpenFdCount());
18+  // Try a couple times to observe the child with 0 fds open.
19+  // Sometimes we've seen that the child can have 1 remaining
20+  // fd shortly after receiving the signal.  Potentially this
21+  // is actually the signal file still open in the child.
22+  int open_fds = -1;
23+  for (int tries = 0; tries < 5; ++tries) {
24+    open_fds = metrics->GetOpenFdCount();
25+    if (!open_fds) {
26+      break;
27+    }
28+    PlatformThread::Sleep(TimeDelta::FromMilliseconds(1));
29+  }
30+  EXPECT_EQ(0, open_fds);
31   ASSERT_TRUE(child.Terminate(0, true));
32 }
33+#endif  // !defined(__ANDROID__)
34+
35 #endif  // defined(OS_LINUX)
36
37 #if defined(OS_ANDROID) || defined(OS_LINUX)
38--- a/base/test/multiprocess_test.cc
39+++ b/base/test/multiprocess_test.cc
40@@ -13,7 +13,7 @@
41
42 namespace base {
43
44-#if !defined(OS_ANDROID)
45+#if !defined(OS_ANDROID) && !defined(__ANDROID__) && !defined(__ANDROID_HOST__)
46 Process SpawnMultiProcessTestChild(const std::string& procname,
47                                    const CommandLine& base_command_line,
48                                    const LaunchOptions& options) {
49@@ -39,7 +39,7 @@ bool TerminateMultiProcessTestChild(const Process& process,
50   return process.Terminate(exit_code, wait);
51 }
52
53-#endif  // !defined(OS_ANDROID)
54+#endif  // !OS_ANDROID && !__ANDROID__ && !__ANDROID_HOST__
55
56 CommandLine GetMultiProcessTestChildBaseCommandLine() {
57   base::ScopedAllowBlockingForTesting allow_blocking;
58@@ -52,6 +52,8 @@ CommandLine GetMultiProcessTestChildBaseCommandLine() {
59
60 MultiProcessTest::MultiProcessTest() = default;
61
62+// Don't compile on ARC.
63+#if 0
64 Process MultiProcessTest::SpawnChild(const std::string& procname) {
65   LaunchOptions options;
66 #if defined(OS_WIN)
67@@ -64,6 +66,7 @@ Process MultiProcessTest::SpawnChildWithOptions(const std::string& procname,
68                                                 const LaunchOptions& options) {
69   return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options);
70 }
71+#endif
72
73 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) {
74   CommandLine command_line = GetMultiProcessTestChildBaseCommandLine();
75