Mbed Host Tests
echo.py
Go to the documentation of this file.
1"""
2mbed SDK
3Copyright (c) 2011-2016 ARM Limited
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16"""
17
18
19import uuid
20from mbed_host_tests import BaseHostTest
21
22class 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):
32 str_uuid = str(uuid.uuid4())
33 self.send_kv("echo", str_uuid)
34 self.uuid_sent.append(str_uuid)
35 self.echo_countecho_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_countecho_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_callback_echo)
50 self.register_callback("echo_count", self._callback_echo_count_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
_callback_echo_count(self, key, value, timestamp)
Definition echo.py:41
_callback_echo(self, key, value, timestamp)
Definition echo.py:37