|
43 | 43 | import easybuild.tools.toolchain as toolchain |
44 | 44 | import easybuild.tools.toolchain.compiler |
45 | 45 | from easybuild.framework.easyconfig.easyconfig import EasyConfig, ActiveMNS |
| 46 | +from easybuild.toolchains.compiler.gcc import Gcc |
46 | 47 | from easybuild.toolchains.system import SystemToolchain |
47 | 48 | from easybuild.tools import systemtools as st |
48 | 49 | from easybuild.tools.build_log import EasyBuildError |
@@ -407,8 +408,10 @@ def test_toolchain_compiler_env_vars(self): |
407 | 408 | self.assertEqual(os.getenv('OMPI_F77'), 'gfortran') |
408 | 409 | self.assertEqual(os.getenv('OMPI_FC'), 'gfortran') |
409 | 410 |
|
| 411 | + flags_regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno") |
410 | 412 | for key in ['CFLAGS', 'CXXFLAGS', 'F90FLAGS', 'FCFLAGS', 'FFLAGS']: |
411 | | - self.assertEqual(os.getenv(key), "-O2 -ftree-vectorize -march=native -fno-math-errno") |
| 413 | + val = os.getenv(key) |
| 414 | + self.assertTrue(flags_regex.match(val), "'%s' should match pattern '%s'" % (val, flags_regex.pattern)) |
412 | 415 |
|
413 | 416 | def test_get_variable_compilers(self): |
414 | 417 | """Test get_variable function to obtain compiler variables.""" |
@@ -886,27 +889,30 @@ def test_precision_flags(self): |
886 | 889 | tc = self.get_toolchain('foss', version='2018a') |
887 | 890 | tc.set_options({}) |
888 | 891 | tc.prepare() |
| 892 | + flags_regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno") |
889 | 893 | for var in flag_vars: |
890 | | - self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native -fno-math-errno") |
| 894 | + val = os.getenv(var) |
| 895 | + self.assertTrue(flags_regex.match(val), "'%s' should match pattern '%s'" % (val, flags_regex.pattern)) |
891 | 896 |
|
892 | 897 | # check other precision flags |
893 | | - prec_flags = { |
894 | | - 'ieee': "-fno-math-errno -mieee-fp -fno-trapping-math", |
895 | | - 'strict': "-mieee-fp -mno-recip", |
896 | | - 'precise': "-mno-recip", |
897 | | - 'loose': "-fno-math-errno -mrecip -mno-ieee-fp", |
898 | | - 'veryloose': "-fno-math-errno -mrecip=all -mno-ieee-fp", |
899 | | - } |
| 898 | + precs = ['strict', 'precise', 'loose', 'veryloose'] |
| 899 | + prec_flags = {} |
| 900 | + for prec in precs: |
| 901 | + prec_flags[prec] = ' '.join('-%s' % x for x in Gcc.COMPILER_UNIQUE_OPTION_MAP[prec]) |
| 902 | + |
900 | 903 | for prec in prec_flags: |
901 | 904 | for enable in [True, False]: |
902 | 905 | tc = self.get_toolchain('foss', version='2018a') |
903 | 906 | tc.set_options({prec: enable}) |
904 | 907 | tc.prepare() |
905 | 908 | for var in flag_vars: |
906 | 909 | if enable: |
907 | | - self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native %s" % prec_flags[prec]) |
| 910 | + regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native %s" % prec_flags[prec]) |
908 | 911 | else: |
909 | | - self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native -fno-math-errno") |
| 912 | + regex = flags_regex |
| 913 | + val = os.getenv(var) |
| 914 | + self.assertTrue(regex.match(val), "%s: '%s' should match pattern '%s'" % (prec, val, regex.pattern)) |
| 915 | + |
910 | 916 | self.modtool.purge() |
911 | 917 |
|
912 | 918 | def test_cgoolf_toolchain(self): |
|
0 commit comments