[V1] framework: add the check of scapy version
diff mbox series

Message ID 1603128651-18576-1-git-send-email-lihongx.ma@intel.com
State Superseded
Headers show
Series
  • [V1] framework: add the check of scapy version
Related show

Commit Message

Ma, LihongX Oct. 19, 2020, 5:30 p.m. UTC
- modify the requirement scapy version to 2.4.2
 - add the check of the scapy version on tester

Signed-off-by: LihongX Ma <lihongx.ma@intel.com>
---
 framework/tester.py | 19 +++++++++++++++++++
 requirements.txt    |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/framework/tester.py b/framework/tester.py
index ca179b2..008c10d 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -80,6 +80,7 @@  class Tester(Crb):
         # prepare for scapy env
         self.scapy_sessions_li = list()
         self.scapy_session = self.prepare_scapy_env()
+        self.check_scapy_version()
         self.tmp_file = '/tmp/tester/'
         out = self.send_expect('ls -d %s' % self.tmp_file, '# ', verify=True)
         if out == 2:
@@ -105,6 +106,24 @@  class Tester(Crb):
             session.logger.warning(f'entering import error: {out}')
         return session
 
+    def check_scapy_version(self):
+        require_version = '2.4.4'
+        self.scapy_session.get_session_before(timeout = 1)
+        self.scapy_session.send_expect('conf.version', '\'')
+        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,' +
+                    'please update your scapy, otherwise maybe some suite will failed')
+                break
+
     def init_ext_gen(self):
         """
         Initialize tester packet generator object.
diff --git a/requirements.txt b/requirements.txt
index cb9f636..fae0ace 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -36,5 +36,5 @@  numpy==1.18.5
 docutils
 pcapy
 xlrd
-scapy==2.4.3
+scapy==2.4.4
 threadpool