Added unit testing for to_dict method
This commit is contained in:
parent
5d5d3c5858
commit
339f4bfd23
@ -6,6 +6,7 @@
|
|||||||
import platform
|
import platform
|
||||||
import spack
|
import spack
|
||||||
from spack.architecture import *
|
from spack.architecture import *
|
||||||
|
import spack.spec
|
||||||
from spack.platforms.cray_xc import CrayXc
|
from spack.platforms.cray_xc import CrayXc
|
||||||
from spack.platforms.linux import Linux
|
from spack.platforms.linux import Linux
|
||||||
from spack.platforms.bgq import Bgq
|
from spack.platforms.bgq import Bgq
|
||||||
@ -13,12 +14,50 @@
|
|||||||
|
|
||||||
class ArchitectureTest(unittest.TestCase):
|
class ArchitectureTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
zlib = spack.spec.Spec("zlib")
|
||||||
|
zlib.concretize()
|
||||||
|
self.architecture = zlib.architecture
|
||||||
|
self.platform = sys_type()
|
||||||
|
self.platform_os = self.platform.operating_system('default_os')
|
||||||
|
self.target = self.platform.target('default')
|
||||||
|
|
||||||
|
#def test_to_dict_function_with_target(self):
|
||||||
|
# d = spack.architecture.to_dict(self.architecture)
|
||||||
|
# print d['target']
|
||||||
|
# self.assertEquals(d['target'], {'name': self.target.name,
|
||||||
|
# 'module_name' : self.target.module_name,
|
||||||
|
# 'platform_name' : self.target.platform_name,
|
||||||
|
# 'compiler_strategy': 'MODULES'
|
||||||
|
# })
|
||||||
|
|
||||||
|
def test_to_dict_function_with_architecture(self):
|
||||||
|
d = spack.architecture.to_dict(self.architecture)
|
||||||
|
self.assertEquals(d, {'architecture':
|
||||||
|
{'platform' : {'name': 'crayxc'},
|
||||||
|
'platform_os': {
|
||||||
|
'compiler_strategy': 'MODULES',
|
||||||
|
'name':'CNL',
|
||||||
|
'version':'10'},
|
||||||
|
'target' : {'platform_name' :'crayxc',
|
||||||
|
'module_name': 'craype-haswell',
|
||||||
|
'name':'haswell'}}})
|
||||||
|
|
||||||
|
#def test_to_dict_function_with_operating_system(self):
|
||||||
|
# d = spack.architecture.to_dict(self.architecture)
|
||||||
|
# self.assertEquals(d['platform_os'], {'name': self.platform_os.name,
|
||||||
|
# 'version': self.platform_os.version,
|
||||||
|
# 'compiler_strategy': self.platform_os.compiler_strategy})
|
||||||
|
|
||||||
|
def test_architecture_from_dict(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def test_platform_class_and_compiler_strategies(self):
|
def test_platform_class_and_compiler_strategies(self):
|
||||||
a = CrayXc()
|
a = CrayXc()
|
||||||
t = a.target('default')
|
t = a.operating_system('default_os')
|
||||||
self.assertEquals(t.compiler_strategy, 'MODULES')
|
self.assertEquals(t.compiler_strategy, 'MODULES')
|
||||||
b = Linux()
|
b = Linux()
|
||||||
s = b.target('default')
|
s = b.operating_system('default_os')
|
||||||
self.assertEquals(s.compiler_strategy, 'PATH')
|
self.assertEquals(s.compiler_strategy, 'PATH')
|
||||||
|
|
||||||
def test_sys_type(self):
|
def test_sys_type(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user