okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
adfb7ecb2
main
1"""A Windows engine that cannot load a DLL ends with 0xC0000135 and no message. The start error must name the missing file 2(tester report 2026-10-17: cublas64_13.dll was not in the engine component and the app blamed memory).""" 3 4import sys 5import tempfile 6import unittest 7from pathlib import Path 8 9ROOT = Path (__file__ ).resolve ().parents [2 ] 10sys .path .insert (0 ,str (ROOT )) 11sys .path .insert (0 ,str (ROOT / "packaging" )) 12sys .path .insert (0 ,str (Path (__file__ ).resolve ().parent )) 13import binary_deps # noqa: E402 14from serve import loader_diag # noqa: E402 15from serve .server import start_exit_note # noqa: E402 16from test_engine_deps import make_pe # noqa: E402 17 18 19class MissingFiles (unittest .TestCase ): 20def folder (self ,d ,* ,with_cublas ): 21d = Path (d ) 22 (d / "strata.exe" ).write_bytes (make_pe (["cublas64_13.dll" ,"KERNEL32.dll" ,"api-ms-win-crt-runtime-l1-1-0.dll" ])) 23 (d / "strata_kq.dll" ).write_bytes (make_pe (["KERNEL32.dll" ])) 24if with_cublas : 25 (d / "cublas64_13.dll" ).write_bytes (make_pe (["cublasLt64_13.dll" ,"KERNEL32.dll" ])) 26 (d / "cublasLt64_13.dll" ).write_bytes (make_pe (["KERNEL32.dll" ])) 27return d / "strata.exe" 28 29def test_reader_matches_the_packaging_reader (self ): 30with tempfile .TemporaryDirectory ()as d : 31exe = self .folder (d ,with_cublas = True ) 32self .assertEqual (loader_diag .pe_imports (exe ),binary_deps .pe_imports (exe )) 33 34def test_names_the_missing_dll (self ): 35with tempfile .TemporaryDirectory ()as d ,tempfile .TemporaryDirectory ()as sysdir : 36exe = self .folder (d ,with_cublas = False ) 37 (Path (sysdir )/ "KERNEL32.dll" ).write_bytes (b"MZ" ) 38self .assertEqual (loader_diag .missing_files (exe , [Path (sysdir )]), ["cublas64_13.dll" ]) 39 40def test_transitive_import_is_named (self ): 41with tempfile .TemporaryDirectory ()as d ,tempfile .TemporaryDirectory ()as sysdir : 42exe = self .folder (d ,with_cublas = True ) 43 (exe .parent / "cublasLt64_13.dll" ).unlink () 44 (Path (sysdir )/ "KERNEL32.dll" ).write_bytes (b"MZ" ) 45self .assertEqual (loader_diag .missing_files (exe , [Path (sysdir )]), ["cublasLt64_13.dll" ]) 46 47def test_complete_folder_names_nothing (self ): 48with tempfile .TemporaryDirectory ()as d ,tempfile .TemporaryDirectory ()as sysdir : 49exe = self .folder (d ,with_cublas = True ) 50 (Path (sysdir )/ "KERNEL32.dll" ).write_bytes (b"MZ" ) 51self .assertEqual (loader_diag .missing_files (exe , [Path (sysdir )]), []) 52 53def test_unreadable_file_never_raises (self ): 54self .assertEqual (loader_diag .missing_files (Path ("no-such-folder" )/ "strata.exe" ), []) 55 56def test_start_note_only_for_the_loader_status (self ): 57with tempfile .TemporaryDirectory ()as d : 58exe = self .folder (d ,with_cublas = False ) 59note = start_exit_note (0xC0000135 ,exe ) 60self .assertIn ("0xC0000135" ,note ) 61self .assertIn ("cublas64_13.dll" ,note ) 62self .assertIn ("Reinstall the engine in Settings > Engine" ,note ) 63self .assertNotIn ("cublas64_13.dll" ,start_exit_note (1 ,exe )) 64self .assertNotIn ("missing a file" ,start_exit_note (0xC0000135 ,None )) 65 66 67if __name__ == "__main__" : 68unittest .main ()