diff --git a/TEST_APPS/testcases/netsocket/TCPSERVER_ACCEPT.py b/TEST_APPS/testcases/netsocket/TCPSERVER_ACCEPT.py index a1711a5669..e975d68359 100644 --- a/TEST_APPS/testcases/netsocket/TCPSERVER_ACCEPT.py +++ b/TEST_APPS/testcases/netsocket/TCPSERVER_ACCEPT.py @@ -16,6 +16,7 @@ limitations under the License. import threading import time +from icetea_lib.TestStepError import TestStepFail from icetea_lib.bench import Bench from interface import interfaceUp, interfaceDown diff --git a/TEST_APPS/testcases/netsocket/TCPSOCKET_ECHOTEST_BURST_SHORT.py b/TEST_APPS/testcases/netsocket/TCPSOCKET_ECHOTEST_BURST_SHORT.py index d4f2df0bf1..0d7eb93263 100644 --- a/TEST_APPS/testcases/netsocket/TCPSOCKET_ECHOTEST_BURST_SHORT.py +++ b/TEST_APPS/testcases/netsocket/TCPSOCKET_ECHOTEST_BURST_SHORT.py @@ -12,9 +12,9 @@ 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 random import string +from icetea_lib.Randomize.randomize import Randomize from icetea_lib.bench import Bench, TestStepFail @@ -44,9 +44,6 @@ class Testcase(Bench): def setup(self): self.command("dut1", "ifup") - def randomString(self, length): - return ''.join(random.choice(string.ascii_uppercase) for i in range(length)) - def case(self): response = self.command("dut1", "socket new TCPSocket") socket_id = int(response.parsed['socket_id']) @@ -57,7 +54,7 @@ class Testcase(Bench): for i in range(2): sentData = "" for size in (100, 200, 300, 120, 500): - packet = self.randomString(size) + packet = Randomize.random_string(max_len=size, min_len=size, chars=string.ascii_uppercase) sentData += packet response = self.command("dut1", "socket " + str(socket_id) + " send " + str(packet)) response.verify_trace("TCPSocket::send() returned: " + str(size)) diff --git a/TEST_APPS/testcases/netsocket/generate_test_data.py b/TEST_APPS/testcases/netsocket/generate_test_data.py deleted file mode 100644 index 38400fe487..0000000000 --- a/TEST_APPS/testcases/netsocket/generate_test_data.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -Copyright 2018 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 random, string - -''' -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)) - - -def randomLowercaseAsciiString(length): - return ''.join(random.choice(string.ascii_lowercase) for i in range(length)) diff --git a/TEST_APPS/testcases/netsocket/interface.py b/TEST_APPS/testcases/netsocket/interface.py index 82cc2acbb2..db81636ec3 100644 --- a/TEST_APPS/testcases/netsocket/interface.py +++ b/TEST_APPS/testcases/netsocket/interface.py @@ -29,7 +29,7 @@ def interfaceUp(tc, duts): ip = interface[dut]["ip"] = interface[dut]["ipv4"] = resp.parsed["address"]["ipv4"] if not ip: - if resp.parsed["address"]["ipv6"] != []: + if resp.parsed["address"]["ipv6"]: ip = interface[dut]["ip"] = interface[dut]["ipv6"] = resp.parsed["address"]["ipv6"][0] if not ip: raise TestStepFail("Failed to parse IP address")