Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4405b7ef99 |
No files matched your search
@@ -133,6 +133,9 @@ collect_steam_logs() {
|
||||
fi
|
||||
}
|
||||
trap 'collect_steam_logs 2>/dev/null || true' TERM INT HUP
|
||||
icd_library_loads() {
|
||||
! LD_LIBRARY_PATH="$(dirname "$1")${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" ldd "$1" 2>&1 | grep -q 'not found'
|
||||
}
|
||||
if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
bl_icd_lib=$(sed -n 's/.*"library_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$BL_VK_DRIVER" 2>/dev/null | head -1)
|
||||
bl_icd_lib=$(printf '%s' "$bl_icd_lib" | sed 's|\\/|/|g')
|
||||
@@ -140,12 +143,12 @@ if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||
/*) ;;
|
||||
?*) bl_icd_lib="$(dirname "$BL_VK_DRIVER")/$bl_icd_lib" ;;
|
||||
esac
|
||||
if [ -r "$BL_VK_DRIVER" ] && [ -n "$bl_icd_lib" ] && [ -r "$bl_icd_lib" ]; then
|
||||
if [ -r "$BL_VK_DRIVER" ] && [ -n "$bl_icd_lib" ] && [ -r "$bl_icd_lib" ] && icd_library_loads "$bl_icd_lib"; then
|
||||
export VK_DRIVER_FILES="$BL_VK_DRIVER"
|
||||
export VK_ICD_FILENAMES="$BL_VK_DRIVER"
|
||||
echo "== vulkan driver: imported $bl_icd_lib (via $BL_VK_DRIVER)"
|
||||
else
|
||||
echo "== vulkan driver: IGNORING $BL_VK_DRIVER (manifest or ${bl_icd_lib:-library} unreadable); using the runtime's own"
|
||||
echo "== vulkan driver: IGNORING $BL_VK_DRIVER (manifest or ${bl_icd_lib:-library} unreadable, or its dependencies do not resolve in this runtime); using the runtime's own"
|
||||
fi
|
||||
unset bl_icd_lib
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
|
||||
|
||||
|
||||
def probe_function():
|
||||
return re.search(r"^icd_library_loads\(\) \{\n.*?^\}\n", SESSION.read_text(), re.M | re.S).group(0)
|
||||
|
||||
|
||||
class VulkanDriverProbeTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.root = Path(tempfile.mkdtemp())
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
|
||||
def probe(self, library):
|
||||
script = probe_function() + 'icd_library_loads "$1"\n'
|
||||
return subprocess.run(["bash", "-c", script, "bash", str(library)]).returncode
|
||||
|
||||
def test_fallback_is_wired_to_the_probe(self):
|
||||
self.assertIn('[ -r "$bl_icd_lib" ] && icd_library_loads "$bl_icd_lib"', SESSION.read_text())
|
||||
|
||||
@unittest.skipUnless(shutil.which("ldd"), "needs ldd")
|
||||
def test_library_with_resolvable_dependencies_passes(self):
|
||||
self.assertEqual(self.probe(shutil.which("true")), 0)
|
||||
|
||||
@unittest.skipUnless(shutil.which("ldd") and shutil.which("cc"), "needs ldd and a C compiler")
|
||||
def test_library_with_missing_dependency_fails(self):
|
||||
(self.root / "dep.c").write_text("int dep(void){return 1;}\n")
|
||||
(self.root / "lib.c").write_text("int dep(void); int f(void){return dep();}\n")
|
||||
subprocess.run(["cc", "-shared", "-o", str(self.root / "libdep.so"), str(self.root / "dep.c")], check=True)
|
||||
subprocess.run(["cc", "-shared", "-o", str(self.root / "libicd.so"), str(self.root / "lib.c"),
|
||||
"-L", str(self.root), "-ldep", "-Wl,-rpath,/nonexistent"], check=True)
|
||||
(self.root / "libdep.so").unlink()
|
||||
self.assertNotEqual(self.probe(self.root / "libicd.so"), 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user