Blame SOURCES/0001-tests-shell-runtime-set-element-automerge.patch

e34dd0
From 2a4f76ff5d5cc8d26a663ef8f8cd79c06560ca24 Mon Sep 17 00:00:00 2001
e34dd0
From: Phil Sutter <psutter@redhat.com>
e34dd0
Date: Fri, 24 Jun 2022 16:02:59 +0200
e34dd0
Subject: [PATCH] tests: shell: runtime set element automerge
e34dd0
e34dd0
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1917398
e34dd0
Upstream Status: nftables commit 8fafe4e6b5b30
e34dd0
e34dd0
commit 8fafe4e6b5b30f2539f16403da8d5c5f819e523b
e34dd0
Author: Pablo Neira Ayuso <pablo@netfilter.org>
e34dd0
Date:   Mon Jun 13 17:05:22 2022 +0200
e34dd0
e34dd0
    tests: shell: runtime set element automerge
e34dd0
e34dd0
    Add a test to cover runtime set element automerge.
e34dd0
e34dd0
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
e34dd0
e34dd0
Signed-off-by: Phil Sutter <psutter@redhat.com>
e34dd0
---
e34dd0
 tests/shell/testcases/sets/automerge_0 | 64 ++++++++++++++++++++++++++
e34dd0
 1 file changed, 64 insertions(+)
e34dd0
 create mode 100755 tests/shell/testcases/sets/automerge_0
e34dd0
e34dd0
diff --git a/tests/shell/testcases/sets/automerge_0 b/tests/shell/testcases/sets/automerge_0
e34dd0
new file mode 100755
e34dd0
index 0000000..c9fb609
e34dd0
--- /dev/null
e34dd0
+++ b/tests/shell/testcases/sets/automerge_0
e34dd0
@@ -0,0 +1,64 @@
e34dd0
+#!/bin/bash
e34dd0
+
e34dd0
+set -e
e34dd0
+
e34dd0
+RULESET="table inet x {
e34dd0
+	set y {
e34dd0
+		type inet_service
e34dd0
+		flags interval
e34dd0
+		auto-merge
e34dd0
+	}
e34dd0
+}"
e34dd0
+
e34dd0
+$NFT -f - <<< $RULESET
e34dd0
+
e34dd0
+tmpfile=$(mktemp)
e34dd0
+echo -n "add element inet x y { " > $tmpfile
e34dd0
+for ((i=0;i<65535;i+=2))
e34dd0
+do
e34dd0
+	echo -n "$i, " >> $tmpfile
e34dd0
+	if [ $i -eq 65534 ]
e34dd0
+	then
e34dd0
+		echo -n "$i" >> $tmpfile
e34dd0
+	fi
e34dd0
+done
e34dd0
+echo "}" >> $tmpfile
e34dd0
+
e34dd0
+$NFT -f $tmpfile
e34dd0
+
e34dd0
+tmpfile2=$(mktemp)
e34dd0
+for ((i=1;i<65535;i+=2))
e34dd0
+do
e34dd0
+	echo "$i" >> $tmpfile2
e34dd0
+done
e34dd0
+
e34dd0
+tmpfile3=$(mktemp)
e34dd0
+shuf $tmpfile2 > $tmpfile3
e34dd0
+i=0
e34dd0
+cat $tmpfile3 | while read line && [ $i -lt 10 ]
e34dd0
+do
e34dd0
+	$NFT add element inet x y { $line }
e34dd0
+	i=$((i+1))
e34dd0
+done
e34dd0
+
e34dd0
+for ((i=0;i<10;i++))
e34dd0
+do
e34dd0
+	from=$(($RANDOM%65535))
e34dd0
+	to=$(($from+100))
e34dd0
+	$NFT add element inet x y { $from-$to }
e34dd0
+	if [ $? -ne 0 ]
e34dd0
+	then
e34dd0
+		echo "failed to add $from-$to"
e34dd0
+		exit 1
e34dd0
+	fi
e34dd0
+	$NFT get element inet x y { $from-$to }
e34dd0
+	if [ $? -ne 0 ]
e34dd0
+	then
e34dd0
+		echo "failed to get $from-$to"
e34dd0
+		exit 1
e34dd0
+	fi
e34dd0
+done
e34dd0
+
e34dd0
+rm -f $tmpfile
e34dd0
+rm -f $tmpfile2
e34dd0
+rm -f $tmpfile3
e34dd0
-- 
e34dd0
2.36.1
e34dd0