about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-03-02 07:24:01 +0100
committerGitHub <noreply@github.com>2023-03-02 07:24:01 +0100
commit478d530af4879ae2ef829cf19370f9b518a98c11 (patch)
tree59d148b6a064858c2ba7318f7e7f556c0a1fdfb7
parent91dafebc91f9ef46e98ba4e592e8b1f6fb6a2145 (diff)
parentc9f1a541b36772800482c0b9de198caa1d6d6b2e (diff)
downloadrust-478d530af4879ae2ef829cf19370f9b518a98c11.tar.gz
rust-478d530af4879ae2ef829cf19370f9b518a98c11.zip
Rollup merge of #108585 - djkoloski:parallel_fuchsia_test_runner, r=tmandry
Run compiler test suite in parallel on Fuchsia

This also adds file locking around calls to `pm publish` as these calls are not thread-safe.
-rwxr-xr-xsrc/ci/docker/scripts/fuchsia-test-runner.py39
-rw-r--r--src/doc/rustc/src/platform-support/fuchsia.md7
2 files changed, 28 insertions, 18 deletions
diff --git a/src/ci/docker/scripts/fuchsia-test-runner.py b/src/ci/docker/scripts/fuchsia-test-runner.py
index c3d532c4b27..e7d1d9781d5 100755
--- a/src/ci/docker/scripts/fuchsia-test-runner.py
+++ b/src/ci/docker/scripts/fuchsia-test-runner.py
@@ -9,6 +9,7 @@ https://doc.rust-lang.org/stable/rustc/platform-support/fuchsia.html#aarch64-unk
 
 import argparse
 from dataclasses import dataclass
+import fcntl
 import glob
 import hashlib
 import json
@@ -146,6 +147,9 @@ class TestEnvironment:
     def zxdb_script_path(self):
         return os.path.join(self.tmp_dir(), "zxdb_script")
 
+    def pm_lockfile_path(self):
+        return os.path.join(self.tmp_dir(), "pm.lock")
+
     def log_info(self, msg):
         print(msg)
 
@@ -460,6 +464,9 @@ class TestEnvironment:
             stderr=self.subprocess_output(),
         )
 
+        # Create lockfiles
+        open(self.pm_lockfile_path(), 'a').close()
+
         # Write to file
         self.write_to_file()
 
@@ -676,19 +683,25 @@ class TestEnvironment:
             log("Publishing package to repo...")
 
             # Publish package to repo
-            subprocess.check_call(
-                [
-                    self.tool_path("pm"),
-                    "publish",
-                    "-a",
-                    "-repo",
-                    self.repo_dir(),
-                    "-f",
-                    far_path,
-                ],
-                stdout=log_file,
-                stderr=log_file,
-            )
+            with open(self.pm_lockfile_path(), 'w') as pm_lockfile:
+                fcntl.lockf(pm_lockfile.fileno(), fcntl.LOCK_EX)
+                subprocess.check_call(
+                    [
+                        self.tool_path("pm"),
+                        "publish",
+                        "-a",
+                        "-repo",
+                        self.repo_dir(),
+                        "-f",
+                        far_path,
+                    ],
+                    stdout=log_file,
+                    stderr=log_file,
+                )
+                # This lock should be released automatically when the pm
+                # lockfile is closed, but we'll be polite and unlock it now
+                # since the spec leaves some wiggle room.
+                fcntl.lockf(pm_lockfile.fileno(), fcntl.LOCK_UN)
 
             log("Running ffx test...")
 
diff --git a/src/doc/rustc/src/platform-support/fuchsia.md b/src/doc/rustc/src/platform-support/fuchsia.md
index 56322d0da43..4d97b8c6cb9 100644
--- a/src/doc/rustc/src/platform-support/fuchsia.md
+++ b/src/doc/rustc/src/platform-support/fuchsia.md
@@ -716,7 +716,7 @@ run the full `tests/ui` test suite:
     --stage=2                                                                 \
     test tests/ui                                                             \
     --target x86_64-unknown-fuchsia                                           \
-    --run=always --jobs 1                                                     \
+    --run=always                                                              \
     --test-args --target-rustcflags                                           \
     --test-args -Lnative=${SDK_PATH}/arch/{x64|arm64}/sysroot/lib             \
     --test-args --target-rustcflags                                           \
@@ -728,9 +728,6 @@ run the full `tests/ui` test suite:
 )
 ```
 
-*Note: The test suite cannot be run in parallel at the moment, so `x.py`
-must be run with `--jobs 1` to ensure only one test runs at a time.*
-
 By default, `x.py` compiles test binaries with `panic=unwind`. If you built your
 Rust toolchain with `-Cpanic=abort`, you need to tell `x.py` to compile test
 binaries with `panic=abort` as well:
@@ -907,7 +904,7 @@ through our `x.py` invocation. The full invocation is:
     --stage=2                                                                 \
     test tests/${TEST}                                                        \
     --target x86_64-unknown-fuchsia                                           \
-    --run=always --jobs 1                                                     \
+    --run=always                                                              \
     --test-args --target-rustcflags                                           \
     --test-args -Lnative=${SDK_PATH}/arch/{x64|arm64}/sysroot/lib             \
     --test-args --target-rustcflags                                           \