@@ -4483,6 +4483,56 @@ def test_easyconfig_import(self):
44834483 error_pattern = r"Failed to copy '.*' easyconfig parameter"
44844484 self .assertErrorRegex (EasyBuildError , error_pattern , EasyConfig , test_ec )
44854485
4486+ def test_get_cuda_cc_template_value (self ):
4487+ """
4488+ Test getting template value based on --cuda-compute-capabilities / cuda_compute_capabilities.
4489+ """
4490+ self .contents = '\n ' .join ([
4491+ 'easyblock = "ConfigureMake"' ,
4492+ 'name = "pi"' ,
4493+ 'version = "3.14"' ,
4494+ 'homepage = "http://example.com"' ,
4495+ 'description = "test easyconfig"' ,
4496+ 'toolchain = SYSTEM' ,
4497+ ])
4498+ self .prep ()
4499+ ec = EasyConfig (self .eb_file )
4500+
4501+ error_pattern = "foobar is not a template value based on --cuda-compute-capabilities/cuda_compute_capabilities"
4502+ self .assertErrorRegex (EasyBuildError , error_pattern , ec .get_cuda_cc_template_value , 'foobar' )
4503+
4504+ error_pattern = r"Template value '%s' is not defined!\n"
4505+ error_pattern += r"Make sure that either the --cuda-compute-capabilities EasyBuild configuration "
4506+ error_pattern += "option is set, or that the cuda_compute_capabilities easyconfig parameter is defined."
4507+ cuda_template_values = {
4508+ 'cuda_compute_capabilities' : '6.5,7.0' ,
4509+ 'cuda_cc_space_sep' : '6.5 7.0' ,
4510+ 'cuda_cc_semicolon_sep' : '6.5;7.0' ,
4511+ 'cuda_sm_comma_sep' : 'sm_65,sm_70' ,
4512+ 'cuda_sm_space_sep' : 'sm_65 sm_70' ,
4513+ }
4514+ for key in cuda_template_values :
4515+ self .assertErrorRegex (EasyBuildError , error_pattern % key , ec .get_cuda_cc_template_value , key )
4516+
4517+ update_build_option ('cuda_compute_capabilities' , ['6.5' , '7.0' ])
4518+ ec = EasyConfig (self .eb_file )
4519+
4520+ for key in cuda_template_values :
4521+ self .assertEqual (ec .get_cuda_cc_template_value (key ), cuda_template_values [key ])
4522+
4523+ update_build_option ('cuda_compute_capabilities' , None )
4524+ ec = EasyConfig (self .eb_file )
4525+
4526+ for key in cuda_template_values :
4527+ self .assertErrorRegex (EasyBuildError , error_pattern % key , ec .get_cuda_cc_template_value , key )
4528+
4529+ self .contents += "\n cuda_compute_capabilities = ['6.5', '7.0']"
4530+ self .prep ()
4531+ ec = EasyConfig (self .eb_file )
4532+
4533+ for key in cuda_template_values :
4534+ self .assertEqual (ec .get_cuda_cc_template_value (key ), cuda_template_values [key ])
4535+
44864536
44874537def suite ():
44884538 """ returns all the testcases in this module """
0 commit comments