Linux Netfilter development
 help / color / mirror / Atom feed
* [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable
@ 2024-11-06 16:42 Phil Sutter
  2024-11-06 16:42 ` [iptables PATCH 2/5] tests: shell: Print escape sequences with terminals only Phil Sutter
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Phil Sutter @ 2024-11-06 16:42 UTC (permalink / raw)
  To: netfilter-devel

Sometimes the test would fail, especially after removing
/run/xtables.lock file. Looks like the supposedly blocking
iptables-restore coproc sometimes takes a moment to set things up.

Fixes: 63ab5b8906f69 ("iptables-legacy: Fix for mandatory lock waiting")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables/tests/shell/testcases/iptables/0010-wait_0 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iptables/tests/shell/testcases/iptables/0010-wait_0 b/iptables/tests/shell/testcases/iptables/0010-wait_0
index 4481f966ce435..37a7a58fc5dca 100755
--- a/iptables/tests/shell/testcases/iptables/0010-wait_0
+++ b/iptables/tests/shell/testcases/iptables/0010-wait_0
@@ -11,7 +11,7 @@ esac
 
 coproc RESTORE { $XT_MULTI iptables-restore; }
 echo "*filter" >&${RESTORE[1]}
-
+sleep 0.5
 
 $XT_MULTI iptables -A FORWARD -j ACCEPT &
 ipt_pid=$!
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [iptables PATCH 2/5] tests: shell: Print escape sequences with terminals only
  2024-11-06 16:42 [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter
@ 2024-11-06 16:42 ` Phil Sutter
  2024-11-06 16:42 ` [iptables PATCH 3/5] tests: iptables-test: Fix for 'make distcheck' Phil Sutter
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2024-11-06 16:42 UTC (permalink / raw)
  To: netfilter-devel

If stdout is not a terminal, don't print the '[EXECUTING]' status line
which has to be cleared again.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables/tests/shell/run-tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/iptables/tests/shell/run-tests.sh b/iptables/tests/shell/run-tests.sh
index 2ad259c21644c..565b654e9f134 100755
--- a/iptables/tests/shell/run-tests.sh
+++ b/iptables/tests/shell/run-tests.sh
@@ -165,7 +165,7 @@ do_test() {
 
 	rc_spec=`echo $(basename ${testfile}) | cut -d _ -f2-`
 
-	msg_info "[EXECUTING]   $testfile"
+	[ -t 1 ] && msg_info "[EXECUTING]   $testfile"
 
 	if [ "$VERBOSE" = "y" ]; then
 		XT_MULTI=$xtables_multi unshare -n ${testfile}
@@ -173,7 +173,7 @@ do_test() {
 	else
 		XT_MULTI=$xtables_multi unshare -n ${testfile} > /dev/null 2>&1
 		rc_got=$?
-		echo -en "\033[1A\033[K" # clean the [EXECUTING] foobar line
+		[ -t 1 ] && echo -en "\033[1A\033[K" # clean the [EXECUTING] foobar line
 	fi
 
 	if [ "$rc_got" == "$rc_spec" ] ; then
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [iptables PATCH 3/5] tests: iptables-test: Fix for 'make distcheck'
  2024-11-06 16:42 [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter
  2024-11-06 16:42 ` [iptables PATCH 2/5] tests: shell: Print escape sequences with terminals only Phil Sutter
@ 2024-11-06 16:42 ` Phil Sutter
  2024-11-06 16:42 ` [iptables PATCH 4/5] tests: xlate-test: " Phil Sutter
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2024-11-06 16:42 UTC (permalink / raw)
  To: netfilter-devel

This was a tricky one: Since called from VPATH topdir, extensions/ do
not contain test files at all. The script consequently passed since 0
tests failed (of 0 in total).

Fix this by introducing TESTS_PATH which is extensions/ below the directory
of the running iptables-test.py. Keep EXTENSIONS_PATH as-is: The built
extensions are indeed there and XTABLES_LIBDIR must point to them.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 iptables-test.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/iptables-test.py b/iptables-test.py
index 141fec7b4ed16..66db552185bc3 100755
--- a/iptables-test.py
+++ b/iptables-test.py
@@ -30,6 +30,7 @@ EBTABLES_SAVE = "ebtables-save"
 #IP6TABLES_SAVE = ['xtables-save','-6']
 
 EXTENSIONS_PATH = "extensions"
+TESTS_PATH = os.path.join(os.path.dirname(sys.argv[0]), "extensions")
 LOGFILE="/tmp/iptables-test.log"
 log_file = None
 
@@ -558,7 +559,7 @@ STDERR_IS_TTY = sys.stderr.isatty()
     '''
     Show the list of missing test files
     '''
-    file_list = os.listdir(EXTENSIONS_PATH)
+    file_list = os.listdir(TESTS_PATH)
     testfiles = [i for i in file_list if i.endswith('.t')]
     libfiles = [i for i in file_list
                 if i.startswith('lib') and i.endswith('.c')]
@@ -669,8 +670,8 @@ STDERR_IS_TTY = sys.stderr.isatty()
         if args.filename:
             file_list = args.filename
         else:
-            file_list = [os.path.join(EXTENSIONS_PATH, i)
-                         for i in os.listdir(EXTENSIONS_PATH)
+            file_list = [os.path.join(TESTS_PATH, i)
+                         for i in os.listdir(TESTS_PATH)
                          if i.endswith('.t')]
             file_list.sort()
 
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [iptables PATCH 4/5] tests: xlate-test: Fix for 'make distcheck'
  2024-11-06 16:42 [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter
  2024-11-06 16:42 ` [iptables PATCH 2/5] tests: shell: Print escape sequences with terminals only Phil Sutter
  2024-11-06 16:42 ` [iptables PATCH 3/5] tests: iptables-test: Fix for 'make distcheck' Phil Sutter
@ 2024-11-06 16:42 ` Phil Sutter
  2024-11-06 16:42 ` [iptables PATCH 5/5] Makefile.am: Revert to old serial test harness Phil Sutter
  2024-11-06 17:13 ` [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2024-11-06 16:42 UTC (permalink / raw)
  To: netfilter-devel

Similar problem as with the other suites: The build directory does not
contain test cases, only build results.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 xlate-test.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xlate-test.py b/xlate-test.py
index b6a78bb250e27..1c8cfe71ffd46 100755
--- a/xlate-test.py
+++ b/xlate-test.py
@@ -188,8 +188,10 @@ xtables_nft_multi = 'xtables-nft-multi'
 
 def load_test_files():
     test_files = total_tests = total_passed = total_error = total_failed = 0
-    tests = sorted(os.listdir("extensions"))
-    for test in ['extensions/' + f for f in tests if f.endswith(".txlate")]:
+    tests_path = os.path.join(os.path.dirname(sys.argv[0]), "extensions")
+    tests = sorted(os.listdir(tests_path))
+    for test in [os.path.join(tests_path, f)
+                 for f in tests if f.endswith(".txlate")]:
         with open(test, "r") as payload:
             tests, passed, failed, errors = run_test(test, payload)
             test_files += 1
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [iptables PATCH 5/5] Makefile.am: Revert to old serial test harness
  2024-11-06 16:42 [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter
                   ` (2 preceding siblings ...)
  2024-11-06 16:42 ` [iptables PATCH 4/5] tests: xlate-test: " Phil Sutter
@ 2024-11-06 16:42 ` Phil Sutter
  2024-11-06 17:13 ` [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2024-11-06 16:42 UTC (permalink / raw)
  To: netfilter-devel

Running the different testsuites in parallel is dangerous since despite
running in different netns, legacy iptables still synchronizes via the
common XTABLES_LOCKFILE.

Fixes: e1eaa04e31e44 ("Makefile.am: Integrate testsuites")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 299ab46d7b8e2..d0ba059c00110 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 # -*- Makefile -*-
 
 ACLOCAL_AMFLAGS  = -I m4
-AUTOMAKE_OPTIONS = foreign subdir-objects dist-xz no-dist-gzip
+AUTOMAKE_OPTIONS = foreign subdir-objects dist-xz no-dist-gzip serial-tests
 
 SUBDIRS          = libiptc libxtables
 if ENABLE_DEVEL
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable
  2024-11-06 16:42 [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter
                   ` (3 preceding siblings ...)
  2024-11-06 16:42 ` [iptables PATCH 5/5] Makefile.am: Revert to old serial test harness Phil Sutter
@ 2024-11-06 17:13 ` Phil Sutter
  4 siblings, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2024-11-06 17:13 UTC (permalink / raw)
  To: netfilter-devel

On Wed, Nov 06, 2024 at 05:42:28PM +0100, Phil Sutter wrote:
> Sometimes the test would fail, especially after removing
> /run/xtables.lock file. Looks like the supposedly blocking
> iptables-restore coproc sometimes takes a moment to set things up.
> 
> Fixes: 63ab5b8906f69 ("iptables-legacy: Fix for mandatory lock waiting")
> Signed-off-by: Phil Sutter <phil@nwl.cc>

Series applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-11-06 17:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-06 16:42 [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter
2024-11-06 16:42 ` [iptables PATCH 2/5] tests: shell: Print escape sequences with terminals only Phil Sutter
2024-11-06 16:42 ` [iptables PATCH 3/5] tests: iptables-test: Fix for 'make distcheck' Phil Sutter
2024-11-06 16:42 ` [iptables PATCH 4/5] tests: xlate-test: " Phil Sutter
2024-11-06 16:42 ` [iptables PATCH 5/5] Makefile.am: Revert to old serial test harness Phil Sutter
2024-11-06 17:13 ` [iptables PATCH 1/5] tests: shell: iptables/0010-wait_0 is unreliable Phil Sutter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox