~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/test/lit.cfg

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Python -*-
 
2
 
 
3
# Configuration file for the 'lit' test runner.
 
4
 
 
5
import os
 
6
 
 
7
# name: The name of this test suite.
 
8
config.name = 'LLVM'
 
9
 
 
10
# testFormat: The test format to use to interpret tests.
 
11
config.test_format = lit.formats.TclTest()
 
12
 
 
13
# suffixes: A list of file extensions to treat as test files, this is actually
 
14
# set by on_clone().
 
15
config.suffixes = []
 
16
 
 
17
# test_source_root: The root path where tests are located.
 
18
config.test_source_root = os.path.dirname(__file__)
 
19
 
 
20
# test_exec_root: The root path where tests should be run.
 
21
llvm_obj_root = getattr(config, 'llvm_obj_root', None)
 
22
if llvm_obj_root is not None:
 
23
    config.test_exec_root = os.path.join(llvm_obj_root, 'test')
 
24
 
 
25
# Tweak the PATH to include the scripts dir, the tools dir, and the llvm-gcc bin
 
26
# dir (if available).
 
27
if llvm_obj_root is not None:
 
28
    llvm_src_root = getattr(config, 'llvm_src_root', None)
 
29
    if not llvm_src_root:
 
30
        lit.fatal('No LLVM source root set!')
 
31
    path = os.path.pathsep.join((os.path.join(llvm_src_root, 'test',
 
32
                                              'Scripts'),
 
33
                                 config.environment['PATH']))
 
34
    config.environment['PATH'] = path
 
35
 
 
36
    llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
 
37
    if not llvm_tools_dir:
 
38
        lit.fatal('No LLVM tools dir set!')
 
39
    path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
 
40
    config.environment['PATH'] = path
 
41
 
 
42
    llvmgcc_dir = getattr(config, 'llvmgcc_dir', None)
 
43
    if llvmgcc_dir:
 
44
        path = os.path.pathsep.join((os.path.join(llvmgcc_dir, 'bin'),
 
45
                                     config.environment['PATH']))
 
46
        config.environment['PATH'] = path
 
47
 
 
48
# Propogate 'HOME' through the environment.
 
49
config.environment['HOME'] = os.environ['HOME']
 
50
 
 
51
###
 
52
 
 
53
import os
 
54
 
 
55
# Check that the object root is known.
 
56
if config.test_exec_root is None:
 
57
    # Otherwise, we haven't loaded the site specific configuration (the user is
 
58
    # probably trying to run on a test file directly, and either the site
 
59
    # configuration hasn't been created by the build system, or we are in an
 
60
    # out-of-tree build situation).
 
61
 
 
62
    # Check for 'llvm_site_config' user parameter, and use that if available.
 
63
    site_cfg = lit.params.get('llvm_site_config', None)
 
64
    if site_cfg and os.path.exists(site_cfg):
 
65
        lit.load_config(config, site_cfg)
 
66
        raise SystemExit
 
67
 
 
68
    # Try to detect the situation where we are using an out-of-tree build by
 
69
    # looking for 'llvm-config'.
 
70
    #
 
71
    # FIXME: I debated (i.e., wrote and threw away) adding logic to
 
72
    # automagically generate the lit.site.cfg if we are in some kind of fresh
 
73
    # build situation. This means knowing how to invoke the build system
 
74
    # though, and I decided it was too much magic.
 
75
 
 
76
    llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
 
77
    if not llvm_config:
 
78
        lit.fatal('No site specific configuration available!')
 
79
 
 
80
    # Get the source and object roots.
 
81
    llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
 
82
    llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
 
83
 
 
84
    # Validate that we got a tree which points to here.
 
85
    this_src_root = os.path.dirname(config.test_source_root)
 
86
    if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root):
 
87
        lit.fatal('No site specific configuration available!')
 
88
 
 
89
    # Check that the site specific configuration exists.
 
90
    site_cfg = os.path.join(llvm_obj_root, 'test', 'lit.site.cfg')
 
91
    if not os.path.exists(site_cfg):
 
92
        lit.fatal('No site specific configuration available!')
 
93
 
 
94
    # Okay, that worked. Notify the user of the automagic, and reconfigure.
 
95
    lit.note('using out-of-tree build at %r' % llvm_obj_root)
 
96
    lit.load_config(config, site_cfg)
 
97
    raise SystemExit
 
98
 
 
99
###
 
100
 
 
101
# Load site data from DejaGNU's site.exp.
 
102
import re
 
103
site_exp = {}
 
104
# FIXME: Implement lit.site.cfg.
 
