Autoformatting files

pull/7745/head
Olli-Pekka Puolitaival 2018-08-20 09:50:55 +03:00
parent 912c4f5c05
commit 54ff956461
5 changed files with 34 additions and 28 deletions

2
.gitignore vendored
View File

@ -90,4 +90,4 @@ tags
features/FEATURE_BLE/targets/TARGET_CORDIO/stack_backup/
.pytest_cache
log
log

View File

@ -12,35 +12,37 @@ 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.
"""
from icetea_lib.bench import Bench
from interface import interfaceUp, interfaceDown
import threading
import time
from icetea_lib.bench import Bench
from interface import interfaceUp, interfaceDown
class Testcase(Bench):
def __init__(self):
Bench.__init__(self,
name="TCPSERVER_ACCEPT",
title = "TCPSERVER_ACCEPT",
purpose = "Test that TCPServer::bind(), TCPServer::listen() and TCPServer::accept() works",
status = "released",
component= ["mbed-os", "netsocket"],
author = "Juha Ylinen <juha.ylinen@arm.com>",
title="TCPSERVER_ACCEPT",
purpose="Test that TCPServer::bind(), TCPServer::listen() and TCPServer::accept() works",
status="released",
component=["mbed-os", "netsocket"],
author="Juha Ylinen <juha.ylinen@arm.com>",
type="smoke",
subtype="socket",
requirements={
"duts": {
'*': { #requirements for all nodes
"count":2,
"type": "hardware",
"application": {"name": "TEST_APPS-device-socket_app"}
},
"1": {"nick": "dut1"},
"2": {"nick": "dut2"}
'*': { # requirements for all nodes
"count": 2,
"type": "hardware",
"application": {"name": "TEST_APPS-device-socket_app"}
},
"1": {"nick": "dut1"},
"2": {"nick": "dut2"}
}
}
)
)
def setup(self):
interface = interfaceUp(self, ["dut1"])
@ -50,10 +52,10 @@ class Testcase(Bench):
def clientThread(self):
self.logger.info("Starting")
time.sleep(5) #wait accept from server
time.sleep(5) # wait accept from server
self.command("dut2", "socket " + str(self.client_socket_id) + " open")
self.command("dut2", "socket " + str(self.client_socket_id) + " connect " + str(self.server_ip) + " " + str(self.used_port))
self.command("dut2", "socket " + str(self.client_socket_id) + " connect " + str(self.server_ip) + " " + str(
self.used_port))
def case(self):
self.used_port = 2000
@ -73,20 +75,20 @@ class Testcase(Bench):
zero = response.timedelta
self.client_socket_id = int(response.parsed['socket_id'])
#Create a thread which calls client connect()
# Create a thread which calls client connect()
t = threading.Thread(name='clientThread', target=self.clientThread)
t.start()
wait = 5
response = self.command("dut1", "socket " + str(server_base_socket_id) + " accept " + str(server_socket_id))
response.verify_response_duration(expected = wait, zero = zero, threshold_percent = 10, break_in_fail = True)
response.verify_response_duration(expected=wait, zero=zero, threshold_percent=10, break_in_fail=True)
socket_id = int(response.parsed['socket_id'])
t.join()
self.command("dut1", "socket " + str(socket_id) + " send hello")
response = self.command("dut2", "socket " + str(self.client_socket_id) + " recv 5")
data = response.parsed['data'].replace(":","")
data = response.parsed['data'].replace(":", "")
if data != "hello":
raise TestStepFail("Received data doesn't match the sent data")
@ -95,7 +97,6 @@ class Testcase(Bench):
self.command("dut1", "socket " + str(server_base_socket_id) + " delete")
self.command("dut2", "socket " + str(self.client_socket_id) + " delete")
def teardown(self):
interfaceDown(self, ["dut1"])
interfaceDown(self, ["dut2"])

View File

@ -12,10 +12,11 @@ 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.
"""
from icetea_lib.bench import Bench, TestStepFail
import random
import string
from icetea_lib.bench import Bench, TestStepFail
class Testcase(Bench):
def __init__(self):
@ -31,9 +32,9 @@ class Testcase(Bench):
requirements={
"duts": {
'*': { # requirements for all nodes
"count": 1,
"type": "hardware",
"application": {"name": "TEST_APPS-device-socket_app"}
"count": 1,
"type": "hardware",
"application": {"name": "TEST_APPS-device-socket_app"}
},
"1": {"nick": "dut1"},
}

View File

@ -19,6 +19,7 @@ This script is intended to be a common test data generator.
Currently it implements randomUppercaseAsciiString, randomLowercaseAsciiString methods.
'''
def randomUppercaseAsciiString(length):
return ''.join(random.choice(string.ascii_uppercase) for i in range(length))

View File

@ -13,15 +13,17 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
from icetea_lib.TestStepError import TestStepFail
'''
This interface script is intended to be a common library to be used in testcase scripts by testers.
It delegates setUp and tearDown functions with different provided network interface types using setUp() and tearDown() methods.
'''
def interfaceUp(tc, duts):
interfaces = {}
for dut in duts:
interface = {dut:{"ipv4": None, "ipv6": None}}
interface = {dut: {"ipv4": None, "ipv6": None}}
resp = tc.command("%s" % dut, "ifup")
@ -35,6 +37,7 @@ def interfaceUp(tc, duts):
interfaces.update(interface)
return interfaces
def interfaceDown(tc, duts):
for dut in duts:
tc.command(dut, "ifdown")