Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1647cebf3 | ||
|
|
2bd7d96642 | ||
|
|
acbd6ac688 |
No files matched your search
@@ -1286,6 +1286,16 @@ def system_graphics_launch(command, env):
|
||||
return [str(wrapper), *command], result
|
||||
|
||||
|
||||
AUDIO_STREAMS_PROBE = (
|
||||
'folder=$1; launch=$2; shift 2; n=0; '
|
||||
'for t in "$@"; do '
|
||||
'while [ "$n" -lt "$t" ]; do kill -0 "$launch" 2>/dev/null || exit 0; sleep 1; n=$((n + 1)); done; '
|
||||
'kill -0 "$launch" 2>/dev/null || exit 0; '
|
||||
'{ echo "== $(date +%T)"; pactl list sink-inputs 2>&1 | head -80; } >> "$folder/audio-streams.txt"; '
|
||||
'done'
|
||||
)
|
||||
|
||||
|
||||
def game_logs(command, env, app_id, now=None):
|
||||
"""Detailed graphics logs for one game launch, in the session's log folder: Proton's own log,
|
||||
DXVK's and vkd3d-proton's, and the Vulkan driver's startup messages. The app turns this on
|
||||
@@ -1327,8 +1337,7 @@ def game_logs(command, env, app_id, now=None):
|
||||
pass
|
||||
# Whether the game's sound reaches PulseAudio: the streams 20 s and 60 s in, without waiting.
|
||||
try:
|
||||
subprocess.Popen(["sh", "-c", 'for t in 20 40; do sleep $t; { echo "== $(date +%T)"; '
|
||||
'pactl list sink-inputs 2>&1 | head -80; } >> "$1/audio-streams.txt"; done', "audio", str(folder)],
|
||||
subprocess.Popen(["sh", "-c", AUDIO_STREAMS_PROBE, "audio", str(folder), str(os.getpid()), "20", "60"],
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
start_new_session=True)
|
||||
except OSError:
|
||||
|
||||
@@ -9,6 +9,7 @@ import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from unittest import mock
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@@ -2013,6 +2014,65 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertIn("exe: first.exe", (Path(first["PROTON_LOG_DIR"]) / "launch.txt").read_text())
|
||||
self.assertIn("exe: second.exe", (Path(second["PROTON_LOG_DIR"]) / "launch.txt").read_text())
|
||||
|
||||
def test_audio_probe_watches_this_launch(self):
|
||||
with tempfile.TemporaryDirectory() as tmp, mock.patch("subprocess.Popen") as popen:
|
||||
env = {"DD_GAME_LOGS": "1", "DD_DEBUG_DIR": tmp}
|
||||
result = MODULE["game_logs"](["/proton", "waitforexitandrun", "game.exe"], env, "42", now=0)
|
||||
self.assertEqual(popen.call_args.args[0], [
|
||||
"sh", "-c", MODULE["AUDIO_STREAMS_PROBE"], "audio", result["PROTON_LOG_DIR"], str(os.getpid()), "20", "60",
|
||||
])
|
||||
|
||||
def test_audio_probe_ends_with_the_game_and_keeps_its_samples_while_it_runs(self):
|
||||
probe = ["sh", "-c", MODULE["AUDIO_STREAMS_PROBE"], "audio"]
|
||||
|
||||
def samples(folder):
|
||||
path = Path(folder) / "audio-streams.txt"
|
||||
return sum(line.startswith("== ") for line in path.read_text().splitlines()) if path.exists() else 0
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "60"])
|
||||
try:
|
||||
subprocess.run(probe + [tmp, str(game.pid), "1", "2"], timeout=15, check=True)
|
||||
self.assertEqual(samples(tmp), 2)
|
||||
finally:
|
||||
game.kill()
|
||||
game.wait()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "60"])
|
||||
running = subprocess.Popen(probe + [tmp, str(game.pid), "1", "600"])
|
||||
try:
|
||||
deadline = time.monotonic() + 15
|
||||
while samples(tmp) < 1 and time.monotonic() < deadline:
|
||||
time.sleep(0.1)
|
||||
self.assertEqual(samples(tmp), 1)
|
||||
game.kill()
|
||||
game.wait()
|
||||
self.assertEqual(running.wait(timeout=10), 0)
|
||||
self.assertEqual(samples(tmp), 1)
|
||||
finally:
|
||||
game.kill()
|
||||
game.wait()
|
||||
running.kill()
|
||||
running.wait()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
ended = subprocess.Popen(["true"])
|
||||
ended.wait()
|
||||
subprocess.run(probe + [tmp, str(ended.pid), "20", "60"], timeout=10, check=True)
|
||||
self.assertEqual(samples(tmp), 0)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "0.5"])
|
||||
running = subprocess.Popen(probe + [tmp, str(game.pid), "1"])
|
||||
try:
|
||||
game.wait()
|
||||
self.assertEqual(running.wait(timeout=10), 0)
|
||||
self.assertEqual(samples(tmp), 0)
|
||||
finally:
|
||||
running.kill()
|
||||
running.wait()
|
||||
|
||||
def test_open_driver_pairs_report_the_drivers_own_vkd3d_caps(self):
|
||||
apply = MODULE["apply_config"]
|
||||
config = {"version": 1, "shared": {"VKD3D_FEATURE_LEVEL": "12_2", "VKD3D_SHADER_MODEL": "6_9"},
|
||||
|
||||
Reference in new issue
Block a user