okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
fcb0c2d0e
main
1"""I1 / I2 (tools and images review, 2026-10-22): the picture reader in an engine package must run on every card and Mac the package does. 2 3#3669: the Windows cuda12 package reused a strata-vision.exe built before Pascal support; the engine ran on a P100 and the reader stopped 4with "device kernel image is invalid". #3697: a macOS package with no reader at all. These tests need no GPU and no toolkit.""" 5 6import json 7import sys 8import tempfile 9import unittest 10from pathlib import Path 11 12ROOT = Path (__file__ ).resolve ().parents [2 ] 13sys .path .insert (0 ,str (ROOT / "packaging" )) 14import package_engine # noqa: E402 15 16CUDA12 = ("sm_60" ,"sm_61" ,"sm_70" ,"sm_75" ,"sm_80" ,"sm_86" ,"sm_89" ,"compute_89" ) 17CUDA13 = ("sm_75" ,"sm_86" ,"sm_89" ,"sm_120" ,"compute_120" ) 18 19 20class ReaderCheck (unittest .TestCase ): 21def setUp (self ): 22self .tmp = tempfile .TemporaryDirectory () 23self .addCleanup (self .tmp .cleanup ) 24self .src = Path (self .tmp .name ) 25 (self .src / "strata" ).write_text ("x" ) 26 27def reader (self ,vision_archs = None ): 28 (self .src / "strata-vision" ).write_text ("x" ) 29data = {"version" :"0.2.3" } 30if vision_archs is not None : 31data ["vision_archs" ]= vision_archs 32 (self .src / "BUILD.json" ).write_text (json .dumps (data )) 33 34def check (self ,backend ,target ,archs ,** kw ): 35return package_engine .check_picture_reader (self .src ,backend ,target ,archs ,** kw ) 36 37def test_a_reader_with_no_recorded_archs_is_refused_for_cuda12 (self ): 38self .reader () 39with self .assertRaises (SystemExit )as cm : 40self .check ("cuda" ,"windows-x86_64" ,CUDA12 ,variant = "cuda12" ) 41self .assertIn ("vision_archs" ,str (cm .exception )) 42self .assertIn ("3669" ,str (cm .exception )) 43 44def test_a_cuda13_reader_does_not_pass_for_the_pascal_package (self ): 45self .reader ("75;86;89;120" ) 46with self .assertRaises (SystemExit )as cm : 47self .check ("cuda" ,"windows-x86_64" ,CUDA12 ,variant = "cuda12" ) 48for n in ("sm_60" ,"sm_61" ,"sm_70" ): 49self .assertIn (n ,str (cm .exception )) 50 51def test_a_reader_built_for_the_packages_archs_passes (self ): 52self .reader ("60;61;70;75;80;86;89" ) 53self .assertEqual (self .check ("cuda" ,"linux-x86_64" ,CUDA12 ,variant = "cuda12" ), []) 54self .reader (["75" ,"sm_86" ,"89-real" ,120 ]) 55self .assertEqual (self .check ("cuda" ,"windows-x86_64" ,CUDA13 ,variant = "cuda13" ), []) 56 57def test_allow_stale_vision_packages_it_and_says_what_is_missing (self ): 58self .reader ("75;86;89;120" ) 59notes = self .check ("cuda" ,"windows-x86_64" ,CUDA12 ,variant = "cuda12" ,allow_stale = True ) 60self .assertIn ("sm_60" ,notes [0 ]) 61 62def test_a_cuda_package_without_a_reader_is_text_only_not_an_error (self ): 63notes = self .check ("cuda" ,"linux-x86_64" ,CUDA13 ,variant = "cuda13" ) 64self .assertIn ("text only" ,notes [0 ]) 65 66def test_a_macos_package_without_a_reader_is_refused (self ): 67with self .assertRaises (SystemExit )as cm : 68self .check ("metal" ,"macos-arm64" , ()) 69self .assertIn ("build_vision_mac.sh" ,str (cm .exception )) 70self .assertIn ("pictures are off" ,self .check ("metal" ,"macos-arm64" , (),allow_none = True )[0 ]) 71 72def test_a_macos_package_with_a_reader_passes (self ): 73self .reader () 74self .assertEqual (self .check ("metal" ,"macos-arm64" , ()), []) 75 76def test_build_runs_the_check_only_when_asked (self ): 77self .reader ("75;86;89;120" ) 78out = Path (self .tmp .name )/ "out" 79out .mkdir () 80with self .assertRaises (SystemExit )as cm : 81package_engine .build (self .src ,"cuda" ,"0.2.3" ,"linux-x86_64" ,out ,archs = CUDA12 ,variant = "cuda12" ,build_id = "t" , 82check_reader = True ) 83self .assertIn ("picture reader" ,str (cm .exception )) 84 85def test_stamp_vision_writes_the_record (self ): 86 (self .src / "BUILD.json" ).write_text (json .dumps ({"version" :"0.2.3" ,"archs" :"60;61" })) 87self .assertEqual (package_engine .main (["--stamp-vision" ,str (self .src ),"--vision-archs" ,"60;61;70" ]),0 ) 88data = json .loads ((self .src / "BUILD.json" ).read_text ()) 89self .assertEqual (data ["vision_archs" ],"60;61;70" ) 90self .assertEqual (data ["archs" ],"60;61" ) 91 92 93if __name__ == "__main__" : 94unittest .main ()