From patchwork Tue Dec 1 22:45:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pablo M. Bermudo Garay" X-Patchwork-Id: 551050 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7430F1401DE for ; Wed, 2 Dec 2015 09:46:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=gvy5Q9kL; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757186AbbLAWqM (ORCPT ); Tue, 1 Dec 2015 17:46:12 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:33616 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756454AbbLAWqL (ORCPT ); Tue, 1 Dec 2015 17:46:11 -0500 Received: by wmec201 with SMTP id c201so227976091wme.0 for ; Tue, 01 Dec 2015 14:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j1UBXu+kpUVDapy0dUFXypXUCcXZ7b0WANLdH2RpTOI=; b=gvy5Q9kLIT3fklutCGrokHoyOacZRga06pxDD5oJN81ZRfSaiO6CW2xmBYImLguxlf S9oPHCmZ9tYMUWe5fPkLU0WeaPGzq+FZ7QImsoDr5/EyttTB9GfEmXPg5N7+52wgx4IQ SFtb0U/6dls0XlBcLqWw8xx7siSsW5Dm00gKO3xqhWTsOfmPAEO/K0l1QKHHVD9O/Fp7 o6X0IkFc6XYTzH7TTIHp+mpYNNlr5a0/aHNFRrU8SMnTDrKPcc4zYTMUJGi7iz6xTvLQ mmCtM6ZUmxwxdgddfd3KrWwXtTzwPmGo+LAmqHEJRspapsj2myr2NJb4rV0fkUq73TZB sDOg== X-Received: by 10.194.24.38 with SMTP id r6mr22977343wjf.32.1449009969824; Tue, 01 Dec 2015 14:46:09 -0800 (PST) Received: from hk-2.localdomain (85.136.142.133.dyn.user.ono.com. [85.136.142.133]) by smtp.gmail.com with ESMTPSA id u134sm28172933wmd.0.2015.12.01.14.46.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Dec 2015 14:46:08 -0800 (PST) From: "Pablo M. Bermudo Garay" To: netfilter-devel@vger.kernel.org Cc: "Pablo M. Bermudo Garay" Subject: [PATCH nft 3/3] tests: fix crash when rule test is malformed Date: Tue, 1 Dec 2015 23:45:23 +0100 Message-Id: <1449009923-10726-3-git-send-email-pablombg@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1449009923-10726-1-git-send-email-pablombg@gmail.com> References: <1449009923-10726-1-git-send-email-pablombg@gmail.com> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org The tests script suffers a crash when a rule test line is malformed (e.g. if expected result is missing). This commit fixes these crashes and now the line is skipped and a warning is printed. Signed-off-by: Pablo M. Bermudo Garay --- tests/regression/nft-test.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/regression/nft-test.py b/tests/regression/nft-test.py index 9d623b7..e68087f 100755 --- a/tests/regression/nft-test.py +++ b/tests/regression/nft-test.py @@ -508,12 +508,6 @@ def rule_add(rule, table_list, chain_list, filename, lineno, print_error("did not find payload information for rule '%s'" % rule[0], payload_log.name, 1) for chain in chain_list: - if len(rule) == 1: - reason = "Skipping malformed test. (" + \ - str(rule[0].rstrip('\n')) + ")" - print_warning(reason, filename, lineno) - continue - unit_tests += 1 table_flush(table, filename, lineno) table_info = " " + table[0] + " " + table[1] + " " @@ -808,6 +802,11 @@ def run_test_file(filename, force_all_family_option, specific_file): # Rule rule = line.split(';') # rule[1] Ok or FAIL + if len(rule) == 1 or len(rule) > 3 or rule[1].rstrip() not in {"ok", "fail"}: + reason = "Skipping malformed rule test. (" + line.rstrip('\n') + ")" + print_warning(reason, filename, lineno) + continue + if line[0] == "-": # Run omitted lines if need_fix_option: rule[0] = rule[0].rstrip()[1:].strip()