From patchwork Tue Jun 5 14:30:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Fabian X-Patchwork-Id: 925508 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=bosson.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bosson.cz header.i=@bosson.cz header.b="YvJKfgB0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 410ZD52K5cz9s08 for ; Wed, 6 Jun 2018 00:38:13 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752005AbeFEOiJ (ORCPT ); Tue, 5 Jun 2018 10:38:09 -0400 Received: from mailalternative.uvtmail.cz ([109.205.75.52]:47028 "EHLO mail.hosting.cldn.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752489AbeFEOiF (ORCPT ); Tue, 5 Jun 2018 10:38:05 -0400 Received: from linux.local (linux.uvt.cz [178.17.1.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: fabian@bosson.cz) by mail.hosting.cldn.cz (Postfix) with ESMTPSA id 0711E27DCB for ; Tue, 5 Jun 2018 16:31:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bosson.cz; s=mail; t=1528209086; bh=DNknIzzdlgY2Vt6EPtvCFy+HMbbXPl8VlRgE/gak9oE=; h=From:To:Subject:Date:In-Reply-To:References; b=YvJKfgB0DAVfE1HqLLk1VPPaxCFok+zNdRWfFGYxIS6icEs43M6GuANJsoLvn13SF 2YUTElJWbHr8pISqxrgFh+cp9cJC2C/WFksEgV9EOuKAdxalC/SEJ2kBTBG075xMHV DqT36z0cVjb0kZYv4x6Xk0p6MzkukMT/AeBxTAKt/ruDmsWxO/89z14yoUfQ5rEEbu Im48rcfJJ2eX3racdMavQKU8zpT67osamiXxrb0K/pcGEEDNi5m/dsafeaqaKbumfK jvniSuuAXy4R3z09z0orIMa6p2A6sC2USPCprISAc4aYo1CPltjx6Mmr5cIQhRuPW0 QkRhghJSlp4dQ== From: David Fabian To: netfilter-devel@vger.kernel.org Subject: [PATCH v2 4/4] Added tests for nested file-based scopes Date: Tue, 5 Jun 2018 16:30:51 +0200 Message-Id: <20180605143051.19274-5-david.fabian@bosson.cz> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180605143051.19274-1-david.fabian@bosson.cz> References: <20180605143051.19274-1-david.fabian@bosson.cz> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org --- tests/shell/testcases/include/0016sibling_scopes_0 | 33 ++++++++++++++++++ .../shell/testcases/include/0017scope_hierarchy_0 | 39 ++++++++++++++++++++++ tests/shell/testcases/include/0018global_define_0 | 38 +++++++++++++++++++++ tests/shell/testcases/include/0019global_define_1 | 20 +++++++++++ .../include/dumps/0016sibling_scopes_0.nft | 0 .../include/dumps/0017scope_hierarchy_0.nft | 0 .../include/dumps/0018global_define_0.nft | 0 7 files changed, 130 insertions(+) create mode 100755 tests/shell/testcases/include/0016sibling_scopes_0 create mode 100755 tests/shell/testcases/include/0017scope_hierarchy_0 create mode 100755 tests/shell/testcases/include/0018global_define_0 create mode 100755 tests/shell/testcases/include/0019global_define_1 create mode 100644 tests/shell/testcases/include/dumps/0016sibling_scopes_0.nft create mode 100644 tests/shell/testcases/include/dumps/0017scope_hierarchy_0.nft create mode 100644 tests/shell/testcases/include/dumps/0018global_define_0.nft diff --git a/tests/shell/testcases/include/dumps/0016sibling_scopes_0.nft b/tests/shell/testcases/include/dumps/0016sibling_scopes_0.nft new file mode 100644 index 0000000..e69de29 diff --git a/tests/shell/testcases/include/dumps/0017scope_hierarchy_0.nft b/tests/shell/testcases/include/dumps/0017scope_hierarchy_0.nft new file mode 100644 index 0000000..e69de29 diff --git a/tests/shell/testcases/include/dumps/0018global_define_0.nft b/tests/shell/testcases/include/dumps/0018global_define_0.nft new file mode 100644 index 0000000..e69de29 diff --git a/tests/shell/testcases/include/0016sibling_scopes_0 b/tests/shell/testcases/include/0016sibling_scopes_0 new file mode 100755 index 0000000..c8b4d7f --- /dev/null +++ b/tests/shell/testcases/include/0016sibling_scopes_0 @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +tmpdir=$(mktemp -d) +if [ ! -d $tmpdir ] ; then + echo "Failed to create tmp directory" >&2 + exit 0 +fi + +# cleanup if aborted +trap "rm -rf $tmpdir" EXIT + +cat > $tmpdir/top.nft << EOF +include "$tmpdir/a.nft" +include "$tmpdir/b.nft" + +EOF + +cat > $tmpdir/a.nft << EOF +define AAA = "testa" +EOF + +cat > $tmpdir/b.nft << EOF +define AAA = "testb" +EOF + +$NFT -f $tmpdir/top.nft + +if [ $? -ne 0 ] ; then + echo "E: unable to load good ruleset" >&2 + exit 1 +fi \ No newline at end of file diff --git a/tests/shell/testcases/include/0017scope_hierarchy_0 b/tests/shell/testcases/include/0017scope_hierarchy_0 new file mode 100755 index 0000000..ba99a58 --- /dev/null +++ b/tests/shell/testcases/include/0017scope_hierarchy_0 @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e + +tmpdir=$(mktemp -d) +if [ ! -d $tmpdir ] ; then + echo "Failed to create tmp directory" >&2 + exit 0 +fi + +# cleanup if aborted +trap "rm -rf $tmpdir" EXIT + +cat > $tmpdir/top.nft << EOF +define TOP = "top" +include "$tmpdir/a.nft" +EOF + +cat > $tmpdir/a.nft << EOF +define AAA = "testa" +include "$tmpdir/sub/*.nft" +EOF + +mkdir $tmpdir/sub &> /dev/null + +cat > $tmpdir/sub/b.nft << EOF +define FOO = { \$TOP, abc } +EOF + +cat > $tmpdir/sub/c.nft << EOF +define BAR = { \$AAA, cdef } +EOF + +$NFT -f $tmpdir/top.nft + +if [ $? -ne 0 ] ; then + echo "E: unable to load good ruleset" >&2 + exit 1 +fi \ No newline at end of file diff --git a/tests/shell/testcases/include/0018global_define_0 b/tests/shell/testcases/include/0018global_define_0 new file mode 100755 index 0000000..4288862 --- /dev/null +++ b/tests/shell/testcases/include/0018global_define_0 @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e + +tmpdir=$(mktemp -d) +if [ ! -d $tmpdir ] ; then + echo "Failed to create tmp directory" >&2 + exit 0 +fi + +# cleanup if aborted +trap "rm -rf $tmpdir" EXIT + +cat > $tmpdir/top.nft << EOF +define TOP = "top" +include "$tmpdir/a.nft" +define CCC = \$BBB +global undefine BBB +EOF + +cat > $tmpdir/a.nft << EOF +define AAA = "testa" +include "$tmpdir/sub/b.nft" +EOF + +mkdir $tmpdir/sub &> /dev/null + +cat > $tmpdir/sub/b.nft << EOF +global define BBB = "global" +global redefine BBB = "global2" +EOF + +$NFT -f $tmpdir/top.nft + +if [ $? -ne 0 ] ; then + echo "E: unable to load good ruleset" >&2 + exit 1 +fi diff --git a/tests/shell/testcases/include/0019global_define_1 b/tests/shell/testcases/include/0019global_define_1 new file mode 100755 index 0000000..11d9dd2 --- /dev/null +++ b/tests/shell/testcases/include/0019global_define_1 @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e + +tmpdir=$(mktemp -d) +if [ ! -d $tmpdir ] ; then + echo "Failed to create tmp directory" >&2 + exit 0 +fi + +# cleanup if aborted +trap "rm -rf $tmpdir" EXIT + +cat > $tmpdir/top.nft << EOF +define TOP = "top" +global define FAIL = \$TOP +EOF + +$NFT -f $tmpdir/top.nft 2> /dev/null +echo "E: local variable in global define"