tests: Skip test cases properly if tshark is not available

Instead of trying to process empty results, mark the test case as
skipped if tshark is not available.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2020-12-04 11:43:45 +02:00
parent 95cff14c6f
commit 0dcfdd5e47

View file

@ -12,6 +12,8 @@ import subprocess
import logging import logging
logger = logging.getLogger() logger = logging.getLogger()
from utils import *
class UnknownFieldsException(Exception): class UnknownFieldsException(Exception):
def __init__(self, fields): def __init__(self, fields):
Exception.__init__(self, "unknown tshark fields %s" % ','.join(fields)) Exception.__init__(self, "unknown tshark fields %s" % ','.join(fields))
@ -41,6 +43,8 @@ def _run_tshark(filename, filter, display=None, wait=True):
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
except Exception as e: except Exception as e:
logger.info("Could run run tshark check: " + str(e)) logger.info("Could run run tshark check: " + str(e))
if "No such file or directory: 'tshark'" in str(e):
raise HwsimSkip("No tshark available")
cmd = None cmd = None
return None return None
@ -111,6 +115,8 @@ def run_tshark_json(filename, filter):
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
except Exception as e: except Exception as e:
logger.info("Could run run tshark: " + str(e)) logger.info("Could run run tshark: " + str(e))
if "No such file or directory: 'tshark'" in str(e):
raise HwsimSkip("No tshark available")
return None return None
output = cmd.communicate() output = cmd.communicate()
out = output[0].decode() out = output[0].decode()