1- # Copyright 2024 Arm Limited and/or its affiliates.
1+ # Copyright 2024-2025 Arm Limited and/or its affiliates.
22#
33# This source code is licensed under the BSD-style license found in the
44# LICENSE file in the root directory of this source tree.
77import os
88import platform
99import random
10- import re
1110import shutil
1211import subprocess
1312import sys
2524
2625
2726def pytest_configure (config ):
28- pytest ._test_options = {}
2927
30- if config .option .arm_quantize_io :
31- _load_libquantized_ops_aot_lib ()
32- pytest ._test_options ["quantize_io" ] = True
28+ pytest ._test_options = {} # type: ignore[attr-defined]
29+
3330 if config .option .arm_run_corstoneFVP :
3431 corstone300_exists = shutil .which ("FVP_Corstone_SSE-300_Ethos-U55" )
3532 corstone320_exists = shutil .which ("FVP_Corstone_SSE-320" )
3633 if not (corstone300_exists and corstone320_exists ):
3734 raise RuntimeError (
3835 "Tests are run with --arm_run_corstoneFVP but corstone FVP is not installed."
3936 )
40- pytest ._test_options ["corstone_fvp" ] = True
41- pytest ._test_options ["fast_fvp" ] = config .option .fast_fvp
37+ pytest ._test_options ["corstone_fvp" ] = True # type: ignore[attr-defined]
38+ pytest ._test_options ["fast_fvp" ] = config .option .fast_fvp # type: ignore[attr-defined]
4239 logging .basicConfig (level = logging .INFO , stream = sys .stdout )
4340
4441
4542def pytest_collection_modifyitems (config , items ):
46- """
47- Skip all tests that require run on Ethos-U if the option arm_quantize_io is
48- not set.
49- """
50- if not config .option .arm_quantize_io :
51- skip_if_aot_lib_not_loaded = pytest .mark .skip (
52- "Ethos-U tests can only run on FVP with quantize_io=True."
53- )
54-
55- for item in items :
56- if re .search (r"u55|u65|u85" , item .name , re .IGNORECASE ):
57- item .add_marker (skip_if_aot_lib_not_loaded )
43+ pass
5844
5945
6046def pytest_addoption (parser ):
61- parser .addoption ("--arm_quantize_io" , action = "store_true" )
47+ parser .addoption ("--arm_quantize_io" , action = "store_true" , help = "Deprecated." )
6248 parser .addoption ("--arm_run_corstoneFVP" , action = "store_true" )
6349 parser .addoption ("--fast_fvp" , action = "store_true" )
6450
6551
6652def pytest_sessionstart (session ):
67- pass
53+ if not session .config .option .collectonly :
54+ _load_libquantized_ops_aot_lib ()
6855
6956
7057def pytest_sessionfinish (session , exitstatus ):
@@ -128,15 +115,12 @@ def is_option_enabled(option: str, fail_if_not_enabled: bool = False) -> bool:
128115 """
129116 Returns whether an option is successfully enabled, i.e. if the flag was
130117 given to pytest and the necessary requirements are available.
131- Implemented options are:
132- - corstone_fvp.
133- - quantize_io.
134118
135119 The optional parameter 'fail_if_not_enabled' makes the function raise
136120 a RuntimeError instead of returning False.
137121 """
138122
139- if option in pytest ._test_options and pytest ._test_options [option ]:
123+ if option in pytest ._test_options and pytest ._test_options [option ]: # type: ignore[attr-defined]
140124 return True
141125 else :
142126 if fail_if_not_enabled :
@@ -152,15 +136,14 @@ def get_option(option: str) -> Any | None:
152136 Args:
153137 option (str): The option to check for.
154138 """
155- if option in pytest ._test_options :
156- return pytest ._test_options [option ]
139+ if option in pytest ._test_options : # type: ignore[attr-defined]
140+ return pytest ._test_options [option ] # type: ignore[attr-defined]
157141 return None
158142
159143
160144def _load_libquantized_ops_aot_lib ():
161145 """
162- Load the libquantized_ops_aot_lib shared library. It's required when
163- arm_quantize_io is set.
146+ Find and load the libquantized_ops_aot_lib shared library.
164147 """
165148 so_ext = {
166149 "Darwin" : "dylib" ,
@@ -181,5 +164,5 @@ def _load_libquantized_ops_aot_lib():
181164 torch .ops .load_library (library_path )
182165 else :
183166 raise RuntimeError (
184- f"Failed to load libquantized_ops_aot_lib.{ so_ext } . Did you build it?"
167+ f"Did not find libquantized_ops_aot_lib.{ so_ext } in cmake-out-aot-lib . Did you build it?"
185168 )
0 commit comments