2014-03-26 02:57:33 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# =============================================================================
|
2019-01-07 08:47:17 +00:00
|
|
|
# Copyright (c) 2011-2019 Bolero MURAKAMI
|
2014-03-26 02:57:33 +00:00
|
|
|
# https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
#
|
|
|
|
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
# =============================================================================
|
|
|
|
import sys
|
|
|
|
import optparse
|
|
|
|
import subprocess
|
|
|
|
import multiprocessing
|
|
|
|
|
|
|
|
def build(command):
|
|
|
|
sys.stdout.write(".")
|
|
|
|
sys.stdout.flush()
|
|
|
|
return subprocess.call(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = optparse.OptionParser(description='test.py')
|
|
|
|
parser.add_option('--stagedir', type='string', default='testspr')
|
|
|
|
parser.add_option('--gcc_version', type='string', default='.')
|
|
|
|
parser.add_option('--clang_version', type='string', default='.')
|
|
|
|
parser.add_option('--gcc_root', type='string', default='/usr/local')
|
|
|
|
parser.add_option('--clang_root', type='string', default='/usr/local')
|
|
|
|
parser.add_option('--all_options', type='string', default='')
|
|
|
|
parser.add_option('--test_cpp', type='string')
|
|
|
|
parser.add_option('--serialized_std_options', type='string', default='{}')
|
|
|
|
parser.add_option('--serialized_compiler_specific_options', type='string', default='{}')
|
|
|
|
parser.add_option('--serialized_version_specific_options', type='string', default='{}')
|
|
|
|
parser.add_option('--max_procs', type='int', default=0)
|
|
|
|
(opts, args) = parser.parse_args()
|
|
|
|
|
|
|
|
std_options = eval(opts.serialized_std_options)
|
|
|
|
version_specific_options = eval(opts.serialized_version_specific_options)
|
|
|
|
compiler_specific_options = eval(opts.serialized_compiler_specific_options)
|
|
|
|
|
|
|
|
def format_command(name, version, root):
|
|
|
|
base = "%s-%s" % (name, version) if version != "." else name
|
|
|
|
bin = "%s/test.%s.out" % (opts.stagedir, base.replace('.', ''))
|
|
|
|
compile_log = "%s/test.%s.compile.log" % (opts.stagedir, base.replace('.', ''))
|
|
|
|
execute_log = "%s/test.%s.execute.log" % (opts.stagedir, base.replace('.', ''))
|
2014-07-30 10:23:33 +00:00
|
|
|
fail_log = "%s/fail.log" % (opts.stagedir)
|
2014-03-26 02:57:33 +00:00
|
|
|
compiler = "%s/%s/bin/%s++" % (root, base, name.rstrip('c')) if version != "." else "%s++" % name.rstrip('c')
|
2014-07-30 10:23:33 +00:00
|
|
|
command = "%s -o %s" \
|
2014-03-26 02:57:33 +00:00
|
|
|
" %s %s" \
|
|
|
|
" %s %s" \
|
2014-07-30 10:23:33 +00:00
|
|
|
" %s" \
|
2014-03-26 02:57:33 +00:00
|
|
|
% (compiler, bin,
|
|
|
|
std_options.get(base, ''), opts.all_options,
|
|
|
|
compiler_specific_options.get(name, ''), version_specific_options.get(base, ''),
|
2014-07-30 10:23:33 +00:00
|
|
|
opts.test_cpp
|
|
|
|
)
|
|
|
|
fail_info = "%s : %s" % (base, command)
|
|
|
|
return "(" \
|
|
|
|
" %s > %s 2>&1" \
|
|
|
|
" && %s > %s 2>&1" \
|
|
|
|
" ) || !(echo %s >> %s)" \
|
|
|
|
% (command, compile_log,
|
|
|
|
bin, execute_log,
|
|
|
|
fail_info, fail_log
|
2014-03-26 02:57:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
pool = multiprocessing.Pool(opts.max_procs if opts.max_procs != 0 else None)
|
|
|
|
return sum(result != 0 for result in pool.map(
|
|
|
|
build,
|
|
|
|
([format_command('gcc', version, opts.gcc_root)
|
|
|
|
for version in opts.gcc_version.split(' ')
|
|
|
|
] if opts.gcc_version != ' '
|
|
|
|
else []
|
|
|
|
)
|
|
|
|
+
|
|
|
|
([format_command('clang', version, opts.clang_root)
|
|
|
|
for version in opts.clang_version.split(' ')
|
|
|
|
] if opts.clang_version != ' '
|
|
|
|
else []
|
|
|
|
)
|
|
|
|
))
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(main())
|