From d622a2683fe498d6300c1c7933f6bd59311d72d0 Mon Sep 17 00:00:00 2001 From: gvoskuilen <3968723+gvoskuilen@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:02:08 -0600 Subject: [PATCH] Fix test logic for shared array (#1160) * Fix shared array test * Remove use of deprecated functions in test suites and frameworks --- .../coreTest_SharedObjectComponent.cc | 6 +++--- .../testingframework/sst_unittest_support.py | 8 ++++---- tests/testsuite_default_PerfComponent.py | 2 +- .../testsuite_default_StatisticsComponent.py | 2 +- .../testsuite_default_config_input_output.py | 2 +- tests/testsuite_default_sstinfo.py | 4 ++-- tests/testsuite_testengine_testing.py | 20 +++++++++---------- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/sst/core/testElements/coreTest_SharedObjectComponent.cc b/src/sst/core/testElements/coreTest_SharedObjectComponent.cc index d1f028e28..9e203e9b9 100644 --- a/src/sst/core/testElements/coreTest_SharedObjectComponent.cc +++ b/src/sst/core/testElements/coreTest_SharedObjectComponent.cc @@ -110,9 +110,9 @@ coreTestSharedObjectsComponent::coreTestSharedObjectsComponent(SST::ComponentId_ array.write(myid, myid); } if ( pub ) array.publish(); - int readval = array.mutex_read(myid); - if ( !full_initialization && readval != myid ) { - out.fatal(CALL_INFO, 100, "ERROR: SharedArray does not contain expected data\n"); + if ( !full_initialization ) { + int readval = array.mutex_read(myid); + if ( readval != myid ) { out.fatal(CALL_INFO, 100, "ERROR: SharedArray does not contain expected data\n"); } } } else if ( test_bool_array && !late_initialize ) { diff --git a/src/sst/core/testingframework/sst_unittest_support.py b/src/sst/core/testingframework/sst_unittest_support.py index e4cd6ea7f..28cf81df3 100644 --- a/src/sst/core/testingframework/sst_unittest_support.py +++ b/src/sst/core/testingframework/sst_unittest_support.py @@ -132,8 +132,8 @@ def testing_is_PIN_loaded() -> bool: def testing_is_PIN_Compiled() -> bool: global pin_exec_path - pin_crt = sst_elements_config_include_file_get_value_int("HAVE_PINCRT", 0, True) - pin_exec = sst_elements_config_include_file_get_value_str("PINTOOL_EXECUTABLE", "", True) + pin_crt = sst_elements_config_include_file_get_value(define="HAVE_PINCRT", type=int, default=0, disable_warning=True) + pin_exec = sst_elements_config_include_file_get_value(define="PINTOOL_EXECUTABLE", type=str, default="", disable_warning=True) #log_debug("testing_is_PIN_Compiled() - Detected PIN_CRT = {0}".format(pin_crt)) #log_debug("testing_is_PIN_Compiled() - Detected PIN_EXEC = {0}".format(pin_exec)) pin_exec_path = pin_exec @@ -238,7 +238,7 @@ def host_os_get_distribution_type() -> str: 'ROCKY' for Rocky; 'UNDEFINED' an undefined OS. """ - k_type = host_os_get_kernel_type() + k_type = platform.system() if k_type == 'Linux': lin_dist = _get_linux_distribution() dist_name = lin_dist[0].lower() @@ -262,7 +262,7 @@ def host_os_get_distribution_version() -> str: Returns: (str) The OS distribution version """ - k_type = host_os_get_kernel_type() + k_type = platform.system() if k_type == 'Linux': lin_dist = _get_linux_distribution() return lin_dist[1] diff --git a/tests/testsuite_default_PerfComponent.py b/tests/testsuite_default_PerfComponent.py index 6dcf4ebe8..f08d015b4 100644 --- a/tests/testsuite_default_PerfComponent.py +++ b/tests/testsuite_default_PerfComponent.py @@ -52,7 +52,7 @@ def perf_component_test_template(self, testtype): perfdata_sav = "{0}/PerfComponent_PerfData.out".format(outdir) #if SST was built with SST_PERFORMANCE_INSTRUMENTING enabled, then we will also check that the counters are sane - if(sst_core_config_include_file_get_value_int(define="SST_PERFORMANCE_INSTRUMENTING", default=0, disable_warning=True) > 0): + if(sst_core_config_include_file_get_value(define="SST_PERFORMANCE_INSTRUMENTING", type=int, default=0, disable_warning=True) > 0): if os.path.isfile(perfdata_out): os.system("mv {0} {1}".format(perfdata_out, perfdata_sav)) else: diff --git a/tests/testsuite_default_StatisticsComponent.py b/tests/testsuite_default_StatisticsComponent.py index a430a01ae..73c42cfe6 100644 --- a/tests/testsuite_default_StatisticsComponent.py +++ b/tests/testsuite_default_StatisticsComponent.py @@ -19,7 +19,7 @@ from sst_unittest_support import * -have_h5 = sst_core_config_include_file_get_value_int("HAVE_HDF5", default=0, disable_warning=True) == 1 +have_h5 = sst_core_config_include_file_get_value(define="HAVE_HDF5", type=int, default=0, disable_warning=True) == 1 class testcase_StatisticComponent(SSTTestCase): diff --git a/tests/testsuite_default_config_input_output.py b/tests/testsuite_default_config_input_output.py index bbc7d1b4e..fe1916ec3 100644 --- a/tests/testsuite_default_config_input_output.py +++ b/tests/testsuite_default_config_input_output.py @@ -18,7 +18,7 @@ from sst_unittest_support import * -have_mpi = sst_core_config_include_file_get_value_int("SST_CONFIG_HAVE_MPI", default=0, disable_warning=True) == 1 +have_mpi = sst_core_config_include_file_get_value(define="SST_CONFIG_HAVE_MPI", type=int, default=0, disable_warning=True) == 1 class testcase_Config_input_output(SSTTestCase): diff --git a/tests/testsuite_default_sstinfo.py b/tests/testsuite_default_sstinfo.py index a7de57b38..a9e53766e 100644 --- a/tests/testsuite_default_sstinfo.py +++ b/tests/testsuite_default_sstinfo.py @@ -15,7 +15,7 @@ from sst_unittest_support import * -have_curses = sst_core_config_include_file_get_value_int("HAVE_CURSES", default=0, disable_warning=True) == 1 +have_curses = sst_core_config_include_file_get_value(define="HAVE_CURSES", type=int, default=0, disable_warning=True) == 1 class testcase_sstinfo(SSTTestCase): @@ -47,7 +47,7 @@ def sstinfo_test_template(self, testtype, flags): errfile = "{0}/test_sstinfo_{1}.err".format(outdir, testtype) # Get the path to sst-info binary application - sst_app_path = sstsimulator_conf_get_value_str('SSTCore', 'bindir', default="UNDEFINED") + sst_app_path = sstsimulator_conf_get_value(section='SSTCore', key='bindir', type=str, default="UNDEFINED") err_str = "Path to SST-INFO {0}; does not exist...".format(sst_app_path) self.assertTrue(os.path.isdir(sst_app_path), err_str) diff --git a/tests/testsuite_testengine_testing.py b/tests/testsuite_testengine_testing.py index 5b0d60d0c..39fd18c94 100644 --- a/tests/testsuite_testengine_testing.py +++ b/tests/testsuite_testengine_testing.py @@ -109,14 +109,14 @@ def tearDown(self): ############################################################################ # Test read access of the sstsimulator configuration file - # Note: We can only test the sstsimulator_conf_get_value_str(); as we have - # No generic entries for _int, _float, _bool + # Note: We can only test the sstsimulator_conf_get_value() with type=str; + # as we have no generic entries for _int, _float, _bool ############################################################################ def test_support_functions_get_info_from_sstsimulator_conf_success(self): # This should pass as we give valid data log_forced("NOTE: This Test Has an Expected Pass and should show as 'PASS'") - sourcedir = sstsimulator_conf_get_value_str("SSTCore", "sourcedir") + sourcedir = sstsimulator_conf_get_value(section="SSTCore", key="sourcedir", type=str) log_forced("SSTCore SourceDir = {0}; Type = {1}".format(sourcedir, type(sourcedir))) self.assertIsInstance(sourcedir, str) @@ -124,18 +124,18 @@ def test_support_functions_get_info_from_sstsimulator_conf_invalid_section_excep # This should pass as we detect an expected exception due to invalid section log_forced("NOTE: This Test Has an Expected Pass (BUT GENERATES A WARNING) and should show as 'PASS'") with self.assertRaises(SSTTestCaseException): - sstsimulator_conf_get_value_str("invalid_section", "invalid_key") + sstsimulator_conf_get_value(section="invalid_section", key="invalid_key", type=str) @unittest.expectedFailure def test_support_functions_get_info_from_sstsimulator_conf_invalid_key_exception_error(self): # This should give an error as we detect an exception due to invalid key log_forced("NOTE: This Test Has an Expected ERROR (BUT GENERATES A WARNING) and should show as 'EXPECTED FAILURE'") - sstsimulator_conf_get_value_str("SSTCore", "invalid_key") + sstsimulator_conf_get_value(section="SSTCore", key="invalid_key", type=str) def test_support_functions_get_info_from_sstsimulator_conf_invalid_key_rtn_default_success_with_warning(self): # This should pass by failing to find a valid key and returning a default, but should log a warning log_forced("NOTE: This Test Has an Expected Pass (BUT GENERATES A WARNING) and should show as 'PASS'") - sourcedir = sstsimulator_conf_get_value_str("SSTCore", "invalid_key", "kilroy_was_here") + sourcedir = sstsimulator_conf_get_value(section="SSTCore", key="invalid_key", type=str, default="kilroy_was_here") log_forced("SSTCore SourceDir = {0}".format(sourcedir)) self.assertEqual(str, type(sourcedir)) self.assertEqual("kilroy_was_here", sourcedir) @@ -197,7 +197,7 @@ def test_support_functions_get_all_key_vaules_from_section_from_sstsimulator_con def test_support_functions_get_info_from_sst_config_h_valid_key_rtn_int_success(self): # This should pass as we give/get valid data log_forced("NOTE: This Test Has an Expected Pass and should show as 'PASS'") - test_define = sst_config_include_file_get_value_int("HAVE_CLOSEDIR", 123) + test_define = sst_config_include_file_get_value(define="HAVE_CLOSEDIR", type=int, default=123) log_forced("#define HAVE_CLOSEDIR={0}; type={1}".format(test_define, type(test_define))) self.assertEqual(1, test_define) self.assertEqual(int, type(test_define)) @@ -205,7 +205,7 @@ def test_support_functions_get_info_from_sst_config_h_valid_key_rtn_int_success( def test_support_functions_get_info_from_sst_config_h_valid_key_rtn_str_success(self): # This should pass as we give/get valid data log_forced("NOTE: This Test Has an Expected Pass and should show as 'PASS'") - test_define = sst_config_include_file_get_value_str("PACKAGE_BUGREPORT", "THIS_IS_DEFAULT_DATA") + test_define = sst_config_include_file_get_value(define="PACKAGE_BUGREPORT", type=str, default="THIS_IS_DEFAULT_DATA") log_forced("#define PACKAGE_BUGREPORT={0}; type={1}".format(test_define, type(test_define))) self.assertEqual("sst@sandia.gov", test_define) self.assertEqual(str, type(test_define)) @@ -214,7 +214,7 @@ def test_support_functions_get_info_from_sst_config_h_invalid_key_rtn_default_st # This should pass as we give valid data log_forced("NOTE: This Test Has an Expected Pass (BUT GENERATES A WARNING) and should show as 'PASS'") # This should pass by returning a default, but should log a warning - test_define = sst_config_include_file_get_value_str("PACKAGE_BUGREPORT_KEYINVALID", "THIS_IS_DEFAULT_DATA") + test_define = sst_config_include_file_get_value(define="PACKAGE_BUGREPORT_KEYINVALID", type=str, default="THIS_IS_DEFAULT_DATA") log_forced("#define PACKAGE_BUGREPORT_KEYINVALID={0}; type={1}".format(test_define, type(test_define))) self.assertEqual("THIS_IS_DEFAULT_DATA", test_define) self.assertEqual(str, type(test_define)) @@ -223,7 +223,7 @@ def test_support_functions_get_info_from_sst_config_h_invalid_key_exception_succ # This should pass as we detect an expected exception log_forced("NOTE: This Test Has an Expected Pass (BUT GENERATES A WARNING) and should show as 'PASS'") with self.assertRaises(SSTTestCaseException): - test_define = sst_config_include_file_get_value_str("PACKAGE_BUGREPORT_KEYINVALID") + test_define = sst_config_include_file_get_value(define="PACKAGE_BUGREPORT_KEYINVALID", type=str) log_forced("#define PACKAGE_BUGREPORT_KEYINVALID={0}; type={1}".format(test_define, type(test_define))) ############################################################################