|
28 | 28 | import threading |
29 | 29 | import signal |
30 | 30 | import time |
| 31 | +import multiprocessing |
31 | 32 | from typing import Optional |
32 | 33 |
|
33 | 34 | import test_engine_globals |
@@ -58,11 +59,10 @@ class SSTTestCase(unittest.TestCase): |
58 | 59 | def __init__(self, methodName: str) -> None: |
59 | 60 | # NOTE: __init__ is called at startup for all tests before any |
60 | 61 | # setUpModules(), setUpClass(), setUp() and the like are called. |
61 | | - super(SSTTestCase, self).__init__(methodName) |
| 62 | + super().__init__(methodName) |
62 | 63 | self.testname = methodName |
63 | | - parent_module_path: str = os.path.dirname(sys.modules[self.__class__.__module__].__file__) # type: ignore |
| 64 | + parent_module_path: str = os.path.dirname(sys.modules[self.__class__.__module__].__file__) # type: ignore [assignment,type-var] |
64 | 65 | self._testsuite_dirpath = parent_module_path |
65 | | - #log_forced("SSTTestCase: __init__() - {0}".format(self.testname)) |
66 | 66 | self.initializeClass(self.testname) |
67 | 67 | self._start_test_time = time.time() |
68 | 68 | self._stop_test_time = time.time() |
@@ -195,7 +195,7 @@ def get_testsuite_dir(self) -> str: |
195 | 195 | """ Return the directory path of the testsuite that is being run |
196 | 196 |
|
197 | 197 | Returns: |
198 | | - (str)The path of the testsite directory |
| 198 | + (str) The path of the testsite directory |
199 | 199 | """ |
200 | 200 | return self._testsuite_dirpath |
201 | 201 |
|
@@ -235,9 +235,23 @@ def get_test_runtime_sec(self) -> float: |
235 | 235 | ### Method to run an SST simulation |
236 | 236 | ################################################################################ |
237 | 237 |
|
238 | | - def run_sst(self, sdl_file, out_file, err_file=None, set_cwd=None, mpi_out_files="", |
239 | | - other_args="", num_ranks=None, num_threads=None, global_args=None, |
240 | | - timeout_sec=120, expected_rc=0, check_sdl_file=True, send_signal=signal.NSIG, signal_sec=3): |
| 238 | + def run_sst( |
| 239 | + self, |
| 240 | + sdl_file: str, |
| 241 | + out_file: str, |
| 242 | + err_file: Optional[str] = None, |
| 243 | + set_cwd: Optional[str] = None, |
| 244 | + mpi_out_files: str = "", |
| 245 | + other_args: str = "", |
| 246 | + num_ranks: Optional[int] = None, |
| 247 | + num_threads: Optional[int] = None, |
| 248 | + global_args: Optional[str] = None, |
| 249 | + timeout_sec: int = 120, |
| 250 | + expected_rc: int = 0, |
| 251 | + check_sdl_file: bool = True, |
| 252 | + send_signal: int = signal.NSIG, |
| 253 | + signal_sec: int = 3 |
| 254 | + ) -> str: |
241 | 255 | """ Launch sst with with the command line and send output to the |
242 | 256 | output file. The SST execution will be monitored for result errors and |
243 | 257 | timeouts. On an error or timeout, a SSTTestCase.assert() will be generated |
@@ -288,8 +302,7 @@ def run_sst(self, sdl_file, out_file, err_file=None, set_cwd=None, mpi_out_files |
288 | 302 | check_param_type("num_threads", num_threads, int) |
289 | 303 | if global_args is not None: |
290 | 304 | check_param_type("global_args", global_args, str) |
291 | | - if not (isinstance(timeout_sec, (int, float)) and not isinstance(timeout_sec, bool)): |
292 | | - raise ValueError("ERROR: Timeout_sec must be a postive int or a float") |
| 305 | + check_param_type("timeout_sec", timeout_sec, int) |
293 | 306 | if expected_rc is not None: |
294 | 307 | check_param_type("expected_rc", expected_rc, int) |
295 | 308 |
|
@@ -331,8 +344,8 @@ def run_sst(self, sdl_file, out_file, err_file=None, set_cwd=None, mpi_out_files |
331 | 344 | numa_param = "" |
332 | 345 | if num_ranks > 1: |
333 | 346 | # Check to see if mpirun is available |
334 | | - rtn = os.system("which mpirun > /dev/null 2>&1") |
335 | | - if rtn == 0: |
| 347 | + rtn_mpirun = os.system("which mpirun > /dev/null 2>&1") |
| 348 | + if rtn_mpirun == 0: |
336 | 349 | mpi_avail = True |
337 | 350 |
|
338 | 351 | numa_param = "-map-by numa:PE={0}".format(num_threads) |
@@ -433,7 +446,7 @@ def tearDownModule() -> None: |
433 | 446 |
|
434 | 447 | ################### |
435 | 448 |
|
436 | | -def setUpModuleConcurrent(test): |
| 449 | +def setUpModuleConcurrent(test: SSTTestCase) -> None: |
437 | 450 | """ Perform setup functions before the testing Module loads. |
438 | 451 |
|
439 | 452 | This function is called by the Frameworks before tests in any TestCase |
@@ -461,7 +474,7 @@ def setUpModuleConcurrent(test): |
461 | 474 |
|
462 | 475 | ### |
463 | 476 |
|
464 | | -def tearDownModuleConcurrent(test): |
| 477 | +def tearDownModuleConcurrent(test: SSTTestCase) -> None: |
465 | 478 | """ Perform teardown functions immediately after a testing Module finishes. |
466 | 479 |
|
467 | 480 | This function is called by the Frameworks after all tests in all TestCases |
|
0 commit comments