mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
feat: add fenced SteamVR producer leases
This commit is contained in:
1 parent
bb58d0cc7b
commit
023daf57d2
14 files changed
+696
-51
No files matched your search
@@ -57,6 +57,7 @@ class SteamVrHelperTest(unittest.TestCase):
|
||||
|
||||
def test_fresh_runtime_mode_is_selected_and_log_survives_runtime_cleanup(self):
|
||||
log = self.start()
|
||||
self.assertEqual((self.runtime / 'droiddeck-steamvr').stat().st_mode & 0o777, 0o700)
|
||||
self.assertEqual(log.read_text().strip(), 'display=3360x1760@120')
|
||||
self.assertEqual((self.runtime / 'droiddeck-steamvr/vrstartup.log').resolve(), log)
|
||||
shutil.rmtree(self.runtime)
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import ctypes.util
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which("gcc"), "needs gcc on a Linux host")
|
||||
class VrProducerLeaseTest(unittest.TestCase):
|
||||
def compile_and_run(self, source, headers=None, gpu=False):
|
||||
repository = Path(__file__).resolve().parents[2]
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
executable = Path(directory) / "producer-test"
|
||||
command = ["gcc", "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror", "-Wno-unused-parameter", "-pthread"]
|
||||
if headers:
|
||||
command += ["-I" + str(headers)]
|
||||
command += [str(repository / "tools/vr/tests" / source), "-ldl"]
|
||||
if gpu:
|
||||
command += ["-l:libvulkan.so.1"]
|
||||
subprocess.run(command + ["-o", str(executable)], check=True)
|
||||
environment = dict(os.environ)
|
||||
if gpu:
|
||||
manifests = sorted(Path("/usr/share/vulkan/icd.d").glob("lvp_icd*.json"))
|
||||
environment["VK_DRIVER_FILES"] = str(manifests[0])
|
||||
environment["VK_ICD_FILENAMES"] = str(manifests[0])
|
||||
result = subprocess.run([str(executable)], env=environment, capture_output=True, text=True, timeout=20)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
return result.stdout
|
||||
|
||||
def test_protocol_and_retained_ownership(self):
|
||||
self.assertIn("disconnect quarantine passed", self.compile_and_run("test_producer_lease.c"))
|
||||
|
||||
def test_real_gpu_completion_and_frozen_overwrite(self):
|
||||
if not ctypes.util.find_library("vulkan") or not list(Path("/usr/share/vulkan/icd.d").glob("lvp_icd*.json")):
|
||||
self.skipTest("needs Vulkan loader and Lavapipe")
|
||||
repository = Path(__file__).resolve().parents[2]
|
||||
candidates = [os.environ.get("VK_INCLUDE", ""), "/usr/include", repository / "build/vr/include"]
|
||||
candidates += [path for root in (os.environ.get("ANDROID_HOME"), os.environ.get("ANDROID_SDK_ROOT")) if root
|
||||
for path in Path(root).glob("ndk/*/toolchains/llvm/prebuilt/*/sysroot/usr/include")]
|
||||
headers = next((Path(path) for path in candidates if path and (Path(path) / "vulkan/vk_layer.h").is_file()), None)
|
||||
if headers is None:
|
||||
self.skipTest("needs Vulkan headers")
|
||||
self.assertIn("1024 buffer values passed", self.compile_and_run("test_producer_gpu.c", headers=headers, gpu=True))
|
||||
Reference in new issue
Block a user