netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 3/3] tests: add test cases for meta random
Date: Tue,  2 Feb 2016 00:19:01 +0100	[thread overview]
Message-ID: <1454368741-16368-4-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1454368741-16368-1-git-send-email-fw@strlen.de>

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 tests/py/any/meta.t         |  6 ++++++
 tests/py/any/meta.t.payload | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/tests/py/any/meta.t b/tests/py/any/meta.t
index c10297a..6298e5c 100644
--- a/tests/py/any/meta.t
+++ b/tests/py/any/meta.t
@@ -197,3 +197,9 @@ meta cgroup {1048577-1048578};ok;cgroup { 1048577-1048578}
 meta iif . meta oif { lo . eth0 };ok
 meta iif . meta oif . meta mark { lo . eth0 . 0x0000000a };ok
 meta iif . meta oif vmap { lo . eth0 : drop };ok
+
+meta random 0.999999999;ok;meta random <= 0.999999999
+meta random 0.5;ok;meta random <= 0.500000000
+meta random 0.001;ok;meta random <= 0.001000000
+meta random 0.000000001;ok;meta random <= 0.000000001
+meta random 0.0000000005;fail
diff --git a/tests/py/any/meta.t.payload b/tests/py/any/meta.t.payload
index 9f7a6d9..5ca13b0 100644
--- a/tests/py/any/meta.t.payload
+++ b/tests/py/any/meta.t.payload
@@ -754,3 +754,22 @@ ip test-ip4 output
   [ meta load oif => reg 9 ]
   [ lookup reg 1 set map%d dreg 0 ]
 
+# meta random 0.999999999
+ip test-ip4 input
+  [ meta load prandom => reg 1 ]
+  [ cmp lte reg 1 0xfbffffff ]
+
+# meta random 0.5
+ip test-ip4 input
+  [ meta load prandom => reg 1 ]
+  [ cmp lte reg 1 0x00000080 ]
+
+# meta random 0.001
+ip test-ip4 input
+  [ meta load prandom => reg 1 ]
+  [ cmp lte reg 1 0x37894100 ]
+
+# meta random 0.000000001
+ip test-ip4 input
+  [ meta load prandom => reg 1 ]
+  [ cmp lte reg 1 0x04000000 ]
-- 
2.4.10


  parent reply	other threads:[~2016-02-01 23:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 23:18 [PATCH nft 0/3] meta: random match for statistic sampling Florian Westphal
2016-02-01 23:18 ` [PATCH nft 1/3] evaluate: move default op lookup into helper Florian Westphal
2016-02-01 23:19 ` [PATCH nft 2/3] meta: add prandom matching Florian Westphal
2016-02-04 14:39   ` Patrick McHardy
2016-02-04 14:46     ` Florian Westphal
2016-02-04 15:27       ` Patrick McHardy
2016-02-04 15:32         ` Florian Westphal
2016-02-04 16:09           ` Florian Westphal
2016-02-04 16:42             ` Florian Westphal
2016-02-04 17:40               ` Patrick McHardy
2016-02-15 12:54                 ` Florian Westphal
2016-02-16 11:45                   ` Pablo Neira Ayuso
2016-02-16 12:00                     ` Florian Westphal
2016-02-16 16:28                       ` Pablo Neira Ayuso
2016-02-04 17:38             ` Patrick McHardy
2016-02-01 23:19 ` Florian Westphal [this message]
2016-02-03 20:23 ` [PATCH nft 0/3] meta: random match for statistic sampling Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454368741-16368-4-git-send-email-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).