From f08018ad244c1187670b581317518709dbf02159 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 26 Jan 2016 08:22:09 -0800 Subject: [PATCH] better architecture check on linux --- tools/run_tests/run_tests.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 7482824099e..a3908642375 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -545,6 +545,27 @@ def _windows_arch_option(arch): else: print 'Architecture %s not supported.' % arch sys.exit(1) + + +def _check_arch_option(arch): + """Checks that architecture option is valid.""" + if platform_string() == 'windows': + _windows_arch_option(arch) + elif platform_string() == 'linux': + # On linux, we need to be running under docker with the right architecture. + if arch == 'default': + return + elif runtime_arch == '64bit' and arch == 'x64': + return + elif runtime_arch == '32bit' and arch == 'x86': + return + else: + print 'Architecture %s does not match current runtime architecture.' % arch + sys.exit(1) + else: + if args.arch != 'default': + print 'Architecture %s not supported on current platform.' % args.arch + sys.exit(1) def _windows_build_bat(compiler): @@ -735,15 +756,6 @@ if any(language.make_options() for language in languages): else: language_make_options = next(iter(languages)).make_options() -if platform_string() != 'windows': - if args.arch != 'default' and platform_string() != 'linux': - # TODO: check if the current arch is correct - print 'Architecture %s not supported on current platform.' % args.arch - sys.exit(1) - if args.compiler != 'default': - print 'Compiler %s not supported on current platform.' % args.compiler - sys.exit(1) - if len(languages) != 1 or len(build_configs) != 1: print 'Multi-language and multi-config testing is not supported.' sys.exit(1) @@ -773,6 +785,12 @@ if args.use_docker: shell=True, env=env) sys.exit(0) + +if platform_string() != 'windows' and args.compiler != 'default': + print 'Compiler %s not supported on current platform.' % args.compiler + sys.exit(1) + +_check_arch_option(args.arch) def make_jobspec(cfg, targets, makefile='Makefile'): if platform_string() == 'windows':