This file is indexed.

/usr/share/pyshared/qm/test/test.py is in qmtest 2.4.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
########################################################################
#
# File:   test.py
# Author: Mark Mitchell
# Date:   2001-10-10
#
# Contents:
#   QMTest Test class.
#
# Copyright (c) 2001, 2002, 2003 by CodeSourcery, LLC.  All rights reserved. 
#
# For license terms see the file COPYING.
#
########################################################################

########################################################################
# Imports
########################################################################

import qm
import qm.fields
import qm.test.database
import qm.test.result
import qm.test.runnable

########################################################################
# Variables
########################################################################

__the_targets = []
"""The global set of available targets."""


########################################################################
# Classes
########################################################################

class TargetGroupField(qm.fields.TextField):
    """A 'TargetGroupField' contains a target group pattern.

    A target group pattern is a regular expression.  A test will only be
    run on a particular target if the target's group is matched by the
    test's target group pattern."""

    def GetDescription(self):
        """Return a description of this field.

        This description is used when displaying detailed help
        information about the field."""

        # Get the basic description.
        desc = qm.fields.TextField.GetDescription(self)
        # Add a list of the available targets.
        desc = desc + "\n\n**Available Target Groups**\n\n"
        groups = [t.GetGroup() for t in get_targets()]
        for g in groups:
            desc = desc + "  * " + g + "\n"

        return desc



class Test(qm.test.runnable.Runnable):
    """A 'Test' is run to check for correct behavior.

    A 'Test' performs some check on the system being tested, and
    indicates whether the check was successful, or whether the
    check failed.

    Each test class (i.e., class derived from 'Test') describes a set
    of "arguments".  Each argument has a name and a type.  The values
    of these arguments determine the design-time parameters for the
    test.  For example, for a test class that executes program and
    checks their exit codes, the arguments might consist of the
    name of the program to execute, and the command-line arguments
    that should be given to that program.  QMTest uses the arguments
    to prompt the user when creating a new test.

    Each test class also defines a 'Run' method that indicates how
    to run tests in that class.  The 'Run' method is responsible for
    actually performing the test and for reporting the results.
    
    'Test' is an abstract class.

    You can extend QMTest by providing your own test class
    implementation.  If the test classes that come with QMTest cannot
    be used conveniently with your application domain, or if you would
    like to report more detailed information about passing and failing
    tests, you may wish to create a new test class.

    To create your own test class, you must create a Python class
    derived (directly or indirectly) from 'Test'.  The documentation
    for each method of 'Test' indicates whether you must override it
    in your test class implementation.  Some methods may be
    overridden, but do not need to be.  You might want to override
    such a method to provide a more efficient implementation, but
    QMTest will work fine if you just use the default version.

    If QMTest calls a method on a test and that method raises an
    exception that is not caught within the method itself, QMTest will
    catch the exception and continue processing."""

    class OutcomeField(qm.fields.EnumerationField):
        """An 'OutcomeField' contains an outcome."""

        def __init__(self, name, **properties):

            qm.fields.EnumerationField.__init__(
                self, name,
                qm.test.result.Result.PASS,
                [ qm.test.result.Result.PASS,
                  qm.test.result.Result.FAIL,
                  qm.test.result.Result.UNTESTED,
                  qm.test.result.Result.ERROR ],
                **properties)



    class TestField(qm.fields.ChoiceField):
        """A 'TestField' contains the name of a test.

        The exact format of the name depends on the test database in use."""

        def GetItems(self):

            database = qm.test.database.get_database()
            return database.GetTestIds()


    arguments = [
        TargetGroupField(
            name="target_group",
            title="Target Group Pattern",
            description="""The targets on which this test can run.

            A regular expression that indicates the targets on which
            this test can be run.  If the pattern matches a particular
            group name, the test can be run on targets in that
            group.""",
            default_value=".*"
            ),
        qm.fields.SetField(
            qm.fields.TupleField(
                "prerequisites",
                (TestField(
                    name = "test_id",
                    title = "Test",
                    description = """The name of the prerequisite test.""",
                    default_value = "",
                    ),
                 OutcomeField(
                    name = "outcome",
                    title = "Outcome",
                    description \
                    = """The required outcome for the prerequisite test.
                        
                          If the outcome is different from that given here,
                          the dependent test will not be run.""",
                    )),
                title="Prerequisite Tests",
                description="""The tests on which this test depends.
                
                Every test can depend on other tests.  Those tests will be
                run before this test.  If the prerequisite test does not
                have the outcome indicated, this test will not be run.""",
                ))
    ]

    kind = "test"

    PREREQUISITES_FIELD_ID = "prerequisites"
    """The name of the field that contains the prerequisites on which
    this test depends."""

    def Run(self, context, result):
        """Run the test.

        'context' -- A 'Context' giving run-time parameters to the
        test.

        'result' -- A 'Result' object.  The outcome will be
        'Result.PASS' when this method is called.  The 'result' may be
        modified by this method to indicate outcomes other than
        'Result.PASS' or to add annotations.

        This method should not return a value.

        Derived classes must override this method."""

        raise NotImplementedError


    def GetTargetGroup(self):
        """Returns the pattern for the targets that can run this test.

        returns -- A regular expression (represented as a string) that
        indicates the targets on which this test can be run.  If the
        pattern matches a particular group name, the test can be run
        on targets in that group."""

        return self.target_group


########################################################################
# Functions
########################################################################

def set_targets(targets):
    """Set the available target.

    'targets' -- A list of targets available for test execution."""

    global __the_targets

    __the_targets = targets


def get_targets():
    """Get the available target.

    returns -- A list of targets available for test execution."""

    return __the_targets


########################################################################
# Local Variables:
# mode: python
# indent-tabs-mode: nil
# fill-column: 72
# End: