diff mbox series

[V1] framework: fix Trex mode not working

Message ID 20201104025209.8423-1-box.c.chen@intel.com (mailing list archive)
State Accepted
Headers show
Series [V1] framework: fix Trex mode not working | expand

Commit Message

Chen, BoX C Nov. 4, 2020, 2:52 a.m. UTC
DTS requires Trex compatible scapy, modify package loading mode and scapy version verification rules

Signed-off-by: Chen, BoX C <box.c.chen@intel.com>
---
 framework/packet.py | 23 +++++++++++++----------
 framework/tester.py | 12 ++++--------
 2 files changed, 17 insertions(+), 18 deletions(-)

Comments

Tu, Lijuan Nov. 11, 2020, 2:50 a.m. UTC | #1
> DTS requires Trex compatible scapy, modify package loading mode and scapy
> version verification rules
> 
> Signed-off-by: Chen, BoX C <box.c.chen@intel.com>

Applied, thanks
diff mbox series

Patch

diff --git a/framework/packet.py b/framework/packet.py
index dbc0058..7d974db 100644
--- a/framework/packet.py
+++ b/framework/packet.py
@@ -57,19 +57,22 @@  scapy_modules_required = {'gtp': ['GTP_U_Header', 'GTPPDUSessionContainer'],
 local_modules = [m[:-3] for m in os.listdir(DEP_FOLDER + '/scapy_modules') if (m.endswith('.py') and not m.startswith('__'))]
 
 for m in scapy_modules_required:
-    if m in local_modules:
-        module = import_module(m)
-        for clazz in scapy_modules_required[m]:
-            locals().update({clazz: getattr(module, clazz)})
-    else:
-        if m == 'sctp':
-            module = import_module(f'scapy.layers.{m}')
+    try:
+        if m in local_modules:
+            module = import_module(m)
             for clazz in scapy_modules_required[m]:
                 locals().update({clazz: getattr(module, clazz)})
         else:
-            module = import_module(f'scapy.contrib.{m}')
-            for clazz in scapy_modules_required[m]:
-                locals().update({clazz: getattr(module, clazz)})
+            if m == 'sctp':
+                module = import_module(f'scapy.layers.{m}')
+                for clazz in scapy_modules_required[m]:
+                    locals().update({clazz: getattr(module, clazz)})
+            else:
+                module = import_module(f'scapy.contrib.{m}')
+                for clazz in scapy_modules_required[m]:
+                    locals().update({clazz: getattr(module, clazz)})
+    except Exception as e:
+        print(e)
 
 def get_scapy_module_impcmd():
     cmd_li = list()
diff --git a/framework/tester.py b/framework/tester.py
index df432d5..b2cbdb0 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -111,21 +111,17 @@  class Tester(Crb):
 
     def check_scapy_version(self):
         require_version = '2.4.4'
-        self.scapy_session.get_session_before(timeout = 1)
+        self.scapy_session.get_session_before(timeout=1)
         self.scapy_session.send_expect('conf.version', '\'')
-        out = self.scapy_session.get_session_before(timeout = 1)
+        out = self.scapy_session.get_session_before(timeout=1)
         cur_version = out[:out.find('\'')]
         out = self.session.send_expect('grep scapy requirements.txt', '# ')
         value = re.search('scapy\s*==\s*(\S*)', out)
         if value is not None:
             require_version = value.group(1)
-        cur_version = cur_version.split('.')
-        require_version = require_version.split('.')
-        for i in range(len(require_version)):
-            if int(cur_version[i]) < int(require_version[i]):
-                self.logger.warning('The scapy vesrion not meet the requirement on tester,' +
+        if cur_version != require_version:
+            self.logger.warning('The scapy vesrion not meet the requirement on tester,' +
                     'please update your scapy, otherwise maybe some suite will failed')
-                break
 
     def init_ext_gen(self):
         """