Tests: Fix Windows import of POSIX-only pty and resource in driver.py (#8573)

This commit is contained in:
yash
2026-10-02 14:03:27 -04:00
committed by GitHub
parent b080950f76
commit 9b9d690024
2 changed files with 13 additions and 3 deletions
+2
View File
@@ -58,6 +58,7 @@ Chykon
Congcong Cai
Conor McCullough
Cookie
cynicalmindset
Dan Ruelas-Petrisko
Daniel Bates
Danny Oler
@@ -361,6 +362,7 @@ Wolfgang Mayerwieser
Xi Zhang
Yan Xu
Yangyu Chen
yash
Yilin Li
Yilou Wang
Yinan Xu
+11 -3
View File
@@ -12,9 +12,15 @@ import multiprocessing
import os
import pickle
import platform
import pty
try:
import pty
except ImportError:
pty = None
import re
import resource
try:
import resource
except ImportError:
resource = None
import runpy
import shutil
import signal
@@ -1503,6 +1509,8 @@ class VlTest:
by all of the spawned child processess"""
# An unprivileged process may set only its soft limit
# to a value in the range from 0 up to the hard limit
if not resource:
return
_, hardlimit = resource.getrlimit(resource.RLIMIT_CPU)
softlimit = ctypes.c_long(min(seconds, ctypes.c_ulong(hardlimit).value)).value
# Casting is required due to a quirk in Python,
@@ -1945,7 +1953,7 @@ class VlTest:
if logfile:
logfh = open(logfile, 'wb') # pylint: disable=consider-using-with
if not Args.interactive_debugger:
if not Args.interactive_debugger and pty:
# Some parallel job's run() may attempt to capture driver.py's
# terminal, e.g. gdb does this. So, unless known we want to run GDB
# (where we want it to control the terminal), become a controlling