~ubuntu-branches/debian/sid/clamav/sid

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/lit/lit/LitConfig.py

  • Committer: Package Import Robot
  • Author(s): Andreas Cadhalpun, Andreas Cadhalpun, Sebastian Andrzej Siewior, Frans Spiesschaert
  • Date: 2014-10-15 06:50:20 UTC
  • mfrom: (1.3.13) (42.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20141015065020-0cpy1hdueggaw35s
Tags: 0.98.5~rc1+dfsg-1
[ Andreas Cadhalpun ]
* Import new upstream release candidate.
* Drop patches included upstream and update the others.
* Add 4 new symbols to libclamav6.symbols.
* Fix debian/copyright.
* Update lintian overrides.
* Update Standards-Version to 3.9.6 (no changes needed).
* Add Breaks and Replaces for old clamd package to clamdscan.
* Remove unnecessary shlibs:Depends from clamav-dbg.
* Add patches to support LLVM 3.5.

[ Sebastian Andrzej Siewior ]
* Add embedded copy of libmspack to be used as fallback, when libmspack-dev
  is not available.

[ Frans Spiesschaert ]
* Updated Dutch Debconf template translation (Closes: #763634)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
class LitConfig:
2
 
    """LitConfig - Configuration data for a 'lit' test runner instance, shared
3
 
    across all tests.
4
 
 
5
 
    The LitConfig object is also used to communicate with client configuration
6
 
    files, it is always passed in as the global variable 'lit' so that
7
 
    configuration files can access common functionality and internal components
8
 
    easily.
9
 
    """
10
 
 
11
 
    # Provide access to built-in formats.
12
 
    import LitFormats as formats
13
 
 
14
 
    # Provide access to built-in utility functions.
15
 
    import Util as util
16
 
 
17
 
    def __init__(self, progname, path, quiet,
18
 
                 useValgrind, valgrindLeakCheck, valgrindArgs,
19
 
                 useTclAsSh,
20
 
                 noExecute, debug, isWindows,
21
 
                 params):
22
 
        # The name of the test runner.
23
 
        self.progname = progname
24
 
        # The items to add to the PATH environment variable.
25
 
        self.path = list(map(str, path))
26
 
        self.quiet = bool(quiet)
27
 
        self.useValgrind = bool(useValgrind)
28
 
        self.valgrindLeakCheck = bool(valgrindLeakCheck)
29
 
        self.valgrindUserArgs = list(valgrindArgs)
30
 
        self.useTclAsSh = bool(useTclAsSh)
31
 
        self.noExecute = noExecute
32
 
        self.debug = debug
33
 
        self.isWindows = bool(isWindows)
34
 
        self.params = dict(params)
35
 
        self.bashPath = None
36
 
 
37
 
        self.numErrors = 0
38
 
        self.numWarnings = 0
39
 
 
40
 
        self.valgrindArgs = []
41
 
        self.valgrindTriple = ""
42
 
        if self.useValgrind:
43
 
            self.valgrindTriple = "-vg"
44
 
            self.valgrindArgs = ['valgrind', '-q', '--run-libc-freeres=no',
45
 
                                 '--tool=memcheck', '--trace-children=yes',
46
 
                                 '--error-exitcode=123']
47
 
            if self.valgrindLeakCheck:
48
 
                self.valgrindTriple += "_leak"
49
 
                self.valgrindArgs.append('--leak-check=full')
50
 
            else:
51
 
                # The default is 'summary'.
52
 
                self.valgrindArgs.append('--leak-check=no')
53
 
            self.valgrindArgs.extend(self.valgrindUserArgs)
54
 
 
55
 
 
56
 
    def load_config(self, config, path):
57
 
        """load_config(config, path) - Load a config object from an alternate
58
 
        path."""
59
 
        from TestingConfig import TestingConfig
60
 
        return TestingConfig.frompath(path, config.parent, self,
61
 
                                      mustExist = True,
62
 
                                      config = config)
63
 
 
64
 
    def getBashPath(self):
65
 
        """getBashPath - Get the path to 'bash'"""
66
 
        import os, Util
67
 
 
68
 
        if self.bashPath is not None:
69
 
            return self.bashPath
70
 
 
71
 
        self.bashPath = Util.which('bash', os.pathsep.join(self.path))
72
 
        if self.bashPath is None:
73
 
            # Check some known paths.
74
 
            for path in ('/bin/bash', '/usr/bin/bash', '/usr/local/bin/bash'):
75
 
                if os.path.exists(path):
76
 
                    self.bashPath = path
77
 
                    break
78
 
 
79
 
        if self.bashPath is None:
80
 
            self.warning("Unable to find 'bash', running Tcl tests internally.")
81
 
            self.bashPath = ''
82
 
 
83
 
        return self.bashPath
84
 
 
85
 
    def _write_message(self, kind, message):
86
 
        import inspect, os, sys
87
 
 
88
 
        # Get the file/line where this message was generated.
89
 
        f = inspect.currentframe()
90
 
        # Step out of _write_message, and then out of wrapper.
91
 
        f = f.f_back.f_back
92
 
        file,line,_,_,_ = inspect.getframeinfo(f)
93
 
        location = '%s:%d' % (os.path.basename(file), line)
94
 
 
95
 
        print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
96
 
                                                kind, message)
97
 
 
98
 
    def note(self, message):
99
 
        self._write_message('note', message)
100
 
 
101
 
    def warning(self, message):
102
 
        self._write_message('warning', message)
103
 
        self.numWarnings += 1
104
 
 
105
 
    def error(self, message):
106
 
        self._write_message('error', message)
107
 
        self.numErrors += 1
108
 
 
109
 
    def fatal(self, message):
110
 
        import sys
111
 
        self._write_message('fatal', message)
112
 
        sys.exit(2)