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