2
0

gen_run_tests.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/usr/bin/env python
  2. import sys
  3. from itertools import combinations
  4. from os import uname
  5. from multiprocessing import cpu_count
  6. # Later, we want to test extended vaddr support. Apparently, the "real" way of
  7. # checking this is flaky on OS X.
  8. bits_64 = sys.maxsize > 2**32
  9. nparallel = cpu_count() * 2
  10. uname = uname()[0]
  11. def powerset(items):
  12. result = []
  13. for i in xrange(len(items) + 1):
  14. result += combinations(items, i)
  15. return result
  16. possible_compilers = [('gcc', 'g++'), ('clang', 'clang++')]
  17. possible_compiler_opts = [
  18. '-m32',
  19. ]
  20. possible_config_opts = [
  21. '--enable-debug',
  22. '--enable-prof',
  23. '--disable-stats',
  24. ]
  25. if bits_64:
  26. possible_config_opts.append('--with-lg-vaddr=56')
  27. possible_malloc_conf_opts = [
  28. 'tcache:false',
  29. 'dss:primary',
  30. 'percpu_arena:percpu',
  31. 'background_thread:true',
  32. ]
  33. print 'set -e'
  34. print 'if [ -f Makefile ] ; then make relclean ; fi'
  35. print 'autoconf'
  36. print 'rm -rf run_tests.out'
  37. print 'mkdir run_tests.out'
  38. print 'cd run_tests.out'
  39. ind = 0
  40. for cc, cxx in possible_compilers:
  41. for compiler_opts in powerset(possible_compiler_opts):
  42. for config_opts in powerset(possible_config_opts):
  43. for malloc_conf_opts in powerset(possible_malloc_conf_opts):
  44. if cc is 'clang' \
  45. and '-m32' in possible_compiler_opts \
  46. and '--enable-prof' in config_opts:
  47. continue
  48. config_line = (
  49. 'EXTRA_CFLAGS=-Werror EXTRA_CXXFLAGS=-Werror '
  50. + 'CC="{} {}" '.format(cc, " ".join(compiler_opts))
  51. + 'CXX="{} {}" '.format(cxx, " ".join(compiler_opts))
  52. + '../../configure '
  53. + " ".join(config_opts) + (' --with-malloc-conf=' +
  54. ",".join(malloc_conf_opts) if len(malloc_conf_opts) > 0
  55. else '')
  56. )
  57. # We don't want to test large vaddr spaces in 32-bit mode.
  58. if ('-m32' in compiler_opts and '--with-lg-vaddr=56' in
  59. config_opts):
  60. continue
  61. # Per CPU arenas are only supported on Linux.
  62. linux_supported = ('percpu_arena:percpu' in malloc_conf_opts \
  63. or 'background_thread:true' in malloc_conf_opts)
  64. # Heap profiling and dss are not supported on OS X.
  65. darwin_unsupported = ('--enable-prof' in config_opts or \
  66. 'dss:primary' in malloc_conf_opts)
  67. if (uname == 'Linux' and linux_supported) \
  68. or (not linux_supported and (uname != 'Darwin' or \
  69. not darwin_unsupported)):
  70. print """cat <<EOF > run_test_%(ind)d.sh
  71. #!/bin/sh
  72. set -e
  73. abort() {
  74. echo "==> Error" >> run_test.log
  75. echo "Error; see run_tests.out/run_test_%(ind)d.out/run_test.log"
  76. exit 255 # Special exit code tells xargs to terminate.
  77. }
  78. # Environment variables are not supported.
  79. run_cmd() {
  80. echo "==> \$@" >> run_test.log
  81. \$@ >> run_test.log 2>&1 || abort
  82. }
  83. echo "=> run_test_%(ind)d: %(config_line)s"
  84. mkdir run_test_%(ind)d.out
  85. cd run_test_%(ind)d.out
  86. echo "==> %(config_line)s" >> run_test.log
  87. %(config_line)s >> run_test.log 2>&1 || abort
  88. run_cmd make all tests
  89. run_cmd make check
  90. run_cmd make distclean
  91. EOF
  92. chmod 755 run_test_%(ind)d.sh""" % {'ind': ind, 'config_line': config_line}
  93. ind += 1
  94. 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}