gen_travis.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/usr/bin/env python
  2. from itertools import combinations
  3. travis_template = """\
  4. language: generic
  5. matrix:
  6. include:
  7. %s
  8. before_script:
  9. - autoconf
  10. - ./configure ${COMPILER_FLAGS:+ \
  11. CC="$CC $COMPILER_FLAGS" \
  12. CXX="$CXX $COMPILER_FLAGS" } \
  13. $CONFIGURE_FLAGS
  14. - make -j3
  15. - make -j3 tests
  16. script:
  17. - make check
  18. """
  19. # The 'default' configuration is gcc, on linux, with no compiler or configure
  20. # flags. We also test with clang, -m32, --enable-debug, --enable-prof,
  21. # --disable-stats, and --with-malloc-conf=tcache:false. To avoid abusing
  22. # travis though, we don't test all 2**7 = 128 possible combinations of these;
  23. # instead, we only test combinations of up to 2 'unusual' settings, under the
  24. # hope that bugs involving interactions of such settings are rare.
  25. # Things at once, for C(7, 0) + C(7, 1) + C(7, 2) = 29
  26. MAX_UNUSUAL_OPTIONS = 2
  27. os_default = 'linux'
  28. os_unusual = 'osx'
  29. compilers_default = 'CC=gcc CXX=g++'
  30. compilers_unusual = 'CC=clang CXX=clang++'
  31. compiler_flag_unusuals = ['-m32']
  32. configure_flag_unusuals = [
  33. '--enable-debug',
  34. '--enable-prof',
  35. '--disable-stats',
  36. ]
  37. malloc_conf_unusuals = [
  38. 'tcache:false',
  39. 'dss:primary',
  40. 'percpu_arena:percpu',
  41. 'background_thread:true',
  42. ]
  43. all_unusuals = (
  44. [os_unusual] + [compilers_unusual] + compiler_flag_unusuals
  45. + configure_flag_unusuals + malloc_conf_unusuals
  46. )
  47. unusual_combinations_to_test = []
  48. for i in xrange(MAX_UNUSUAL_OPTIONS + 1):
  49. unusual_combinations_to_test += combinations(all_unusuals, i)
  50. include_rows = ""
  51. for unusual_combination in unusual_combinations_to_test:
  52. os = os_default
  53. if os_unusual in unusual_combination:
  54. os = os_unusual
  55. compilers = compilers_default
  56. if compilers_unusual in unusual_combination:
  57. compilers = compilers_unusual
  58. compiler_flags = [
  59. x for x in unusual_combination if x in compiler_flag_unusuals]
  60. configure_flags = [
  61. x for x in unusual_combination if x in configure_flag_unusuals]
  62. malloc_conf = [
  63. x for x in unusual_combination if x in malloc_conf_unusuals]
  64. # Filter out unsupported configurations on OS X.
  65. if os == 'osx' and ('dss:primary' in malloc_conf or \
  66. 'percpu_arena:percpu' in malloc_conf or 'background_thread:true' \
  67. in malloc_conf):
  68. continue
  69. if len(malloc_conf) > 0:
  70. configure_flags.append('--with-malloc-conf=' + ",".join(malloc_conf))
  71. # Filter out an unsupported configuration - heap profiling on OS X.
  72. if os == 'osx' and '--enable-prof' in configure_flags:
  73. continue
  74. # We get some spurious errors when -Warray-bounds is enabled.
  75. env_string = ('{} COMPILER_FLAGS="{}" CONFIGURE_FLAGS="{}" '
  76. 'EXTRA_CFLAGS="-Werror -Wno-array-bounds"').format(
  77. compilers, " ".join(compiler_flags), " ".join(configure_flags))
  78. include_rows += ' - os: %s\n' % os
  79. include_rows += ' env: %s\n' % env_string
  80. if '-m32' in unusual_combination and os == 'linux':
  81. include_rows += ' addons:\n'
  82. include_rows += ' apt:\n'
  83. include_rows += ' packages:\n'
  84. include_rows += ' - gcc-multilib\n'
  85. print travis_template % include_rows