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