mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 11:06:11 -10:00
parity.py started on Windows since #3428 but stopped before any harness ran: machine_slot locked its slots with fcntl, which Windows lacks. The rest of the run path was POSIX too: a timed-out harness was killed with os.killpg, trace_main read the peak memory with resource, and the oracle shim went on PATH as a `java` symlink to a Python script. - tools/file_lock.py: an exclusive lock, flock or msvcrt's byte lock; used by machine_slot, integration_env.suite_lock and test_datafix_parity. - kill_tree: the process group where there is one, taskkill /T on Windows. - Without resource, the trace has no peak_bytes and the scheduler assumes DEFAULT_MEMORY, as for a harness that never ran. - No oracle shim on Windows: a program started without a shell is found there only as an .exe, and the shim's execv returns before the program. Harnesses run their oracles fresh. Fixes #6391 Co-Authored-By: Claude Opus 5.5 <[email protected]>
26 lines
740 B
Python
26 lines
740 B
Python
from pathlib import Path
|
|
import tempfile
|
|
import unittest
|
|
|
|
from tools import file_lock
|
|
|
|
|
|
class FileLockTests(unittest.TestCase):
|
|
def test_a_held_lock_refuses_another_until_closed(self):
|
|
with tempfile.TemporaryDirectory() as temp:
|
|
path = Path(temp) / "slot.lock"
|
|
first = open(path, "w")
|
|
second = open(path, "a")
|
|
try:
|
|
self.assertTrue(file_lock.lock(first, wait=False))
|
|
self.assertFalse(file_lock.lock(second, wait=False))
|
|
first.close()
|
|
self.assertTrue(file_lock.lock(second, wait=False))
|
|
finally:
|
|
first.close()
|
|
second.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|