105
for line in open(os.path.join(config.llvm_obj_root, 'test', 'site.exp')):
 
106
    m = re.match('set ([^ ]+) "([^"]*)"', line)
 
107
    if m:
 
108
        site_exp[m.group(1)] = m.group(2)
 
109
 
 
110
# Add substitutions.
 
111
config.substitutions.append(('%llvmgcc_only', site_exp['llvmgcc']))
 
112
for sub in ['llvmgcc', 'llvmgxx', 'compile_cxx', 'compile_c',
 
113
            'link', 'shlibext', 'ocamlopt', 'llvmdsymutil', 'llvmlibsdir',
 
114
            'bugpoint_topts']:
 
115
    if sub in ('llvmgcc', 'llvmgxx'):
 
116
        config.substitutions.append(('%' + sub,
 
117
                                     site_exp[sub] + ' -emit-llvm -w'))
 
118
    # FIXME: This is a hack to avoid LLVMC tests failing due to a clang driver
 
119
    #        warning when passing in "-fexceptions -fno-exceptions".
 
120
    elif sub == 'compile_cxx':
 
121
        config.substitutions.append(('%' + sub,
 
122
                                  site_exp[sub].replace('-fno-exceptions', '')))
 
123
    else:
 
124
        config.substitutions.append(('%' + sub, site_exp[sub]))
 
125
 
 
126
excludes = []
 
127
 
 
128
# Provide target_triple for use in XFAIL and XTARGET.
 
129
config.target_triple = site_exp['target_triplet']
 
130
 
 
131
# Provide llvm_supports_target for use in local configs.
 
132
targets = set(site_exp["TARGETS_TO_BUILD"].split())
 
133
def llvm_supports_target(name):
 
134
    return name in targets
 
135
 
 
136
def llvm_supports_darwin_and_target(name):
 
137
    return 'darwin' in config.target_triple and llvm_supports_target(name)
 
138
 
 
139
langs = set(site_exp['llvmgcc_langs'].split(','))
 
140
def llvm_gcc_supports(name):
 
141
    return name in langs
 
142
 
 
143
bindings = set(site_exp['llvm_bindings'].split(','))
 
144
def llvm_supports_binding(name):
 
145
    return name in bindings
 
146
 
 
147
config.conditions["TARGET"] = llvm_supports_target
 
148
config.conditions["BINDING"] = llvm_supports_binding
 
149
 
 
150
# Provide on_clone hook for reading 'dg.exp'.
 
151
import os
 
152
simpleLibData = re.compile(r"""load_lib llvm.exp
 
153
 
 
154
RunLLVMTests \[lsort \[glob -nocomplain \$srcdir/\$subdir/\*\.(.*)\]\]""",
 
155
                           re.MULTILINE)
 
156
conditionalLibData = re.compile(r"""load_lib llvm.exp
 
157
 
 
158
if.*\[ ?(llvm[^ ]*) ([^ ]*) ?\].*{
 
159
 *RunLLVMTests \[lsort \[glob -nocomplain \$srcdir/\$subdir/\*\.(.*)\]\]
 
160
\}""", re.MULTILINE)
 
161
def on_clone(parent, cfg, for_path):
 
162
    def addSuffixes(match):
 
163
        if match[0] == '{' and match[-1] == '}':
 
164
            cfg.suffixes = ['.' + s for s in match[1:-1].split(',')]
 
165
        else:
 
166
            cfg.suffixes = ['.' + match]
 
167
 
 
168
    libPath = os.path.join(os.path.dirname(for_path),
 
169
                           'dg.exp')
 
170
    if not os.path.exists(libPath):
 
171
        cfg.unsupported = True
 
172
        return
 
173
 
 
174
    # Reset unsupported, in case we inherited it.
 
175
    cfg.unsupported = False
 
176
    lib = open(libPath).read().strip()
 
177
 
 
178
    # Check for a simple library.
 
179
    m = simpleLibData.match(lib)
 
180
    if m:
 
181
        addSuffixes(m.group(1))
 
182
        return
 
183
 
 
184
    # Check for a conditional test set.
 
185
    m = conditionalLibData.match(lib)
 
186
    if m:
 
187
        funcname,arg,match = m.groups()
 
188
        addSuffixes(match)
 
189
 
 
190
        func = globals().get(funcname)
 
191
        if not func:
 
192
            lit.error('unsupported predicate %r' % funcname)
 
193
        elif not func(arg):
 
194
            cfg.unsupported = True
 
195
        return
 
196
    # Otherwise, give up.
 
197
    lit.error('unable to understand %r:\n%s' % (libPath, lib))
 
198
 
 
199
config.on_clone = on_clone