Skip to content

Commit 0dba1d9

Browse files
Merge pull request sstsimulator#1631 from sstsimulator/devel
Automatically Merged using SST Master Branch Merger
2 parents 7c260c5 + 837f349 commit 0dba1d9

3 files changed

Lines changed: 4 additions & 117 deletions

File tree

src/sst/core/testingframework/sst_unittest.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import test_engine_globals
3434
from sst_unittest_support import *
3535
from test_engine_junit import JUnitTestSuite, junit_to_xml_report_file
36-
from test_engine_support import check_param_type, strclass, strqual
36+
from test_engine_support import strclass, strqual
3737

3838
if not sys.warnoptions:
3939
import warnings
@@ -274,25 +274,6 @@ def run_sst(
274274
if global_args is None:
275275
global_args = test_engine_globals.TESTENGINE_SSTRUN_GLOBALARGS
276276

277-
# Make sure arguments are of valid types
278-
check_param_type("sdl_file", sdl_file, str)
279-
check_param_type("out_file", out_file, str)
280-
if err_file is not None:
281-
check_param_type("err_file", err_file, str)
282-
if set_cwd is not None:
283-
check_param_type("set_cwd", set_cwd, str)
284-
check_param_type("mpi_out_files", mpi_out_files, str)
285-
check_param_type("other_args", other_args, str)
286-
if num_ranks is not None:
287-
check_param_type("num_ranks", num_ranks, int)
288-
if num_threads is not None:
289-
check_param_type("num_threads", num_threads, int)
290-
if global_args is not None:
291-
check_param_type("global_args", global_args, str)
292-
check_param_type("timeout_sec", timeout_sec, int)
293-
if expected_rc is not None:
294-
check_param_type("expected_rc", expected_rc, int)
295-
296277
# Make sure sdl file is exists and is a file, if check_sdl_file flag is True
297278
if check_sdl_file:
298279
if not os.path.exists(sdl_file) or not os.path.isfile(sdl_file):

src/sst/core/testingframework/sst_unittest_support.py

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
from warnings import warn
4141

4242
import test_engine_globals
43-
from test_engine_support import check_param_type
4443

4544
if TYPE_CHECKING:
4645
from sst_unittest import SSTTestCase
@@ -249,7 +248,6 @@ def _testing_check_is_scenario_filtering_enabled(scenario_name: str) -> bool:
249248
Returns:
250249
(bool) True if the scenario filter name is enabled
251250
"""
252-
check_param_type("scenario_name", scenario_name, str)
253251
return scenario_name in test_engine_globals.TESTENGINE_SCENARIOSLIST
254252

255253
###
@@ -265,8 +263,6 @@ def skip_on_scenario(scenario_name: str, reason: str) -> Callable[[_FT], _FT]:
265263
scenario_name (str): The scenario filter name to check
266264
reason (str): The reason for the skip
267265
"""
268-
check_param_type("scenario_name", scenario_name, str)
269-
check_param_type("reason", reason, str)
270266
if not _testing_check_is_scenario_filtering_enabled(scenario_name):
271267
return lambda func: func
272268
return unittest.skip(reason)
@@ -339,9 +335,6 @@ def skip_on_sstsimulator_conf_empty_str(section: str, key: str, reason: str) ->
339335
key (str): The key in the sstsimulator.conf to check
340336
reason (str): The reason for the skip
341337
"""
342-
check_param_type("section", section, str)
343-
check_param_type("key", key, str)
344-
check_param_type("reason", reason, str)
345338
rtn_str = sstsimulator_conf_get_value(section, key, str, "")
346339
if rtn_str != "":
347340
return lambda func: func
@@ -469,7 +462,6 @@ def sstsimulator_conf_get_section_keys(section: str) -> List[str]:
469462
Raises:
470463
SSTTestCaseException: If an error occurs
471464
"""
472-
check_param_type("section", section, str)
473465
core_conf_file_parser = test_engine_globals.TESTENGINE_CORE_CONFFILE_PARSER
474466
try:
475467
return core_conf_file_parser.options(section)
@@ -491,7 +483,6 @@ def sstsimulator_conf_get_all_keys_values_from_section(section: str) -> List[Tup
491483
Raises:
492484
SSTTestCaseException: If an error occurs
493485
"""
494-
check_param_type("section", section, str)
495486
core_conf_file_parser = test_engine_globals.TESTENGINE_CORE_CONFFILE_PARSER
496487
try:
497488
return core_conf_file_parser.items(section)
@@ -513,7 +504,6 @@ def sstsimulator_conf_does_have_section(section: str) -> bool:
513504
Raises:
514505
SSTTestCaseException: If an error occurs
515506
"""
516-
check_param_type("section", section, str)
517507
core_conf_file_parser = test_engine_globals.TESTENGINE_CORE_CONFFILE_PARSER
518508
try:
519509
return core_conf_file_parser.has_section(section)
@@ -535,8 +525,6 @@ def sstsimulator_conf_does_have_key(section: str, key: str) -> bool:
535525
Raises:
536526
SSTTestCaseException: If an error occurs
537527
"""
538-
check_param_type("section", section, str)
539-
check_param_type("key", key, str)
540528
core_conf_file_parser = test_engine_globals.TESTENGINE_CORE_CONFFILE_PARSER
541529
try:
542530
return core_conf_file_parser.has_option(section, key)
@@ -555,7 +543,6 @@ def log(logstr: str) -> None:
555543
Args:
556544
logstr (str): string to be logged
557545
"""
558-
check_param_type("logstr", logstr, str)
559546
if test_engine_globals.TESTENGINE_VERBOSITY >= test_engine_globals.VERBOSE_NORMAL:
560547
log_forced(logstr)
561548

@@ -570,7 +557,6 @@ def log_forced(logstr: str) -> None:
570557
Args:
571558
logstr (str): string to be logged
572559
"""
573-
check_param_type("logstr", logstr, str)
574560
extra_lf = ""
575561
if test_engine_globals.TESTRUN_TESTRUNNINGFLAG:
576562
extra_lf = "\n"
@@ -619,7 +605,6 @@ def log_info(logstr: str, forced: bool = True) -> None:
619605
forced (bool): If true Always force the logging regardless of verbosity;
620606
otherwise, perform a normal log.
621607
"""
622-
check_param_type("logstr", logstr, str)
623608
finalstr = "INFO: {0}".format(logstr)
624609
if forced:
625610
log_forced(finalstr)
@@ -635,7 +620,6 @@ def log_error(logstr: str) -> None:
635620
Args:
636621
logstr (str): string to be logged
637622
"""
638-
check_param_type("logstr", logstr, str)
639623
finalstr = "ERROR: {0}".format(logstr)
640624
log_forced(finalstr)
641625
test_engine_globals.TESTENGINE_ERRORCOUNT += 1
@@ -650,7 +634,6 @@ def log_warning(logstr: str) -> None:
650634
Args:
651635
logstr (str): string to be logged
652636
"""
653-
check_param_type("logstr", logstr, str)
654637
finalstr = "WARNING: {0}".format(logstr)
655638
log_forced(finalstr)
656639

@@ -665,7 +648,6 @@ def log_fatal(errstr: str) -> None:
665648
Args:
666649
errstr (str): string to be logged
667650
"""
668-
check_param_type("errstr", errstr, str)
669651
finalstr = "FATAL: {0}".format(errstr)
670652
log_forced(finalstr)
671653
sys.exit(2)
@@ -686,7 +668,6 @@ def log_testing_note(note_str: str) -> None:
686668
Args:
687669
note_str (str): string to be added to notes list
688670
"""
689-
check_param_type("note_str", note_str, str)
690671
final_note = "NOTE: {0}".format(note_str)
691672
test_engine_globals.TESTENGINE_TESTNOTESLIST.append(final_note)
692673
log_debug(final_note)
@@ -738,10 +719,6 @@ def combine_per_rank_files(
738719
No return value
739720
740721
"""
741-
check_param_type("filename", filename, str)
742-
check_param_type("header_lines_to_remove", header_lines_to_remove, int)
743-
check_param_type("remove_header_from_first_file", remove_header_from_first_file, bool)
744-
745722
# Get the number of MPI ranks
746723
ranks = testing_check_get_num_ranks()
747724

@@ -1168,12 +1145,8 @@ def testing_compare_filtered_diff(
11681145
11691146
"""
11701147

1171-
check_param_type("test_name", test_name, str)
1172-
check_param_type("outfile", outfile, str)
1173-
check_param_type("reffile", reffile, str)
11741148
if isinstance(filters, LineFilter):
11751149
filters = [filters]
1176-
check_param_type("filters", filters, list)
11771150

11781151
if not os.path.isfile(outfile):
11791152
log_error("Cannot diff files: Out File {0} does not exist".format(outfile))
@@ -1221,10 +1194,6 @@ def testing_compare_diff(
12211194
Returns:
12221195
(bool) True if the 2 files match.
12231196
"""
1224-
check_param_type("test_name", test_name, str)
1225-
check_param_type("outfile", outfile, str)
1226-
check_param_type("reffile", reffile, str)
1227-
check_param_type("ignore_ws", ignore_ws, bool)
12281197

12291198
if ignore_ws:
12301199
return testing_compare_filtered_diff(test_name, outfile, reffile, False, [IgnoreWhiteSpaceFilter()])
@@ -1246,9 +1215,6 @@ def testing_compare_sorted_diff(test_name: str, outfile: str, reffile: str) -> b
12461215
(bool) True if the 2 sorted files match
12471216
12481217
"""
1249-
check_param_type("test_name", test_name, str)
1250-
check_param_type("outfile", outfile, str)
1251-
check_param_type("reffile", reffile, str)
12521218
return testing_compare_filtered_diff(test_name, outfile, reffile, True)
12531219

12541220

@@ -1274,11 +1240,8 @@ def testing_compare_filtered_subset(
12741240
12751241
"""
12761242

1277-
check_param_type("outfile", outfile, str)
1278-
check_param_type("reffile", reffile, str)
12791243
if isinstance(filters, LineFilter):
12801244
filters = [filters]
1281-
check_param_type("filters", filters, list)
12821245

12831246
if not os.path.isfile(outfile):
12841247
log_error("Cannot diff files: Out File {0} does not exist".format(outfile))
@@ -1313,7 +1276,6 @@ def testing_get_diff_data(test_name: str) -> str:
13131276
(str) The diff data file if it exists; otherwise an empty string
13141277
13151278
"""
1316-
check_param_type("test_name", test_name, str)
13171279

13181280
diff_file = "{1}/{0}_diff_file".format(test_name, test_output_get_tmp_dir())
13191281

@@ -1345,10 +1307,6 @@ def testing_merge_mpi_files(
13451307
errorfilepath (str): The output file path for stderr. If none, stderr redirects to stdout.
13461308
"""
13471309

1348-
check_param_type("filepath_wildcard", filepath_wildcard, str)
1349-
check_param_type("mpiout_filename", mpiout_filename, str)
1350-
check_param_type("outputfilepath", outputfilepath, str)
1351-
13521310
# Delete any output files that might exist
13531311
cmd = "rm -rf {0}".format(outputfilepath)
13541312
os.system(cmd)
@@ -1396,7 +1354,6 @@ def testing_remove_component_warning_from_file(input_filepath: str) -> None:
13961354
Args:
13971355
input_filepath (str): Path to the file to have warnings removed from
13981356
"""
1399-
check_param_type("input_filepath", input_filepath, str)
14001357

14011358
bad_string = 'WARNING: No components are'
14021359
_remove_lines_with_string_from_file(bad_string, input_filepath)
@@ -1469,7 +1426,6 @@ def run(self,
14691426
will be terminated and a timeout error will occur.
14701427
kwargs: Extra parameters e.g., timeout_sec to override the default timeout
14711428
"""
1472-
check_param_type("timeout_sec", timeout_sec, int)
14731429

14741430
self._timeout_sec = timeout_sec
14751431
self._signal = send_signal
@@ -1654,7 +1610,6 @@ def os_ls(directory: str = ".", echo_out: bool = True, **kwargs: Any) -> str:
16541610
Returns:
16551611
(str) Output from ls command
16561612
"""
1657-
check_param_type("directory", directory, str)
16581613
cmd = "ls -lia {0}".format(directory)
16591614
rtn = os_command(cmd).run(**kwargs)
16601615
if echo_out:
@@ -1685,7 +1640,6 @@ def os_cat(filepath: str, echo_out: bool = True, **kwargs: Any) -> str:
16851640
Returns:
16861641
(str) Output from cat command
16871642
"""
1688-
check_param_type("filepath", filepath, str)
16891643
cmd = "cat {0}".format(filepath)
16901644
rtn = os_command(cmd).run(**kwargs)
16911645
if echo_out:
@@ -1700,9 +1654,7 @@ def os_symlink_file(srcdir: str, destdir: str, filename: str) -> None:
17001654
destdir (str): Path to destination dir of the file
17011655
filename (str): Name of the file
17021656
"""
1703-
check_param_type("srcdir", srcdir, str)
1704-
check_param_type("destdir", destdir, str)
1705-
check_param_type("filename", filename, str)
1657+
17061658
srcfilepath = "{0}/{1}".format(srcdir, filename)
17071659
dstfilepath = "{0}/{1}".format(destdir, filename)
17081660
os.symlink(srcfilepath, dstfilepath)
@@ -1714,8 +1666,7 @@ def os_symlink_dir(srcdir: str, destdir: str) -> None:
17141666
srcdir (str): Path to source dir
17151667
destdir (str): Path to destination dir
17161668
"""
1717-
check_param_type("srcdir", srcdir, str)
1718-
check_param_type("destdir", destdir, str)
1669+
17191670
os.symlink(srcdir, destdir)
17201671

17211672
def os_awk_print(in_str: str, fields_index_list: List[int]) -> str:
@@ -1736,12 +1687,7 @@ def os_awk_print(in_str: str, fields_index_list: List[int]) -> str:
17361687
DeprecationWarning,
17371688
stacklevel=2,
17381689
)
1739-
check_param_type("in_str", in_str, bytes)
1740-
else:
1741-
check_param_type("in_str", in_str, str)
1742-
check_param_type("fields_index_list", fields_index_list, list)
1743-
for index, field_index in enumerate(fields_index_list):
1744-
check_param_type("field_index - {0}".format(index), field_index, int)
1690+
17451691
finalstrdata = ""
17461692
split_list = in_str.split()
17471693
for field_index in fields_index_list:
@@ -1760,10 +1706,6 @@ def os_wc(in_file: str, fields_index_list: List[int] = [], **kwargs: Any) -> str
17601706
Returns:
17611707
(str) Space separated string of extracted fields.
17621708
"""
1763-
check_param_type("in_file", in_file, str)
1764-
check_param_type("fields_index_list", fields_index_list, list)
1765-
for index, field_index in enumerate(fields_index_list):
1766-
check_param_type("field_index - {0}".format(index), field_index, int)
17671709
cmd = "wc {0}".format(in_file)
17681710
rtn = os_command(cmd).run(**kwargs)
17691711
wc_out = rtn.output()
@@ -1781,8 +1723,6 @@ def os_test_file(file_path: str, expression: str = "-e", **kwargs: Any) -> bool:
17811723
Returns:
17821724
(bool) True if test is successful.
17831725
"""
1784-
check_param_type("file_path", file_path, str)
1785-
check_param_type("expression", expression, str)
17861726
if os.path.exists(file_path):
17871727
cmd = "test {0} {1}".format(expression, file_path)
17881728
rtn = os_command(cmd).run(**kwargs)
@@ -1811,12 +1751,6 @@ def os_wget(
18111751
Returns:
18121752
(bool) True if wget is successful.
18131753
"""
1814-
check_param_type("fileurl", fileurl, str)
1815-
check_param_type("targetdir", targetdir, str)
1816-
check_param_type("num_tries", num_tries, int)
1817-
check_param_type("secsbetweentries", secsbetweentries, int)
1818-
check_param_type("wgetparams", wgetparams, str)
1819-
18201754
wget_success = False
18211755

18221756
wget_loc = which("wget")
@@ -1973,10 +1907,6 @@ def _get_sst_config_include_file_value(
19731907
"""
19741908
if data_type not in (int, str):
19751909
raise SSTTestCaseException("Illegal datatype {0}".format(data_type))
1976-
check_param_type("include_source", include_source, str)
1977-
check_param_type("define", define, str)
1978-
if default is not None:
1979-
check_param_type("default", default, data_type)
19801910
try:
19811911
rtn_data = include_dict[define]
19821912
except KeyError as exc_e:
@@ -2006,10 +1936,6 @@ def _get_sstsimulator_conf_value(
20061936
"""
20071937
if data_type not in (int, str, float, bool):
20081938
raise SSTTestCaseException("Illegal datatype {0}".format(data_type))
2009-
check_param_type("section", section, str)
2010-
check_param_type("key", key, str)
2011-
if default is not None:
2012-
check_param_type("default", default, data_type)
20131939
core_conf_file_parser = test_engine_globals.TESTENGINE_CORE_CONFFILE_PARSER
20141940
try:
20151941
if data_type is str:

src/sst/core/testingframework/test_engine_support.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,9 @@
1515
functions
1616
"""
1717

18-
import inspect
1918
from typing import Any, Type
2019

2120

22-
def check_param_type(varname: str, vardata: Any, datatype: Type[Any]) -> None:
23-
""" Validate a parameter to ensure it is of the correct type.
24-
25-
Args:
26-
varname (str) = The string name of the variable
27-
vardata (???) = The actual variable of any type
28-
datatype (???) = The type that we want to confirm
29-
30-
Raises:
31-
ValueErr: variable is not of the correct type.
32-
"""
33-
caller = inspect.stack()[1][3]
34-
if not isinstance(vardata, datatype):
35-
err_str = (("TEST-ERROR: {0}() param {1} = {2} is a not a {3}; it is a ") +
36-
("{4}")).format(caller, varname, vardata, datatype, type(vardata))
37-
print(err_str)
38-
raise ValueError(err_str)
39-
40-
4121
################################################################################
4222

4323
def strclass(cls: Type[Any]) -> str:

0 commit comments

Comments
 (0)