From patchwork Fri Oct 7 03:30:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 679133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3sqw6372jbz9ryn for ; Fri, 7 Oct 2016 14:31:07 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id D008A1097A; Thu, 6 Oct 2016 20:30:52 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 48BDD10975 for ; Thu, 6 Oct 2016 20:30:51 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 9A496162AE1 for ; Thu, 6 Oct 2016 21:30:50 -0600 (MDT) X-ASG-Debug-ID: 1475811049-0b32377597ae210001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar6.cudamail.com with ESMTP id h0wIpYM1zr2RyNQq (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 06 Oct 2016 21:30:49 -0600 (MDT) X-Barracuda-Envelope-From: blp@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO relay5-d.mail.gandi.net) (217.70.183.197) by mx3-pf3.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 7 Oct 2016 03:30:49 -0000 Received-SPF: pass (mx3-pf3.cudamail.com: SPF record at ovn.org designates 217.70.183.197 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.197 X-Barracuda-RBL-IP: 217.70.183.197 Received: from mfilter41-d.gandi.net (mfilter41-d.gandi.net [217.70.178.173]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id BA93641C095; Fri, 7 Oct 2016 05:30:47 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter41-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter41-d.gandi.net (mfilter41-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id y6j0uPYsmasz; Fri, 7 Oct 2016 05:30:46 +0200 (CEST) X-Originating-IP: 173.228.112.90 Received: from sigabrt.gateway.sonic.net (173-228-112-90.dsl.dynamic.fusionbroadband.com [173.228.112.90]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 6079341C08E; Fri, 7 Oct 2016 05:30:45 +0200 (CEST) X-CudaMail-Envelope-Sender: blp@ovn.org From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1005063445 X-CudaMail-DTE: 100616 X-CudaMail-Originating-IP: 217.70.183.197 Date: Thu, 6 Oct 2016 20:30:38 -0700 X-ASG-Orig-Subj: [##CM-V3-1005063445##][PATCH 3/4] expr: Improve test so that it would have found the bugs I just fixed. Message-Id: <1475811039-31662-3-git-send-email-blp@ovn.org> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1475811039-31662-1-git-send-email-blp@ovn.org> References: <1475811039-31662-1-git-send-email-blp@ovn.org> X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1475811049 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 3/4] expr: Improve test so that it would have found the bugs I just fixed. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" The test didn't check for x == 0/0 or x != 0/0 cases, and thus they were buggy. Also, add "expression" as a keyword for tests that only had "expressions" (plural). Signed-off-by: Ben Pfaff Acked-by: Andy Zhou --- tests/ovn.at | 28 +++++++++++++++++----------- tests/test-ovn.c | 10 ++++------ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tests/ovn.at b/tests/ovn.at index 47153a4..be85004 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -397,19 +397,19 @@ AT_CLEANUP AT_SETUP([ovn -- 2-term expression conversion]) AT_CHECK([ovstest test-ovn exhaustive --operation=convert 2], [0], - [Tested converting 570 expressions of 2 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars. + [Tested converting 578 expressions of 2 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 2 string vars. ]) AT_CLEANUP AT_SETUP([ovn -- 3-term expression conversion]) AT_CHECK([ovstest test-ovn exhaustive --operation=convert --bits=2 3], [0], - [Tested converting 62418 expressions of 3 terminals with 2 numeric vars (each 2 bits) in terms of operators == != < <= > >= and 2 string vars. + [Tested converting 67410 expressions of 3 terminals with 2 numeric vars (each 2 bits) in terms of operators == != < <= > >= and 2 string vars. ]) AT_CLEANUP AT_SETUP([ovn -- 3-term numeric expression simplification]) AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=2 --svars=0 3], [0], - [Tested simplifying 477138 expressions of 3 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >=. + [Tested simplifying 490770 expressions of 3 terminals with 2 numeric vars (each 3 bits) in terms of operators == != < <= > >=. ]) AT_CLEANUP @@ -421,7 +421,7 @@ AT_CLEANUP AT_SETUP([ovn -- 3-term mixed expression simplification]) AT_CHECK([ovstest test-ovn exhaustive --operation=simplify --nvars=1 --svars=1 3], [0], - [Tested simplifying 124410 expressions of 3 terminals with 1 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 1 string vars. + [Tested simplifying 127890 expressions of 3 terminals with 1 numeric vars (each 3 bits) in terms of operators == != < <= > >= and 1 string vars. ]) AT_CLEANUP @@ -437,7 +437,7 @@ AT_CLEANUP AT_SETUP([ovn -- 4-term numeric expression normalization]) AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 4], [0], - [Tested normalizing 1207162 expressions of 4 terminals with 3 numeric vars (each 1 bits) in terms of operators == != < <= > >=. + [Tested normalizing 1874026 expressions of 4 terminals with 3 numeric vars (each 1 bits) in terms of operators == != < <= > >=. ]) AT_CLEANUP @@ -449,13 +449,13 @@ AT_CLEANUP AT_SETUP([ovn -- 4-term mixed expression normalization]) AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --bits=1 --svars=2 4], [0], - [Tested normalizing 128282 expressions of 4 terminals with 1 numeric vars (each 1 bits) in terms of operators == != < <= > >= and 2 string vars. + [Tested normalizing 175978 expressions of 4 terminals with 1 numeric vars (each 1 bits) in terms of operators == != < <= > >= and 2 string vars. ]) AT_CLEANUP AT_SETUP([ovn -- 5-term numeric expression normalization]) AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=3 --svars=0 --bits=1 --relops='==' 5], [0], - [Tested normalizing 368550 expressions of 5 terminals with 3 numeric vars (each 1 bits) in terms of operators ==. + [Tested normalizing 1317600 expressions of 5 terminals with 3 numeric vars (each 1 bits) in terms of operators ==. ]) AT_CLEANUP @@ -467,35 +467,40 @@ AT_CLEANUP AT_SETUP([ovn -- 5-term mixed expression normalization]) AT_CHECK([ovstest test-ovn exhaustive --operation=normalize --nvars=1 --svars=1 --bits=1 --relops='==' 5], [0], - [Tested normalizing 116550 expressions of 5 terminals with 1 numeric vars (each 1 bits) in terms of operators == and 1 string vars. + [Tested normalizing 216000 expressions of 5 terminals with 1 numeric vars (each 1 bits) in terms of operators == and 1 string vars. ]) AT_CLEANUP AT_SETUP([ovn -- 4-term numeric expressions to flows]) +AT_KEYWORDS([expression]) AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=2 --svars=0 --bits=2 --relops='==' 4], [0], - [Tested converting to flows 128282 expressions of 4 terminals with 2 numeric vars (each 2 bits) in terms of operators ==. + [Tested converting to flows 175978 expressions of 4 terminals with 2 numeric vars (each 2 bits) in terms of operators ==. ]) AT_CLEANUP AT_SETUP([ovn -- 4-term string expressions to flows]) +AT_KEYWORDS([expression]) AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=0 --svars=4 4], [0], [Tested converting to flows 21978 expressions of 4 terminals with 4 string vars. ]) AT_CLEANUP AT_SETUP([ovn -- 4-term mixed expressions to flows]) +AT_KEYWORDS([expression]) AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=1 --bits=2 --svars=1 --relops='==' 4], [0], - [Tested converting to flows 37994 expressions of 4 terminals with 1 numeric vars (each 2 bits) in terms of operators == and 1 string vars. + [Tested converting to flows 48312 expressions of 4 terminals with 1 numeric vars (each 2 bits) in terms of operators == and 1 string vars. ]) AT_CLEANUP AT_SETUP([ovn -- 3-term numeric expressions to flows]) +AT_KEYWORDS([expression]) AT_CHECK([ovstest test-ovn exhaustive --operation=flow --nvars=3 --svars=0 --bits=3 --relops='==' 3], [0], - [Tested converting to flows 38394 expressions of 3 terminals with 3 numeric vars (each 3 bits) in terms of operators ==. + [Tested converting to flows 41328 expressions of 3 terminals with 3 numeric vars (each 3 bits) in terms of operators ==. ]) AT_CLEANUP AT_SETUP([ovn -- converting expressions to flows -- string fields]) +AT_KEYWORDS([expression]) expr_to_flow () { echo "$1" | ovstest test-ovn expr-to-flows | sort } @@ -532,6 +537,7 @@ AT_CHECK([expr_to_flow 'inport == "eth0" && inport == "eth1"'], [0], [dnl AT_CLEANUP AT_SETUP([ovn -- converting expressions to flows -- address sets]) +AT_KEYWORDS([expression]) expr_to_flow () { echo "$1" | ovstest test-ovn expr-to-flows | sort } diff --git a/tests/test-ovn.c b/tests/test-ovn.c index 67543b1..637ac7d 100644 --- a/tests/test-ovn.c +++ b/tests/test-ovn.c @@ -626,7 +626,7 @@ init_terminal(struct expr *expr, int phase, memset(&expr->cmp.value, 0, sizeof expr->cmp.value); memset(&expr->cmp.mask, 0, sizeof expr->cmp.mask); expr->cmp.value.integer = htonll(0); - expr->cmp.mask.integer = htonll(1); + expr->cmp.mask.integer = htonll(0); return; } @@ -721,15 +721,13 @@ next_terminal(struct expr *expr, return true; } } - next = 0; - } else if (m == 0) { - /* Skip: empty mask is pathological. */ + next = UINT_MAX; } else if (v & ~m) { /* Skip: 1-bits in value correspond to 0-bits in mask. */ - } else if (turn_off_rightmost_1s(m) + } else if ((!m || turn_off_rightmost_1s(m)) && (expr->cmp.relop != EXPR_R_EQ && expr->cmp.relop != EXPR_R_NE)) { - /* Skip: can't have discontiguous mask for > >= < <=. */ + /* Skip: can't have discontiguous or all-0 mask for > >= < <=. */ } else { expr->cmp.value.integer = htonll(v); expr->cmp.mask.integer = htonll(m);