Mbed Host Tests
echo.py
Go to the documentation of this file.
1
"""
2
mbed SDK
3
Copyright (c) 2011-2016 ARM Limited
4
5
Licensed under the Apache License, Version 2.0 (the "License");
6
you may not use this file except in compliance with the License.
7
You may obtain a copy of the License at
8
9
http://www.apache.org/licenses/LICENSE-2.0
10
11
Unless required by applicable law or agreed to in writing, software
12
distributed under the License is distributed on an "AS IS" BASIS,
13
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
See the License for the specific language governing permissions and
15
limitations under the License.
16
"""
17
18
19
import
uuid
20
from
mbed_host_tests
import
BaseHostTest
21
22
class
EchoTest
(BaseHostTest):
23
24
__result =
None
25
echo_count = 0
26
count = 0
27
uuid_sent = []
28
uuid_recv = []
29
30
def
__send_echo_uuid(self):
31
if
self.
echo_count
:
32
str_uuid = str(uuid.uuid4())
33
self.send_kv(
"echo"
, str_uuid)
34
self.
uuid_sent
.append(str_uuid)
35
self.
echo_count
-= 1
36
37
def
_callback_echo(self, key, value, timestamp):
38
self.
uuid_recv
.append(value)
39
self.
__send_echo_uuid
()
40
41
def
_callback_echo_count(self, key, value, timestamp):
42
# Handshake
43
self.
echo_count
= int(value)
44
self.send_kv(key, value)
45
# Send first echo to echo server on DUT
46
self.
__send_echo_uuid
()
47
48
def
setup
(self):
49
self.register_callback(
"echo"
, self.
_callback_echo
)
50
self.register_callback(
"echo_count"
, self.
_callback_echo_count
)
51
52
def
result
(self):
53
self.
__result
= self.
uuid_sent
== self.
uuid_recv
54
return
self.
__result
55
56
def
teardown
(self):
57
pass
mbed_host_tests.host_tests.echo.EchoTest.echo_count
int echo_count
Definition:
echo.py:25
mbed_host_tests.host_tests.echo.EchoTest.__result
__result
Definition:
echo.py:24
mbed_host_tests.host_tests.echo.EchoTest.setup
def setup(self)
Definition:
echo.py:48
mbed_host_tests.host_tests.echo.EchoTest._callback_echo_count
def _callback_echo_count(self, key, value, timestamp)
Definition:
echo.py:41
mbed_host_tests.host_tests.echo.EchoTest.teardown
def teardown(self)
Definition:
echo.py:56
mbed_host_tests.host_tests.echo.EchoTest._callback_echo
def _callback_echo(self, key, value, timestamp)
Definition:
echo.py:37
mbed_host_tests.host_tests.echo.EchoTest
Definition:
echo.py:22
mbed_host_tests.host_tests.echo.EchoTest.__send_echo_uuid
def __send_echo_uuid(self)
Definition:
echo.py:30
mbed_host_tests.host_tests.echo.EchoTest.uuid_sent
list uuid_sent
Definition:
echo.py:27
mbed_host_tests.host_tests.echo.EchoTest.uuid_recv
list uuid_recv
Definition:
echo.py:28
mbed_host_tests.host_tests.echo.EchoTest.result
def result(self)
Definition:
echo.py:52
mbed_host_tests
host_tests
echo.py
Generated by
1.8.18