| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | import os |
| 5 | import tempfile |
| 6 | from pathlib import Path |
| 7 | |
| 8 | from vllm.utils.system_utils import _maybe_force_spawn, unique_filepath |
| 9 | |
| 10 | |
| 11 | def test_unique_filepath(): |
| 12 | temp_dir = tempfile.mkdtemp() |
| 13 | path_fn = lambda i: Path(temp_dir) / f"file_{i}.txt" |
| 14 | paths = set() |
| 15 | for i in range(10): |
| 16 | path = unique_filepath(path_fn) |
| 17 | path.write_text("test") |
| 18 | paths.add(path) |
| 19 | assert len(paths) == 10 |
| 20 | assert len(list(Path(temp_dir).glob("*.txt"))) == 10 |
| 21 | |
| 22 | |
| 23 | def test_numa_bind_forces_spawn(monkeypatch): |
| 24 | monkeypatch.delenv("VLLM_WORKER_MULTIPROC_METHOD", raising=False) |
| 25 | monkeypatch.setattr("sys.argv", ["vllm", "serve", "--numa-bind"]) |
| 26 | _maybe_force_spawn() |
| 27 | assert os.environ["VLLM_WORKER_MULTIPROC_METHOD"] == "spawn" |