/tests/testsuite_default_UnitAlgebra.py

https://github.com/sstsimulator/sst-core
Python | 64 lines | 34 code | 18 blank | 12 comment | 2 complexity | 74f258a0369ced148304c909ab0e614f MD5 | raw file
  1. # -*- coding: utf-8 -*-
  2. from sst_unittest import *
  3. from sst_unittest_support import *
  4. ################################################################################
  5. # Code to support a single instance module initialize, must be called setUp method
  6. module_init = 0
  7. module_sema = threading.Semaphore()
  8. def initializeTestModule_SingleInstance(class_inst):
  9. global module_init
  10. global module_sema
  11. module_sema.acquire()
  12. if module_init != 1:
  13. # Put your single instance Init Code Here
  14. module_init = 1
  15. module_sema.release()
  16. ################################################################################
  17. class testcase_UnitAlgebra(SSTTestCase):
  18. def initializeClass(self, testName):
  19. super(type(self), self).initializeClass(testName)
  20. # Put test based setup code here. it is called before testing starts
  21. # NOTE: This method is called once for every test
  22. def setUp(self):
  23. super(type(self), self).setUp()
  24. initializeTestModule_SingleInstance(self)
  25. # Put test based setup code here. it is called once before every test
  26. def tearDown(self):
  27. # Put test based teardown code here. it is called once after every test
  28. super(type(self), self).tearDown()
  29. #####
  30. def test_UnitAlgebra(self):
  31. self.unitalgebra_test_template("UnitAlgebra")
  32. #####
  33. def unitalgebra_test_template(self, testtype):
  34. testsuitedir = self.get_testsuite_dir()
  35. outdir = test_output_get_run_dir()
  36. sdlfile = "{0}/test_{1}.py".format(testsuitedir, testtype)
  37. reffile = "{0}/refFiles/test_{1}.out".format(testsuitedir, testtype)
  38. outfile = "{0}/test_{1}.out".format(outdir, testtype)
  39. self.run_sst(sdlfile, outfile)
  40. testing_remove_component_warning_from_file(outfile)
  41. # Perform the test
  42. cmp_result = testing_compare_sorted_diff(testtype, outfile, reffile)
  43. if (cmp_result == False):
  44. diffdata = testing_get_diff_data("UnitAlgebra")
  45. log_failure(diffdata)
  46. self.assertTrue(cmp_result, "Output/Compare file {0} does not match Reference File {1}".format(outfile, reffile))