![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/TEST_APPS/testcases/netsocket/TCPSOCKET_ECHOTEST_BURST_SHORT.py@0:8fdf9a60065b, 2018-10-10 (annotated)
- Committer:
- kadonotakashi
- Date:
- Wed Oct 10 00:33:53 2018 +0000
- Revision:
- 0:8fdf9a60065b
how to make mbed librry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | """ |
kadonotakashi | 0:8fdf9a60065b | 2 | Copyright 2018 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 4 | you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 5 | You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 6 | |
kadonotakashi | 0:8fdf9a60065b | 7 | http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 8 | |
kadonotakashi | 0:8fdf9a60065b | 9 | Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 10 | distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 12 | See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 13 | limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 14 | """ |
kadonotakashi | 0:8fdf9a60065b | 15 | import string |
kadonotakashi | 0:8fdf9a60065b | 16 | |
kadonotakashi | 0:8fdf9a60065b | 17 | from icetea_lib.Randomize.randomize import Randomize |
kadonotakashi | 0:8fdf9a60065b | 18 | from icetea_lib.bench import Bench, TestStepFail |
kadonotakashi | 0:8fdf9a60065b | 19 | |
kadonotakashi | 0:8fdf9a60065b | 20 | |
kadonotakashi | 0:8fdf9a60065b | 21 | class Testcase(Bench): |
kadonotakashi | 0:8fdf9a60065b | 22 | def __init__(self): |
kadonotakashi | 0:8fdf9a60065b | 23 | Bench.__init__(self, |
kadonotakashi | 0:8fdf9a60065b | 24 | name="TCPSOCKET_ECHOTEST_BURST_SHORT", |
kadonotakashi | 0:8fdf9a60065b | 25 | title="TCPSOCKET_ECHOTEST_BURST_SHORT", |
kadonotakashi | 0:8fdf9a60065b | 26 | purpose="Verify that TCPSocket can send burst of packets to echo server and read incoming packets", |
kadonotakashi | 0:8fdf9a60065b | 27 | status="released", |
kadonotakashi | 0:8fdf9a60065b | 28 | component=["mbed-os", "netsocket"], |
kadonotakashi | 0:8fdf9a60065b | 29 | author="Juha Ylinen <juha.ylinen@arm.com>", |
kadonotakashi | 0:8fdf9a60065b | 30 | type="smoke", |
kadonotakashi | 0:8fdf9a60065b | 31 | subtype="socket", |
kadonotakashi | 0:8fdf9a60065b | 32 | requirements={ |
kadonotakashi | 0:8fdf9a60065b | 33 | "duts": { |
kadonotakashi | 0:8fdf9a60065b | 34 | '*': { # requirements for all nodes |
kadonotakashi | 0:8fdf9a60065b | 35 | "count": 1, |
kadonotakashi | 0:8fdf9a60065b | 36 | "type": "hardware", |
kadonotakashi | 0:8fdf9a60065b | 37 | "application": { |
kadonotakashi | 0:8fdf9a60065b | 38 | "name": "TEST_APPS-device-socket_app" |
kadonotakashi | 0:8fdf9a60065b | 39 | } |
kadonotakashi | 0:8fdf9a60065b | 40 | }, |
kadonotakashi | 0:8fdf9a60065b | 41 | "1": {"nick": "dut1"}, |
kadonotakashi | 0:8fdf9a60065b | 42 | } |
kadonotakashi | 0:8fdf9a60065b | 43 | } |
kadonotakashi | 0:8fdf9a60065b | 44 | ) |
kadonotakashi | 0:8fdf9a60065b | 45 | |
kadonotakashi | 0:8fdf9a60065b | 46 | def setup(self): |
kadonotakashi | 0:8fdf9a60065b | 47 | self.command("dut1", "ifup") |
kadonotakashi | 0:8fdf9a60065b | 48 | |
kadonotakashi | 0:8fdf9a60065b | 49 | def case(self): |
kadonotakashi | 0:8fdf9a60065b | 50 | response = self.command("dut1", "socket new TCPSocket") |
kadonotakashi | 0:8fdf9a60065b | 51 | socket_id = int(response.parsed['socket_id']) |
kadonotakashi | 0:8fdf9a60065b | 52 | |
kadonotakashi | 0:8fdf9a60065b | 53 | self.command("dut1", "socket " + str(socket_id) + " open") |
kadonotakashi | 0:8fdf9a60065b | 54 | self.command("dut1", "socket " + str(socket_id) + " connect echo.mbedcloudtesting.com 7") |
kadonotakashi | 0:8fdf9a60065b | 55 | |
kadonotakashi | 0:8fdf9a60065b | 56 | for i in range(2): |
kadonotakashi | 0:8fdf9a60065b | 57 | sentData = "" |
kadonotakashi | 0:8fdf9a60065b | 58 | for size in (100, 200, 300, 120, 500): |
kadonotakashi | 0:8fdf9a60065b | 59 | packet = Randomize.random_string(max_len=size, min_len=size, chars=string.ascii_uppercase) |
kadonotakashi | 0:8fdf9a60065b | 60 | sentData += packet |
kadonotakashi | 0:8fdf9a60065b | 61 | response = self.command("dut1", "socket " + str(socket_id) + " send " + str(packet)) |
kadonotakashi | 0:8fdf9a60065b | 62 | response.verify_trace("TCPSocket::send() returned: " + str(size)) |
kadonotakashi | 0:8fdf9a60065b | 63 | |
kadonotakashi | 0:8fdf9a60065b | 64 | received = 0 |
kadonotakashi | 0:8fdf9a60065b | 65 | data = "" |
kadonotakashi | 0:8fdf9a60065b | 66 | totalSize = 1220 |
kadonotakashi | 0:8fdf9a60065b | 67 | while received < totalSize: |
kadonotakashi | 0:8fdf9a60065b | 68 | response = self.command("dut1", "socket " + str(socket_id) + " recv " + str(totalSize)) |
kadonotakashi | 0:8fdf9a60065b | 69 | data += response.parsed['data'].replace(":", "") |
kadonotakashi | 0:8fdf9a60065b | 70 | received += int(response.parsed['received_bytes']) |
kadonotakashi | 0:8fdf9a60065b | 71 | |
kadonotakashi | 0:8fdf9a60065b | 72 | if data != sentData: |
kadonotakashi | 0:8fdf9a60065b | 73 | raise TestStepFail("Received data doesn't match the sent data") |
kadonotakashi | 0:8fdf9a60065b | 74 | |
kadonotakashi | 0:8fdf9a60065b | 75 | self.command("dut1", "socket " + str(socket_id) + " delete") |
kadonotakashi | 0:8fdf9a60065b | 76 | |
kadonotakashi | 0:8fdf9a60065b | 77 | def teardown(self): |
kadonotakashi | 0:8fdf9a60065b | 78 | self.command("dut1", "ifdown") |