mirror of https://github.com/ARMmbed/mbed-os.git
Use icetea random string generator
parent
54ff956461
commit
49f842b4f6
|
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from icetea_lib.TestStepError import TestStepFail
|
||||||
from icetea_lib.bench import Bench
|
from icetea_lib.bench import Bench
|
||||||
from interface import interfaceUp, interfaceDown
|
from interface import interfaceUp, interfaceDown
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
import random
|
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
from icetea_lib.Randomize.randomize import Randomize
|
||||||
from icetea_lib.bench import Bench, TestStepFail
|
from icetea_lib.bench import Bench, TestStepFail
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -44,9 +44,6 @@ class Testcase(Bench):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.command("dut1", "ifup")
|
self.command("dut1", "ifup")
|
||||||
|
|
||||||
def randomString(self, length):
|
|
||||||
return ''.join(random.choice(string.ascii_uppercase) for i in range(length))
|
|
||||||
|
|
||||||
def case(self):
|
def case(self):
|
||||||
response = self.command("dut1", "socket new TCPSocket")
|
response = self.command("dut1", "socket new TCPSocket")
|
||||||
socket_id = int(response.parsed['socket_id'])
|
socket_id = int(response.parsed['socket_id'])
|
||||||
|
|
@ -57,7 +54,7 @@ class Testcase(Bench):
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
sentData = ""
|
sentData = ""
|
||||||
for size in (100, 200, 300, 120, 500):
|
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
|
sentData += packet
|
||||||
response = self.command("dut1", "socket " + str(socket_id) + " send " + str(packet))
|
response = self.command("dut1", "socket " + str(socket_id) + " send " + str(packet))
|
||||||
response.verify_trace("TCPSocket::send() returned: " + str(size))
|
response.verify_trace("TCPSocket::send() returned: " + str(size))
|
||||||
|
|
|
||||||
|
|
@ -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))
|
|
||||||
|
|
@ -29,7 +29,7 @@ def interfaceUp(tc, duts):
|
||||||
|
|
||||||
ip = interface[dut]["ip"] = interface[dut]["ipv4"] = resp.parsed["address"]["ipv4"]
|
ip = interface[dut]["ip"] = interface[dut]["ipv4"] = resp.parsed["address"]["ipv4"]
|
||||||
if not ip:
|
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]
|
ip = interface[dut]["ip"] = interface[dut]["ipv6"] = resp.parsed["address"]["ipv6"][0]
|
||||||
if not ip:
|
if not ip:
|
||||||
raise TestStepFail("Failed to parse IP address")
|
raise TestStepFail("Failed to parse IP address")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue