2025-10-23 04:25:25 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
|
|
2026-04-09 00:55:24 +08:00
|
|
|
import os
|
2025-10-23 04:25:25 +08:00
|
|
|
import tempfile
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-04-09 00:55:24 +08:00
|
|
|
from vllm.utils.system_utils import _maybe_force_spawn, unique_filepath
|
2025-10-23 04:25:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_unique_filepath():
|
|
|
|
|
temp_dir = tempfile.mkdtemp()
|
|
|
|
|
path_fn = lambda i: Path(temp_dir) / f"file_{i}.txt"
|
|
|
|
|
paths = set()
|
|
|
|
|
for i in range(10):
|
|
|
|
|
path = unique_filepath(path_fn)
|
|
|
|
|
path.write_text("test")
|
|
|
|
|
paths.add(path)
|
|
|
|
|
assert len(paths) == 10
|
|
|
|
|
assert len(list(Path(temp_dir).glob("*.txt"))) == 10
|
2026-04-09 00:55:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_numa_bind_forces_spawn(monkeypatch):
|
|
|
|
|
monkeypatch.delenv("VLLM_WORKER_MULTIPROC_METHOD", raising=False)
|
|
|
|
|
monkeypatch.setattr("sys.argv", ["vllm", "serve", "--numa-bind"])
|
|
|
|
|
_maybe_force_spawn()
|
|
|
|
|
assert os.environ["VLLM_WORKER_MULTIPROC_METHOD"] == "spawn"
|