diff mbox series

[v2,7/7] nftables: tests/py: More tests for day and hour

Message ID 20190626204402.5257-7-a@juaristi.eus
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series [v2,1/7] nftables: meta: Introduce new conditions 'time', 'day' and 'hour' | expand

Commit Message

Ander Juaristi June 26, 2019, 8:44 p.m. UTC
I still have some problems to test the 'time' key.

It always prints one hour earlier than the introduced time,
even though it works perfectly when I introduce the same rules manually,
and there is code that specifically checks for that issue by checking TZ to UTC
and substracting the GMT offset accordingly. Maybe there is some issue with
env variables or localtime() in the Python test environment?

Need to investigate further.

Signed-off-by: Ander Juaristi <a@juaristi.eus>
---
 tests/py/ip/meta.t         |  2 ++
 tests/py/ip/meta.t.payload | 12 ++++++++++++
 2 files changed, 14 insertions(+)

Comments

Florian Westphal June 26, 2019, 9:12 p.m. UTC | #1
Ander Juaristi <a@juaristi.eus> wrote:
> I still have some problems to test the 'time' key.
> 
> It always prints one hour earlier than the introduced time,
> even though it works perfectly when I introduce the same rules manually,
> and there is code that specifically checks for that issue by checking TZ to UTC
> and substracting the GMT offset accordingly. Maybe there is some issue with
> env variables or localtime() in the Python test environment?
> 
> Need to investigate further.

If you're stuck let me know and I can take a look at this too.
diff mbox series

Patch

diff --git a/tests/py/ip/meta.t b/tests/py/ip/meta.t
index 02ba11d..dbcff48 100644
--- a/tests/py/ip/meta.t
+++ b/tests/py/ip/meta.t
@@ -5,6 +5,8 @@ 
 icmp type echo-request;ok
 meta day "Saturday" drop;ok;meta day "Saturday" drop
 meta hour "17:00" drop;ok;meta hour "17:00" drop
+meta hour "00:00" drop;ok
+meta hour "00:01" drop;ok
 meta l4proto icmp icmp type echo-request;ok;icmp type echo-request
 meta l4proto ipv6-icmp icmpv6 type nd-router-advert;ok;icmpv6 type nd-router-advert
 meta l4proto 58 icmpv6 type nd-router-advert;ok;icmpv6 type nd-router-advert
diff --git a/tests/py/ip/meta.t.payload b/tests/py/ip/meta.t.payload
index ad00a1a..be162cf 100644
--- a/tests/py/ip/meta.t.payload
+++ b/tests/py/ip/meta.t.payload
@@ -10,6 +10,18 @@  ip test-ip4 input
   [ cmp eq reg 1 0x0000d2f0 0x00000000 ]
   [ immediate reg 0 drop ]
 
+# meta hour "00:00" drop
+ip meta-test input
+  [ meta load unknown => reg 1 ]
+  [ cmp eq reg 1 0x00013560 0x00000000 ]
+  [ immediate reg 0 drop ]
+
+# meta hour "00:01" drop
+ip meta-test input
+  [ meta load unknown => reg 1 ]
+  [ cmp eq reg 1 0x0001359c 0x00000000 ]
+  [ immediate reg 0 drop ]
+
 # icmp type echo-request
 ip test-ip4 input
   [ meta load l4proto => reg 1 ]