Port gen_run_tests.py to python3

Insignificant changes to make the script runnable on python3.
This commit is contained in:
Alex Lapenkou 2021-08-12 19:21:56 -07:00 committed by Alexander Lapenkov
parent 5884a076fb
commit 9d02bdc883

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
from itertools import combinations
@ -21,7 +21,7 @@ else:
def powerset(items):
result = []
for i in xrange(len(items) + 1):
for i in range(len(items) + 1):
result += combinations(items, i)
return result
@ -53,19 +53,20 @@ possible_malloc_conf_opts = [
'background_thread:true',
]
print 'set -e'
print 'if [ -f Makefile ] ; then %(make_cmd)s relclean ; fi' % {'make_cmd': make_cmd}
print 'autoconf'
print 'rm -rf run_tests.out'
print 'mkdir run_tests.out'
print 'cd run_tests.out'
print('set -e')
print('if [ -f Makefile ] ; then %(make_cmd)s relclean ; fi' % {'make_cmd':
make_cmd})
print('autoconf')
print('rm -rf run_tests.out')
print('mkdir run_tests.out')
print('cd run_tests.out')
ind = 0
for cc, cxx in possible_compilers:
for compiler_opts in powerset(possible_compiler_opts):
for config_opts in powerset(possible_config_opts):
for malloc_conf_opts in powerset(possible_malloc_conf_opts):
if cc is 'clang' \
if cc == 'clang' \
and '-m32' in possible_compiler_opts \
and '--enable-prof' in config_opts:
continue
@ -80,9 +81,9 @@ for cc, cxx in possible_compilers:
)
# We don't want to test large vaddr spaces in 32-bit mode.
if ('-m32' in compiler_opts and '--with-lg-vaddr=56' in
config_opts):
continue
if ('-m32' in compiler_opts and '--with-lg-vaddr=56' in
config_opts):
continue
# Per CPU arenas are only supported on Linux.
linux_supported = ('percpu_arena:percpu' in malloc_conf_opts \
@ -93,7 +94,7 @@ for cc, cxx in possible_compilers:
if (uname == 'Linux' and linux_supported) \
or (not linux_supported and (uname != 'Darwin' or \
not darwin_unsupported)):
print """cat <<EOF > run_test_%(ind)d.sh
print("""cat <<EOF > run_test_%(ind)d.sh
#!/bin/sh
set -e
@ -121,7 +122,9 @@ run_cmd %(make_cmd)s all tests
run_cmd %(make_cmd)s check
run_cmd %(make_cmd)s distclean
EOF
chmod 755 run_test_%(ind)d.sh""" % {'ind': ind, 'config_line': config_line, 'make_cmd': make_cmd}
chmod 755 run_test_%(ind)d.sh""" % {'ind': ind, 'config_line': config_line,
'make_cmd': make_cmd})
ind += 1
print 'for i in `seq 0 %(last_ind)d` ; do echo run_test_${i}.sh ; done | xargs -P %(nparallel)d -n 1 sh' % {'last_ind': ind-1, 'nparallel': nparallel}
print('for i in `seq 0 %(last_ind)d` ; do echo run_test_${i}.sh ; done | xargs'
' -P %(nparallel)d -n 1 sh' % {'last_ind': ind-1, 'nparallel': nparallel})