From nobody Fri Jun 16 07:24:39 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Qj9f01Cfwz4fZTB; Fri, 16 Jun 2023 07:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Qj9f00fF8z4B6v; Fri, 16 Jun 2023 07:24:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686900280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+BRNk1KEfrsbrk7U07U+v/QKZI24GCd7R3ts3BHHhis=; b=TGq672T0+aojsXJqv8FLZoIJ0pWu5VAt6lDdbTUrUPgusn8mNRA8cbhsj1W79anxHqhmoN xIAihTK1Ni5Rj3YdN0dvSXsXQPN855WxV02/tyErlo3yP1sTB9KFKjpwkjlmWQZz6nXp3f XThJ22lx/jAETbtOvOd/s3x3xHvej5yXOA1R/bXte5V3v2IaiKW76/k1XtA6QBKL40h/Xs BmW1R+Fyqg92PaqflZl4m55GtWhkID48oEyD66AUsspRIYGM5ViL441mBJJU8lXLwLWXqJ kjpy+fTZEv3KS8lcbmpkgbrr350sSA1Y9WnV7+iSUVhTyDuor1BCf4AzieAPEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686900280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+BRNk1KEfrsbrk7U07U+v/QKZI24GCd7R3ts3BHHhis=; b=DghyBh3R+fdEYeFBZwViGroazRGpG9aMmQyKjvGNzrSfZhJVXh5qNSANjxRInZ0kXew+GB j9BIijle880O2xnePGLXZAaVPdeD6ZHYB+dWxRqOipJSXDzok34/35mI0I/2RdcX1/W+1P uBNpdWWBB+CyAvF0v+2kq2we4r/+2DsptsOFvLmY7OA0hnnP3+oBb+aA4hKFr4V2Vf5SSC j55e59peEE3hZ5F/xEvt7eENSk4M1uQno+/6p1QcUxbD+1aeUByvHiP7m5cKKiY3N9yO+i Dz7lqFAPpvz1vuT6OjsZXePiDnclGRvdg4H5YhU3To9LHg4wHzd2KMpx2xRniQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686900280; a=rsa-sha256; cv=none; b=uYgweTbqUdwgm2LM0GocWDEJh/DXwPmpUMJ70gsMZzGo6NEjZGZljpr4+IFul0m3qbizJE zoAUtVzAOeb19wGVdOrC+hhKDeV+8hcifdINmdTyccDAjwK2QhzeK6xXZkBu7zrOHhrKXo ne3agF7jIFlgVHleJWxCfWHX3s3z2fm2lA0S3MG9E2xOd4XUZfOaRek8glRVfvAvCxIZ4m 9F5a5Mq+mvzwETWp08gH2fadg8FqAes81Xlmccdl5m9W27P0ylzqjdOACg3baf3NIViWlh rrTtO6XGLt6Bst2fGfg5yxMByQdapcX2xLkCs0WElcrz7Zxkw8yK/QSVWjFbxg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Qj9dz6s9czKK5; Fri, 16 Jun 2023 07:24:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35G7Od10050748; Fri, 16 Jun 2023 07:24:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35G7Od7u050747; Fri, 16 Jun 2023 07:24:39 GMT (envelope-from git) Date: Fri, 16 Jun 2023 07:24:39 GMT Message-Id: <202306160724.35G7Od7u050747@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 7e1ec25c8b6d - main - ipfw: add state/comment tests List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7e1ec25c8b6d4090ab0c1fcac4f048015c216267 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=7e1ec25c8b6d4090ab0c1fcac4f048015c216267 commit 7e1ec25c8b6d4090ab0c1fcac4f048015c216267 Author: Alexander V. Chernikov AuthorDate: 2023-06-16 07:24:19 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-06-16 07:24:19 +0000 ipfw: add state/comment tests --- sbin/ipfw/tests/test_add_rule.py | 63 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/sbin/ipfw/tests/test_add_rule.py b/sbin/ipfw/tests/test_add_rule.py index 42c594a83bcf..60c8cebaceaa 100755 --- a/sbin/ipfw/tests/test_add_rule.py +++ b/sbin/ipfw/tests/test_add_rule.py @@ -57,7 +57,7 @@ def differ(w_obj, g_obj, w_stack=[], g_stack=[]): return True num_objects = 0 for i, w_child in enumerate(w_obj.obj_list): - if i > len(g_obj.obj_list): + if i >= len(g_obj.obj_list): print("MISSING object from chain {}".format(" / ".join(w_stack))) w_child.print_obj() print("==========================") @@ -206,6 +206,66 @@ class TestAddRule(BaseTest): }, id="test_eaction_ntp", ), + pytest.param( + { + "in": "add // test comment", + "out": { + "insns": [ + InsnComment(comment="test comment"), + Insn(IpFwOpcode.O_COUNT), + ], + }, + }, + id="test_action_comment", + ), + pytest.param( + { + "in": "add check-state :OUT // test comment", + "out": { + "objs": [ + NTlv(IpFwTlvType.IPFW_TLV_STATE_NAME, idx=1, name="OUT"), + ], + "insns": [ + InsnComment(comment="test comment"), + Insn(IpFwOpcode.O_CHECK_STATE, arg1=1), + ], + }, + }, + id="test_check_state", + ), + pytest.param( + { + "in": "add allow tcp from any to any keep-state :OUT", + "out": { + "objs": [ + NTlv(IpFwTlvType.IPFW_TLV_STATE_NAME, idx=1, name="OUT"), + ], + "insns": [ + Insn(IpFwOpcode.O_PROBE_STATE, arg1=1), + Insn(IpFwOpcode.O_PROTO, arg1=6), + Insn(IpFwOpcode.O_KEEP_STATE, arg1=1), + InsnEmpty(IpFwOpcode.O_ACCEPT), + ], + }, + }, + id="test_keep_state", + ), + pytest.param( + { + "in": "add allow tcp from any to any record-state", + "out": { + "objs": [ + NTlv(IpFwTlvType.IPFW_TLV_STATE_NAME, idx=1, name="default"), + ], + "insns": [ + Insn(IpFwOpcode.O_PROTO, arg1=6), + Insn(IpFwOpcode.O_KEEP_STATE, arg1=1), + InsnEmpty(IpFwOpcode.O_ACCEPT), + ], + }, + }, + id="test_record_state", + ), ], ) def test_add_rule(self, rule): @@ -329,7 +389,6 @@ class TestAddRule(BaseTest): ("call 420", Insn(IpFwOpcode.O_CALLRETURN, arg1=420)), id="call_420" ), # TOK_FORWARD - # TOK_COMMENT pytest.param( ("setfib 1", Insn(IpFwOpcode.O_SETFIB, arg1=1 | 0x8000)), id="setfib_1",