~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/utils/lit/lit/TestingConfig.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
import os
 
2
 
 
3
class TestingConfig:
 
4
    """"
 
5
    TestingConfig - Information on the tests inside a suite.
 
6
    """
 
7
 
 
8
    @staticmethod
 
9
    def frompath(path, parent, litConfig, mustExist, config = None):
 
10
        if config is None:
 
11
            # Set the environment based on the command line arguments.
 
12
            environment = {
 
13
                'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH',''),
 
14
                'PATH' : os.pathsep.join(litConfig.path +
 
15
                                         [os.environ.get('PATH','')]),
 
16
                'PATHEXT' : os.environ.get('PATHEXT',''),
 
17
                'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
 
18
                'LLVM_DISABLE_CRT_DEBUG' : '1',
 
19
                }
 
20
 
 
21
            config = TestingConfig(parent,
 
22
                                   name = '<unnamed>',
 
23
                                   suffixes = set(),
 
24
                                   test_format = None,
 
25
                                   environment = environment,
 
26
                                   substitutions = [],
 
27
                                   unsupported = False,
 
28
                                   on_clone = None,
 
29
                                   test_exec_root = None,
 
30
                                   test_source_root = None,
 
31
                                   excludes = [],
 
32
                                   conditions = {})
 
33
 
 
34
        if os.path.exists(path):
 
35
            # FIXME: Improve detection and error reporting of errors in the
 
36
            # config file.
 
37
            f = open(path)
 
38
            cfg_globals = dict(globals())
 
39
            cfg_globals['config'] = config
 
40
            cfg_globals['lit'] = litConfig
 
41
            cfg_globals['__file__'] = path
 
42
            try:
 
43
                exec f in cfg_globals
 
44
            except SystemExit,status:
 
45
                # We allow normal system exit inside a config file to just
 
46
                # return control without error.
 
47
                if status.args:
 
48
                    raise
 
49
            f.close()
 
50
        elif mustExist:
 
51
            litConfig.fatal('unable to load config from %r ' % path)
 
52
 
 
53
        config.finish(litConfig)
 
54
        return config
 
55
 
 
56
    def __init__(self, parent, name, suffixes, test_format,
 
57
                 environment, substitutions, unsupported, on_clone,
 
58
                 test_exec_root, test_source_root, excludes, conditions):
 
59
        self.parent = parent
 
60
        self.name = str(name)
 
61
        self.suffixes = set(suffixes)
 
62
        self.test_format = test_format
 
63
        self.environment = dict(environment)
 
64
        self.substitutions = list(substitutions)
 
65
        self.unsupported = unsupported
 
66
        self.on_clone = on_clone
 
67
        self.test_exec_root = test_exec_root
 
68
        self.test_source_root = test_source_root
 
69
        self.excludes = set(excludes)
 
70
        self.conditions = dict(conditions)
 
71
 
 
72
    def clone(self, path):
 
73
        # FIXME: Chain implementations?
 
74
        #
 
75
        # FIXME: Allow extra parameters?
 
76
        cfg = TestingConfig(self, self.name, self.suffixes, self.test_format,
 
77
                            self.environment, self.substitutions,
 
78
                            self.unsupported, self.on_clone,
 
79
                            self.test_exec_root, self.test_source_root,
 
80
                            self.excludes, self.conditions)
 
81
        if cfg.on_clone:
 
82
            cfg.on_clone(self, cfg, path)
 
83
        return cfg
 
84
 
 
85
    def finish(self, litConfig):
 
86
        """finish() - Finish this config object, after loading is complete."""
 
87
 
 
88
        self.name = str(self.name)
 
89
        self.suffixes = set(self.suffixes)
 
90
        self.environment = dict(self.environment)
 
91
        self.substitutions = list(self.substitutions)
 
92
        if self.test_exec_root is not None:
 
93
            # FIXME: This should really only be suite in test suite config
 
94
            # files. Should we distinguish them?
 
95
            self.test_exec_root = str(self.test_exec_root)
 
96
        if self.test_source_root is not None:
 
97
            # FIXME: This should really only be suite in test suite config
 
98
            # files. Should we distinguish them?
 
99
            self.test_source_root = str(self.test_source_root)
 
100
        self.excludes = set(self.excludes)