echo.py
Go to the documentation of this file.
"""
mbed SDK
Copyright (c) 2011-2016 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import uuid
from mbed_host_tests import BaseHostTest
class EchoTest(BaseHostTest):
__result = None
echo_count = 0
count = 0
uuid_sent = []
uuid_recv = []
def __send_echo_uuid(self):
if self.echo_count echo_countecho_count:
str_uuid = str(uuid.uuid4())
self.send_kv("echo", str_uuid)
self.uuid_sent uuid_sentuuid_sent.append(str_uuid)
self.echo_count echo_countecho_count -= 1
def _callback_echo(self, key, value, timestamp):
self.uuid_recvuuid_recv.append(value)
self.__send_echo_uuid__send_echo_uuid()
def _callback_echo_count(self, key, value, timestamp):
# Handshake
self.echo_count echo_countecho_count = int(value)
self.send_kv(key, value)
# Send first echo to echo server on DUT
self.__send_echo_uuid__send_echo_uuid()
def setup(self):
self.register_callback("echo", self._callback_echo_callback_echo)
self.register_callback("echo_count", self._callback_echo_count_callback_echo_count)
def result(self):
self.__result__result = self.uuid_sent uuid_sentuuid_sent == self.uuid_recvuuid_recv
return self.__result__result
def teardown(self):
pass
mbed_host_tests.host_tests.echo.EchoTest
Definition: echo.py:22
mbed_host_tests.host_tests.echo.EchoTest.uuid_sent
list uuid_sent
Definition: echo.py:27
mbed_host_tests.host_tests.echo.EchoTest.echo_count
echo_count
Definition: echo.py:43
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.setup
def setup(self)
Definition: echo.py:48
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.EchoTest.echo_count
int echo_count
Definition: echo.py:25
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.__send_echo_uuid
def __send_echo_uuid(self)
Definition: echo.py:30
mbed_host_tests.host_tests.echo.EchoTest.__result
__result
Definition: echo.py:24
mbed_host_tests.host_tests.echo.EchoTest.uuid_sent
uuid_sent
Definition: echo.py:53