mirror of https://github.com/ARMmbed/mbed-os.git
Autoformatting files
parent
912c4f5c05
commit
54ff956461
|
@ -90,4 +90,4 @@ tags
|
||||||
features/FEATURE_BLE/targets/TARGET_CORDIO/stack_backup/
|
features/FEATURE_BLE/targets/TARGET_CORDIO/stack_backup/
|
||||||
|
|
||||||
.pytest_cache
|
.pytest_cache
|
||||||
log
|
log
|
||||||
|
|
|
@ -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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
from icetea_lib.bench import Bench
|
|
||||||
from interface import interfaceUp, interfaceDown
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from icetea_lib.bench import Bench
|
||||||
|
from interface import interfaceUp, interfaceDown
|
||||||
|
|
||||||
|
|
||||||
class Testcase(Bench):
|
class Testcase(Bench):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Bench.__init__(self,
|
Bench.__init__(self,
|
||||||
name="TCPSERVER_ACCEPT",
|
name="TCPSERVER_ACCEPT",
|
||||||
title = "TCPSERVER_ACCEPT",
|
title="TCPSERVER_ACCEPT",
|
||||||
purpose = "Test that TCPServer::bind(), TCPServer::listen() and TCPServer::accept() works",
|
purpose="Test that TCPServer::bind(), TCPServer::listen() and TCPServer::accept() works",
|
||||||
status = "released",
|
status="released",
|
||||||
component= ["mbed-os", "netsocket"],
|
component=["mbed-os", "netsocket"],
|
||||||
author = "Juha Ylinen <juha.ylinen@arm.com>",
|
author="Juha Ylinen <juha.ylinen@arm.com>",
|
||||||
type="smoke",
|
type="smoke",
|
||||||
subtype="socket",
|
subtype="socket",
|
||||||
requirements={
|
requirements={
|
||||||
"duts": {
|
"duts": {
|
||||||
'*': { #requirements for all nodes
|
'*': { # requirements for all nodes
|
||||||
"count":2,
|
"count": 2,
|
||||||
"type": "hardware",
|
"type": "hardware",
|
||||||
"application": {"name": "TEST_APPS-device-socket_app"}
|
"application": {"name": "TEST_APPS-device-socket_app"}
|
||||||
},
|
},
|
||||||
"1": {"nick": "dut1"},
|
"1": {"nick": "dut1"},
|
||||||
"2": {"nick": "dut2"}
|
"2": {"nick": "dut2"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
interface = interfaceUp(self, ["dut1"])
|
interface = interfaceUp(self, ["dut1"])
|
||||||
|
@ -50,10 +52,10 @@ class Testcase(Bench):
|
||||||
|
|
||||||
def clientThread(self):
|
def clientThread(self):
|
||||||
self.logger.info("Starting")
|
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) + " 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):
|
def case(self):
|
||||||
self.used_port = 2000
|
self.used_port = 2000
|
||||||
|
@ -73,20 +75,20 @@ class Testcase(Bench):
|
||||||
zero = response.timedelta
|
zero = response.timedelta
|
||||||
self.client_socket_id = int(response.parsed['socket_id'])
|
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 = threading.Thread(name='clientThread', target=self.clientThread)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
||||||
wait = 5
|
wait = 5
|
||||||
response = self.command("dut1", "socket " + str(server_base_socket_id) + " accept " + str(server_socket_id))
|
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'])
|
socket_id = int(response.parsed['socket_id'])
|
||||||
|
|
||||||
t.join()
|
t.join()
|
||||||
self.command("dut1", "socket " + str(socket_id) + " send hello")
|
self.command("dut1", "socket " + str(socket_id) + " send hello")
|
||||||
|
|
||||||
response = self.command("dut2", "socket " + str(self.client_socket_id) + " recv 5")
|
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":
|
if data != "hello":
|
||||||
raise TestStepFail("Received data doesn't match the sent data")
|
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("dut1", "socket " + str(server_base_socket_id) + " delete")
|
||||||
self.command("dut2", "socket " + str(self.client_socket_id) + " delete")
|
self.command("dut2", "socket " + str(self.client_socket_id) + " delete")
|
||||||
|
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
interfaceDown(self, ["dut1"])
|
interfaceDown(self, ["dut1"])
|
||||||
interfaceDown(self, ["dut2"])
|
interfaceDown(self, ["dut2"])
|
||||||
|
|
|
@ -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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
from icetea_lib.bench import Bench, TestStepFail
|
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
from icetea_lib.bench import Bench, TestStepFail
|
||||||
|
|
||||||
|
|
||||||
class Testcase(Bench):
|
class Testcase(Bench):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -31,9 +32,9 @@ class Testcase(Bench):
|
||||||
requirements={
|
requirements={
|
||||||
"duts": {
|
"duts": {
|
||||||
'*': { # requirements for all nodes
|
'*': { # requirements for all nodes
|
||||||
"count": 1,
|
"count": 1,
|
||||||
"type": "hardware",
|
"type": "hardware",
|
||||||
"application": {"name": "TEST_APPS-device-socket_app"}
|
"application": {"name": "TEST_APPS-device-socket_app"}
|
||||||
},
|
},
|
||||||
"1": {"nick": "dut1"},
|
"1": {"nick": "dut1"},
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ This script is intended to be a common test data generator.
|
||||||
Currently it implements randomUppercaseAsciiString, randomLowercaseAsciiString methods.
|
Currently it implements randomUppercaseAsciiString, randomLowercaseAsciiString methods.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def randomUppercaseAsciiString(length):
|
def randomUppercaseAsciiString(length):
|
||||||
return ''.join(random.choice(string.ascii_uppercase) for i in range(length))
|
return ''.join(random.choice(string.ascii_uppercase) for i in range(length))
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,17 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
from icetea_lib.TestStepError import TestStepFail
|
from icetea_lib.TestStepError import TestStepFail
|
||||||
|
|
||||||
'''
|
'''
|
||||||
This interface script is intended to be a common library to be used in testcase scripts by testers.
|
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.
|
It delegates setUp and tearDown functions with different provided network interface types using setUp() and tearDown() methods.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def interfaceUp(tc, duts):
|
def interfaceUp(tc, duts):
|
||||||
interfaces = {}
|
interfaces = {}
|
||||||
for dut in duts:
|
for dut in duts:
|
||||||
interface = {dut:{"ipv4": None, "ipv6": None}}
|
interface = {dut: {"ipv4": None, "ipv6": None}}
|
||||||
|
|
||||||
resp = tc.command("%s" % dut, "ifup")
|
resp = tc.command("%s" % dut, "ifup")
|
||||||
|
|
||||||
|
@ -35,6 +37,7 @@ def interfaceUp(tc, duts):
|
||||||
interfaces.update(interface)
|
interfaces.update(interface)
|
||||||
return interfaces
|
return interfaces
|
||||||
|
|
||||||
|
|
||||||
def interfaceDown(tc, duts):
|
def interfaceDown(tc, duts):
|
||||||
for dut in duts:
|
for dut in duts:
|
||||||
tc.command(dut, "ifdown")
|
tc.command(dut, "ifdown")
|
||||||
|
|
Loading…
Reference in New Issue