~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

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

  • 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
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, 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.valgrindArgs = list(valgrindArgs)
 
29
        self.useTclAsSh = bool(useTclAsSh)
 
30
        self.noExecute = noExecute
 
31
        self.debug = debug
 
32
        self.isWindows = bool(isWindows)
 
33
        self.params = dict(params)
 
34
        self.bashPath = None
 
35
 
 
36
        self.numErrors = 0
 
37
        self.numWarnings = 0
 
38
 
 
39
    def load_config(self, config, path):
 
40
        """load_config(config, path) - Load a config object from an alternate
 
41
        path."""
 
42
        from TestingConfig import TestingConfig
 
43
        return TestingConfig.frompath(path, config.parent, self,
 
44
                                      mustExist = True,
 
45
                                      config = config)
 
46
 
 
47
    def getBashPath(self):
 
48
        """getBashPath - Get the path to 'bash'"""
 
49
        import os, Util
 
50
 
 
51
        if self.bashPath is not None:
 
52
            return self.bashPath
 
53
 
 
54
        self.bashPath = Util.which('bash', os.pathsep.join(self.path))
 
55
        if self.bashPath is None:
 
56
            # Check some known paths.
 
57
            for path in ('/bin/bash', '/usr/bin/bash'):
 
58
                if os.path.exists(path):
 
59
                    self.bashPath = path
 
60
                    break
 
61
 
 
62
        if self.bashPath is None:
 
63
            self.warning("Unable to find 'bash', running Tcl tests internally.")
 
64
            self.bashPath = ''
 
65
 
 
66
        return self.bashPath
 
67
 
 
68
    def _write_message(self, kind, message):
 
69
        import inspect, os, sys
 
70
 
 
71
        # Get the file/line where this message was generated.
 
72
        f = inspect.currentframe()
 
73
        # Step out of _write_message, and then out of wrapper.
 
74
        f = f.f_back.f_back
 
75
        file,line,_,_,_ = inspect.getframeinfo(f)
 
76
        location = '%s:%d' % (os.path.basename(file), line)
 
77
 
 
78
        print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
 
79
                                                kind, message)
 
80
 
 
81
    def note(self, message):
 
82
        self._write_message('note', message)
 
83
 
 
84
    def warning(self, message):
 
85
        self._write_message('warning', message)
 
86
        self.numWarnings += 1
 
87
 
 
88
    def error(self, message):
 
89
        self._write_message('error', message)
 
90
        self.numErrors += 1
 
91
 
 
92
    def fatal(self, message):
 
93
        import sys
 
94
        self._write_message('fatal', message)
 
95
        sys.exit(2)