Félix Baylac Jacqué
61a5fcdae8
We made the incorrect assumption that the first DSO we'd stumble upon in the load path would be the most appropriate one for the host system. IE. it'd be the x86_64-gnu-linux on such a system. It turned out not being the case, meaning we can't take such a shortcut and have to handle the case where we end up with multiple same libraries for different archs. This forced us to do two things: 1. It forced us to rethink the cache directory structure. We now have to cache each library directory separately. Meaning we now have to inject the GLX/EGL/Cuda directories of *all* these library directories subpaths to the LD_LIBRARY_PATH. The dynamic linker will then try to open these DSOs (and fail) until it stumble upon the appropriate one. 2. We had to give up on the way we injected EGL libraries using asolute paths. We don't know which DSO is adapted to the wrapped program arch. Instead of injecting the absolute paths through the JSON configuration files, we just stipulate the libraries names in them. We then inject the various EGL DSOs we find through the LD_LIBRARY_PATH, similarly to what we already do for GLX and Cuda.
85 lines
2.7 KiB
Python
85 lines
2.7 KiB
Python
import unittest
|
|
import os
|
|
|
|
from nixglhost_wrapper import CacheDirContent, LibraryPath, ResolvedLib
|
|
|
|
|
|
class TestCacheSerializer(unittest.TestCase):
|
|
def test_hostdso_json_golden_test(self):
|
|
lp = LibraryPath(
|
|
glx=[
|
|
ResolvedLib(
|
|
"dummyglx.so",
|
|
"/lib",
|
|
"/lib/dummyglx.so",
|
|
"031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406",
|
|
)
|
|
],
|
|
cuda=[
|
|
ResolvedLib(
|
|
"dummycuda.so",
|
|
"/lib",
|
|
"/lib/dummycuda.so",
|
|
"031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9407",
|
|
)
|
|
],
|
|
generic=[
|
|
ResolvedLib(
|
|
"dummygeneric.so",
|
|
"/lib",
|
|
"/lib/dummygeneric.so",
|
|
"031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9408",
|
|
)
|
|
],
|
|
egl=[
|
|
ResolvedLib(
|
|
"dummyegl.so",
|
|
"/lib",
|
|
"/lib/dummyegl.so",
|
|
"031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9409",
|
|
)
|
|
],
|
|
path="/path/to/lib/dir",
|
|
)
|
|
cdc = CacheDirContent([lp])
|
|
json = cdc.to_json()
|
|
|
|
self.assertIsNotNone(json)
|
|
golden_cdc = CacheDirContent.from_json(json)
|
|
self.assertEqual(cdc, golden_cdc)
|
|
self.assertEqual(cdc.to_json(), golden_cdc.to_json())
|
|
|
|
def test_eq_commut_jsons(self):
|
|
"""Checks that object equality is not sensible to JSON keys commutations"""
|
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
|
with open(
|
|
os.path.join(cwd, "..", "tests", "fixtures", "json_permut", "1.json"),
|
|
"r",
|
|
encoding="utf8",
|
|
) as f:
|
|
cdc_json = f.read()
|
|
with open(
|
|
os.path.join(cwd, "..", "tests", "fixtures", "json_permut", "2.json"),
|
|
"r",
|
|
encoding="utf8",
|
|
) as f:
|
|
commut_cdc_json = f.read()
|
|
with open(
|
|
os.path.join(
|
|
cwd, "..", "tests", "fixtures", "json_permut", "not-equal.json"
|
|
),
|
|
"r",
|
|
encoding="utf8",
|
|
) as f:
|
|
wrong_cdc_json = f.read()
|
|
cdc = CacheDirContent.from_json(cdc_json)
|
|
commut_cdc = CacheDirContent.from_json(commut_cdc_json)
|
|
wrong_cdc = CacheDirContent.from_json(wrong_cdc_json)
|
|
self.assertEqual(cdc, commut_cdc)
|
|
self.assertNotEqual(cdc, wrong_cdc)
|
|
self.assertNotEqual(commut_cdc, wrong_cdc)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|