Device Emulation(contd.): Specify minimum tshark version that supports the filters we need for verification

This commit is contained in:
Srivats P 2016-01-26 14:05:26 +05:30
parent 83e4aeb992
commit d309bc9362
2 changed files with 28 additions and 3 deletions

View File

@ -12,7 +12,8 @@ import time
import pytest
from fabric.api import run, env, sudo
#from harness import Test, TestSuite, TestPreRequisiteError
from utils import get_tshark
sys.path.insert(1, '../binding')
from core import ost_pb, emul, DroneProxy
@ -24,8 +25,10 @@ from protocols.vlan_pb2 import vlan
use_defaults = True
tshark = 'tshark'
# FIXME: ensure minimum tshark version 1.4 => supports ICMPV6 NS/NA filters
tshark = get_tshark(minversion = '1.6')
if tshark is None:
print 'tshark >= 1.6 not found'
sys.exit(1)
# initialize defaults - drone
host_name = '127.0.0.1'

22
test/utils.py Normal file
View File

@ -0,0 +1,22 @@
#! /usr/bin/env python
import subprocess
import sys
#from distutils.spawn import find_executable
from distutils.version import LooseVersion
def get_tshark(minversion = None):
tshark = 'tshark'
#if sys.platform == 'win32':
# tshark = find_executable(tshark)
if tshark and minversion:
out = subprocess.check_output([tshark, '-v']).split(None, 2)
# we expect output to be of the form 'Tshark <version> ..."
ver = out[1]
if LooseVersion(ver) < LooseVersion(minversion):
tshark = None
if tshark is not None:
print('%s version %s found' % (tshark, ver))
return tshark