From patchwork Tue Oct 24 15:11:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 829931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dkJyHQsc"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yLxb90F7Sz9t2c for ; Wed, 25 Oct 2017 02:12:37 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=oXYBEklzm0FH+iumOvV2uCvslqWS6WuB7rw/uJSEKXk=; b=dkJ yHQscIfsihss1i1QOvFyHaQoHKDWnWWSYyaRPSBFKqrnELJ4edb3MxOCrKV4rqqBckMvhDNpVGT8u laeN/mlHaH03AhfDRNQ6dfb2p7rA4COBrXED3y9er+2yKFA/fyE7t+ZEshF43shNNu1Eeq04I7Fhv 8HUgSqLZGUtL7/7pVYkloOsxJ5r+tTC0ECr76lUdCpqYussz9qsGqUoCMUWQbuRKggD/NPNEVSp9N 644qu5YppVfL53i3dfL5d4QdlPoLXJ1a9NtoAR7CAKFBW71IrqkBdjaDrroLhq2UPDlaSiH7H3O0h nMcrfqhP8x/zObYv3fUHSSRGKAcbj8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e70sR-0005Qe-6r; Tue, 24 Oct 2017 15:12:23 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:72ef::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e70s2-0005Mb-KE for hostap@lists.infradead.org; Tue, 24 Oct 2017 15:12:00 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1e70rd-00052b-CA; Tue, 24 Oct 2017 17:11:33 +0200 From: Johannes Berg To: hostap@lists.infradead.org Subject: [PATCH] hwsim tests: tshark: deal with "wlan_mgt" -> "wlan" rename Date: Tue, 24 Oct 2017 17:11:31 +0200 Message-Id: <20171024151131.5852-1-johannes@sipsolutions.net> X-Mailer: git-send-email 2.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171024_081158_914965_0BEDC233 X-CRM114-Status: UNSURE ( 7.05 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: adiel.aloni@intel.com, Johannes Berg MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg Recent versions of tshark/wireshark renamed these fields, deal with that in the tshark wrapper code. Signed-off-by: Johannes Berg --- tests/hwsim/tshark.py | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tests/hwsim/tshark.py b/tests/hwsim/tshark.py index d2a8c45ca24f..2d4389c69974 100644 --- a/tests/hwsim/tshark.py +++ b/tests/hwsim/tshark.py @@ -12,10 +12,14 @@ import subprocess import logging logger = logging.getLogger() +class UnknownFieldsException(Exception): + def __init__(self, fields): + Exception.__init__(self, "unknown tshark fields %s" % ','.join(fields)) + self.fields = fields _tshark_filter_arg = '-Y' -def run_tshark(filename, filter, display=None, wait=True): +def _run_tshark(filename, filter, display=None, wait=True): global _tshark_filter_arg if wait: @@ -44,8 +48,21 @@ def run_tshark(filename, filter, display=None, wait=True): out = output[0] res = cmd.wait() if res == 1: - if "Some fields aren't valid" in output[1]: - raise Exception("Unknown tshark field") + errmsg = "Some fields aren't valid" + if errmsg in output[1]: + errors = output[1].split('\n') + fields = [] + collect = False + for f in errors: + if collect: + f = f.strip() + if f: + fields.append(f) + continue + if errmsg in f: + collect = True + continue + raise UnknownFieldsException(fields) # remember this for efficiency _tshark_filter_arg = '-R' arg[3] = '-R' @@ -55,3 +72,19 @@ def run_tshark(filename, filter, display=None, wait=True): cmd.wait() return out + +def run_tshark(filename, filter, display=None, wait=True): + if display is None: display = [] + try: + return _run_tshark(filename, filter, display, wait) + except UnknownFieldsException, e: + all_wlan_mgt = True + for f in e.fields: + if not f.startswith('wlan_mgt.'): + all_wlan_mgt = False + break + if not all_wlan_mgt: + raise + return _run_tshark(filename, filter.replace('wlan_mgt', 'wlan'), + [x.replace('wlan_mgt', 'wlan') for x in display], + wait)