From patchwork Sat May 5 12:56:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 909140 X-Patchwork-Delegate: pablo@netfilter.org 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40dTRK6bkLz9s2t for ; Sat, 5 May 2018 22:56:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751267AbeEEM4p (ORCPT ); Sat, 5 May 2018 08:56:45 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:52998 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750830AbeEEM4p (ORCPT ); Sat, 5 May 2018 08:56:45 -0400 Received: from localhost ([::1]:40042 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.90_1) (envelope-from ) id 1fEwk0-00085j-4H; Sat, 05 May 2018 14:56:44 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [nft PATCH v2 12/14] tests/py: Don't read expected payload for each table Date: Sat, 5 May 2018 14:56:04 +0200 Message-Id: <20180505125606.1909-13-phil@nwl.cc> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180505125606.1909-1-phil@nwl.cc> References: <20180505125606.1909-1-phil@nwl.cc> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org When testing rule adding to different table families, expected payload was read for each tested family again. Instead, read it just once and just try to read a family-specific payload for each tested family. Signed-off-by: Phil Sutter --- tests/py/nft-test.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py index ef9c6dbb769e5..5f00b7d658f55 100755 --- a/tests/py/nft-test.py +++ b/tests/py/nft-test.py @@ -647,23 +647,25 @@ def rule_add(rule, filename, lineno, force_all_family_option, filename_path): print_error(reason, filename, lineno) return [-1, warning, error, unit_tests] - payload_expected = [] - - for table in table_list: + if rule[1].strip() == "ok": try: - payload_log = open("%s.payload.%s" % (filename_path, table.family)) - except IOError: payload_log = open("%s.payload" % filename_path) + payload_expected = payload_find_expected(payload_log, rule[0]) + except: + payload_expected = None + for table in table_list: if rule[1].strip() == "ok": + table_payload_expected = None try: - payload_expected.index(rule[0]) - except ValueError: - payload_expected = payload_find_expected(payload_log, rule[0]) - + payload_log = open("%s.payload.%s" % (filename_path, table.family)) + table_payload_expected = payload_find_expected(payload_log, rule[0]) + except: if not payload_expected: print_error("did not find payload information for " "rule '%s'" % rule[0], payload_log.name, 1) + if not table_payload_expected: + table_payload_expected = payload_expected for table_chain in table.chains: chain = chain_get_by_name(table_chain) @@ -696,7 +698,7 @@ def rule_add(rule, filename, lineno, force_all_family_option, filename_path): continue # Check for matching payload - if state == "ok" and not payload_check(payload_expected, + if state == "ok" and not payload_check(table_payload_expected, payload_log, cmd): error += 1 gotf = open("%s.payload.got" % filename_path, 'a')