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_countecho_countecho_count:
32  str_uuid = str(uuid.uuid4())
33  self.send_kv("echo", str_uuid)
34  self.uuid_sentuuid_sentuuid_sent.append(str_uuid)
35  self.echo_countecho_countecho_count -= 1
36 
37  def _callback_echo(self, key, value, timestamp):
38  self.uuid_recvuuid_recv.append(value)
39  self.__send_echo_uuid__send_echo_uuid()
40 
41  def _callback_echo_count(self, key, value, timestamp):
42  # Handshake
43  self.echo_countecho_countecho_count = int(value)
44  self.send_kv(key, value)
45  # Send first echo to echo server on DUT
46  self.__send_echo_uuid__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__result = self.uuid_sentuuid_sentuuid_sent == self.uuid_recvuuid_recv
54  return self.__result__result
55 
56  def teardown(self):
57  pass
def _callback_echo(self, key, value, timestamp)
Definition: echo.py:37
def _callback_echo_count(self, key, value, timestamp)
Definition: echo.py:41