Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d16ae51df8757f2cd5c1bf76f88ecbc91860306d (plain) (blame)
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# *******************************************************************************
# * Copyright (c) 2011 Wind River Systems, Inc. and others.
# * All rights reserved. This program and the accompanying materials
# * are made available under the terms of the Eclipse Public License v1.0
# * which accompanies this distribution, and is available at
# * http://www.eclipse.org/legal/epl-v10.html
# *
# * Contributors:
# *     Wind River Systems - initial API and implementation
# *******************************************************************************

"""
This is an optional service that can be implemented by a peer.
If implemented, the service can be used for testing of the peer and
communication channel functionality and reliability.
"""

from tcf import services

NAME = "Diagnostics"

class DiagnosticsService(services.Service):
    def getName(self):
        return NAME

    def echo(self, s, done):
        """
        'echo' command result returns same string that was given as command argument.
        The command is used to test communication channel ability to transmit arbitrary strings in
        both directions.
        @param s - any string.
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")

    def echoFP(self, n, done):
        """
        'echoFP' command result returns same floating point number that was given as command argument.
        The command is used to test communication channel ability to transmit arbitrary floating point numbers in
        both directions.
        @param n - any floating point number.
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")

    def echoERR(self, error, done):
        """
        'echoERR' command result returns same error report that was given as command argument.
        The command is used to test remote agent ability to receive and transmit TCF error reports.
        @param error - an error object.
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")

    def getTestList(self, done):
        """
        Get list of test names that are implemented by the service.
        Clients can request remote peer to run a test from the list.
        When started, a test performs a predefined set actions.
        Nature of test actions is uniquely identified by test name.
        Exact description of test actions is a contract between client and remote peer,
        and it is not part of Diagnostics service specifications.
        Clients should not attempt to run a test if they don't recognize the test name.
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")

    def runTest(self, name, done):
        """
        Run a test. When started, a test performs a predefined set actions.
        Nature of test actions is uniquely identified by test name.
        Running test usually has associated execution context ID.
        Depending on the test, the ID can be used with services RunControl and/or Processes services to control
        test execution, and to obtain test results.
        @param name - test name
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")

    def cancelTest(self, context_id, done):
        """
        Cancel execution of a test.
        @param context_id - text execution context ID.
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")

    def getSymbol(self, context_id, symbol_name, done):
        """
        Get information about a symbol in text execution context.
        @param context_id
        @param symbol_name
        @param done
        @return
        """
        return NotImplementedError("Abstract method")

    def createTestStreams(self, inp_buf_size, out_buf_size, done):
        """
        Create a pair of virtual streams, @see IStreams service.
        Remote ends of the streams are connected, so any data sent into 'inp' stream
        will become for available for reading from 'out' stream.
        The command is used for testing virtual streams.
        @param inp_buf_size - buffer size in bytes of the input stream.
        @param out_buf_size - buffer size in bytes of the output stream.
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")

    def disposeTestStream(self, id, done):
        """
        Dispose a virtual stream that was created by 'createTestStreams' command.
        @param id - the stream ID.
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")

    def not_implemented_command(self, done):
        """
        Send a command that is not implemented by peer.
        Used to test handling of 'N' messages by communication channel.
        @param done - command result call back object.
        @return - pending command handle.
        """
        return NotImplementedError("Abstract method")


class DoneEcho(object):
    """
    Call back interface for 'echo' command.
    """
    def doneEcho(self, token, error, s):
        """
        Called when 'echo' command is done.
        @param token - command handle.
        @param error - error object or None.
        @param s - same string as the command argument.
        """
        pass

class DoneEchoFP(object):
    """
    Call back interface for 'echoFP' command.
    """
    def doneEchoFP(self, token, error, n):
        """
        Called when 'echoFP' command is done.
        @param token - command handle.
        @param error - error object or None.
        @param n - same number as the command argument.
        """
        pass

class DoneEchoERR(object):
    """
    Call back interface for 'echoERR' command.
    """
    def doneEchoERR(self, token, error, error_obj, error_msg):
        """
        Called when 'echoERR' command is done.
        @param token - command handle.
        @param error - communication error report or None.
        @param error_obj - error object, should be equal to the command argument.
        @param error_msg - error object converted to a human readable string.
        """
        pass

class DoneGetTestList(object):
    """
    Call back interface for 'getTestList' command.
    """
    def doneGetTestList(self, token, error, list):
        """
        Called when 'getTestList' command is done.
        @param token - command handle.
        @param error - error object or None.
        @param list - names of tests that are supported by the peer.
        """
        pass

class DoneRunTest(object):
    """
    Call back interface for 'runTest' command.
    """
    def doneRunTest(self, token, error, context_id):
        """
        Called when 'runTest' command is done.
        @param token - command handle.
        @param error - error object or None.
        @param context_id - test execution contest ID.
        """
        pass

class DoneCancelTest(object):
    """
    Call back interface for 'cancelTest' command.
    """
    def doneCancelTest(self, token, error):
        """
        Called when 'cancelTest' command is done.
        @param token - command handle.
        @param error - error object or None.
        """
        pass

class DoneGetSymbol(object):
    """
    Call back interface for 'getSymbol' command.
    """
    def doneGetSymbol(self, token, error, symbol):
        """
        Called when 'getSymbol' command is done.
        @param token - command handle.
        @param error - error object or None.
        @param symbol
        """
        pass

class Symbol(object):
    """
    Represents result value of 'getSymbol' command.
    """
    def __init__(self, props):
        self._props = props or {}
    def getSectionName(self):
        return self._props.get("Section")
    def getValue(self):
        return self._props.get("Value")
    def isUndef(self):
        val = self._props.get("Storage")
        return val == "UNDEF"
    def isCommon(self):
        val = self._props.get("Storage")
        return val == "COMMON"
    def isGlobal(self):
        val = self._props.get("Storage")
        return val == "GLOBAL"
    def isLocal(self):
        val = self._props.get("Storage")
        return val == "LOCAL"
    def isAbs(self):
        return self._props.get("Abs", False)

class DoneCreateTestStreams(object):
    """
    Call back interface for 'createTestStreams' command.
    """
    def doneCreateTestStreams(self, token, error, inp_id, out_id):
        """
        Called when 'createTestStreams' command is done.
        @param token - command handle.
        @param error - error object or None.
        @param inp_id - the input stream ID.
        @param out_id - the output stream ID.
        """
        pass

class DoneDisposeTestStream(object):
    """
    Call back interface for 'disposeTestStream' command.
    """
    def doneDisposeTestStream(self, token, error):
        """
        Called when 'createTestStreams' command is done.
        @param token - command handle.
        @param error - error object or None.
        """
        pass

class DoneNotImplementedCommand(object):
    def doneNotImplementedCommand(self, token, error):
        """
        Called when 'not_implemented_command' command is done.
        @param token - command handle.
        @param error - error object.
        """
        pass

Back to the top