summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/automation/regression/functional_tests/platform_cmd_cache_test.py4
-rwxr-xr-xscripts/automation/regression/functional_tests/platform_if_manager_test.py10
-rw-r--r--scripts/automation/regression/functional_tests/stl_basic_tests.py6
-rwxr-xr-xscripts/automation/regression/platform_cmd_link.py5
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py4
-rwxr-xr-xscripts/find_python.sh14
-rwxr-xr-xscripts/run_functional_tests26
7 files changed, 56 insertions, 13 deletions
diff --git a/scripts/automation/regression/functional_tests/platform_cmd_cache_test.py b/scripts/automation/regression/functional_tests/platform_cmd_cache_test.py
index 077d81ce..0be21280 100755
--- a/scripts/automation/regression/functional_tests/platform_cmd_cache_test.py
+++ b/scripts/automation/regression/functional_tests/platform_cmd_cache_test.py
@@ -30,10 +30,10 @@ class CCommandCache_Test(functional_general_test.CGeneralFunctional_Test):
def test_dump_config (self):
import sys
- from io import BytesIO
+ from io import StringIO, BytesIO
saved_stdout = sys.stdout
try:
- out = BytesIO()
+ out = BytesIO() if sys.version_info < (3,0) else StringIO()
sys.stdout = out
self.cache.dump_config()
output = out.getvalue().strip()
diff --git a/scripts/automation/regression/functional_tests/platform_if_manager_test.py b/scripts/automation/regression/functional_tests/platform_if_manager_test.py
index b09e8d75..72015f55 100755
--- a/scripts/automation/regression/functional_tests/platform_if_manager_test.py
+++ b/scripts/automation/regression/functional_tests/platform_if_manager_test.py
@@ -28,13 +28,13 @@ class CIfManager_Test(functional_general_test.CGeneralFunctional_Test):
assert_equal( len(self.if_mng.get_dual_if_list()), 2 )
# check the classification with intf name
- assert_equal( map(CIfObj.get_name, self.if_mng.get_if_list() ), ['GigabitEthernet0/0/1','GigabitEthernet0/0/2','GigabitEthernet0/0/3','GigabitEthernet0/0/4'] )
- assert_equal( map(CIfObj.get_name, self.if_mng.get_if_list(is_duplicated = True) ), ['GigabitEthernet0/0/3','GigabitEthernet0/0/4'] )
- assert_equal( map(CIfObj.get_name, self.if_mng.get_if_list(is_duplicated = False) ), ['GigabitEthernet0/0/1','GigabitEthernet0/0/2'] )
- assert_equal( map(CIfObj.get_name, self.if_mng.get_duplicated_if() ), ['GigabitEthernet0/0/3', 'GigabitEthernet0/0/4'] )
+ assert_equal( list(map(CIfObj.get_name, self.if_mng.get_if_list()) ), ['GigabitEthernet0/0/1','GigabitEthernet0/0/2','GigabitEthernet0/0/3','GigabitEthernet0/0/4'] )
+ assert_equal( list(map(CIfObj.get_name, self.if_mng.get_if_list(is_duplicated = True)) ), ['GigabitEthernet0/0/3','GigabitEthernet0/0/4'] )
+ assert_equal( list(map(CIfObj.get_name, self.if_mng.get_if_list(is_duplicated = False)) ), ['GigabitEthernet0/0/1','GigabitEthernet0/0/2'] )
+ assert_equal( list(map(CIfObj.get_name, self.if_mng.get_duplicated_if()) ), ['GigabitEthernet0/0/3', 'GigabitEthernet0/0/4'] )
# check the classification with vrf name
- assert_equal( map(CDualIfObj.get_vrf_name, self.if_mng.get_dual_if_list() ), [None, 'dup'] )
+ assert_equal( list(map(CDualIfObj.get_vrf_name, self.if_mng.get_dual_if_list()) ), [None, 'dup'] )
def tearDown(self):
pass
diff --git a/scripts/automation/regression/functional_tests/stl_basic_tests.py b/scripts/automation/regression/functional_tests/stl_basic_tests.py
index 6467c128..2bf97307 100644
--- a/scripts/automation/regression/functional_tests/stl_basic_tests.py
+++ b/scripts/automation/regression/functional_tests/stl_basic_tests.py
@@ -133,14 +133,16 @@ class CStlBasic_Test(functional_general_test.CGeneralFunctional_Test):
if compare:
self.compare_caps(output_cap, golden_file)
-
+
except Exception as e:
print(e)
finally:
if not do_no_remove_generated:
os.unlink(generated_filename)
- os.unlink(generated_filename + 'c')
+ # python 3 does not generate PYC under the same dir
+ if os.path.exists(generated_filename + 'c'):
+ os.unlink(generated_filename + 'c')
if not do_no_remove:
os.unlink(output_cap)
diff --git a/scripts/automation/regression/platform_cmd_link.py b/scripts/automation/regression/platform_cmd_link.py
index eba20bfd..247127ca 100755
--- a/scripts/automation/regression/platform_cmd_link.py
+++ b/scripts/automation/regression/platform_cmd_link.py
@@ -5,13 +5,14 @@ import CustomLogger
import misc_methods
import telnetlib
import socket
+from collections import OrderedDict
class CCommandCache(object):
def __init__(self):
self.__gen_clean_data_structure()
def __gen_clean_data_structure (self):
- self.cache = {"IF" : {},
+ self.cache = {"IF" : OrderedDict(),
"CONF" : [],
"EXEC" : []}
@@ -274,7 +275,7 @@ class CIfManager(object):
_ipv6_gen = misc_methods.get_network_addr(ip_type = 'ipv6')
def __init__(self):
- self.interfarces = {}
+ self.interfarces = OrderedDict()
self.dual_intf = []
self.full_device_cfg = None
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
index eed20485..4f8ce3e6 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
@@ -534,15 +534,17 @@ class STLStream(object):
else:
new_data = ''.join([chr(c) if chr(c) in good_printable else r'\x{0:02x}'.format(c) for c in data])
- payload_start = packet_command.find("Raw(load='")
+ payload_start = packet_command.find("Raw(load=")
if payload_start != -1:
packet_command = packet_command[:payload_start-1]
layers = packet_command.split('/')
+
if payload:
if len(new_data) and new_data == new_data[0] * len(new_data):
layers.append("Raw(load='%s' * %s)" % (new_data[0], len(new_data)))
else:
layers.append("Raw(load='%s')" % new_data)
+
packet_code = 'packet = (' + (' / \n ').join(layers) + ')'
vm_list = []
for inst in self.fields['vm']['instructions']:
diff --git a/scripts/find_python.sh b/scripts/find_python.sh
index 9552260b..aba2d936 100755
--- a/scripts/find_python.sh
+++ b/scripts/find_python.sh
@@ -24,7 +24,21 @@ function find_python {
exit -1
}
+function find_python3 {
+ MACHINE_PYTHON=python3
+ PYTHON3=$MACHINE_PYTHON
+ PCHECK=`$PYTHON3 -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
+ if [ $? -eq 0 ]; then
+ return
+ fi
+ PYTHON3=
+
+}
+
if [ -z "$PYTHON" ]; then
find_python
fi
+if [ -z "$PYTHON3" ]; then
+ find_python3
+fi
diff --git a/scripts/run_functional_tests b/scripts/run_functional_tests
index e3a5fa61..783d6346 100755
--- a/scripts/run_functional_tests
+++ b/scripts/run_functional_tests
@@ -2,5 +2,29 @@
source find_python.sh
cd automation/regression
-$PYTHON trex_unit_test.py --functional $@
+
+if [ -z "$PYTHON" ]; then
+ echo "*** $PYTHON - python version is too old, 2.7 at least is required"
+else
+ $PYTHON trex_unit_test.py --functional $@
+ if [ $? -eq 0 ]; then
+ printf "\n$PYTHON test succeeded\n\n"
+ else
+ printf "\n*** $PYTHON test failed\n\n"
+ exit -1
+ fi
+fi
+
+if [ -z "$PYTHON3" ]; then
+ echo "*** $PYTHON3 - python3 version required is 3.4 - skipping python3 test"
+else
+ $PYTHON3 trex_unit_test.py --functional $@
+ if [ $? -eq 0 ]; then
+ printf "\n$PYTHON3 test succeeded\n\n"
+ else
+ printf "\n*** $PYTHON3 test failed\n\n"
+ exit -1
+ fi
+
+fi