okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ef8071303
main
1"""#1445: setup warns when nvidia-smi reports a compute mode other than Default (never refuses). 2 3python -m unittest tools.test_setup_compute_mode 4""" 5from __future__import annotations 6 7import sys 8import unittest 9from pathlib import Path 10from unittest import mock 11 12ROOT = Path (__file__ ).resolve ().parents [1 ] 13sys .path .insert (0 ,str (ROOT )) 14import setup # noqa: E402 15 16 17class Mode (unittest .TestCase ): 18def test_default_is_silent (self ): 19for m in ("Default" ,"default" ,"" ,"[N/A]" ,"N/A" ): 20self .assertIsNone (setup .compute_mode_warning (0 ,m ),m ) 21 22def test_other_modes_warn (self ): 23for m in ("Exclusive_Process" ,"Prohibited" ,"Exclusive_Thread" ): 24w = setup .compute_mode_warning (2 ,m ) 25self .assertIn (m ,w ) 26self .assertIn ("GPU 2" ,w ) 27self .assertIn ("nvidia-smi -i 2 -c DEFAULT" ,w ) 28 29def test_query (self ): 30with mock .patch .object (setup ,"out" ,return_value = "Exclusive_Process\n" )as o : 31self .assertEqual (setup .gpu_compute_mode (1 ),"Exclusive_Process" ) 32self .assertIn ("compute_mode" ," " .join (o .call_args [0 ][0 ])) 33 34 35if __name__ == "__main__" : 36unittest .main ()