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

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