public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH v4 00/12] Improve handling of test temporary files
@ 2022-09-09  3:30 David Gibson
  2022-09-09  3:30 ` [PATCH v4 01/12] test: Group tests by context then protocol, rather than the reverse David Gibson
                   ` (11 more replies)
  0 siblings, 12 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 3873 bytes --]

Sigh.  Even more silly errors

The tests create temporary files and fifos in a number of places.
Some of them can interfere with later test runs, and are awkward to
clean up.  Consolidate them in a single per-run directory in /tmp
which gets cleaned up automatically.

This is based on the earlier userns cleanup series.

Changes since v3:
 * Fixed problem with ssh hosts file naming which caused a bunch of
   non-fatal warnings
Changes since v2:
 * Reinstated patch to move the log pipe accidentally dropped during
   a rebase
Chances since v1:
 * Fixed a number of straightforward bugs where things were missed
 * Also removed files we're no longer putting into the source tree
   from .gitignore
 * Added an extra patch moving the video processing files

David Gibson (12):
  test: Group tests by context then protocol, rather than the reverse
  test: Remove unused variable FFMPEG_PID_FILE
  test: Actually run cleanup function
  test: Create common state directories for temporary files
  test: Move passt_test_log_pipe to state directory
  test: Move context temporary files to state dir
  test: Dont regnerate small test file in pasta/tcp
  test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir'
    directives
  test: Move pause temporary file to state directory
  test: Store pcap files in $LOGDIR instead of /tmp
  test: Move pidfiles and nsholder sockets into state directory
  test: Move video processing files to $STATEBASE

 .gitignore                                    |  1 -
 test/.gitignore                               |  3 -
 test/build/all                                | 31 ++++---
 test/demo/passt                               |  9 +-
 test/demo/pasta                               | 12 ++-
 test/demo/podman                              | 11 ++-
 test/distro/debian                            |  2 +-
 test/distro/fedora                            |  2 +-
 test/distro/opensuse                          | 16 ++--
 test/distro/ubuntu                            |  8 +-
 test/lib/context                              | 61 +++++++-------
 test/lib/layout                               | 16 ++--
 test/lib/setup                                | 84 ++++++++++---------
 test/lib/term                                 | 26 +++---
 test/lib/test                                 | 14 +---
 test/lib/video                                | 20 ++---
 test/{dhcp/passt => passt/dhcp}               |  2 +-
 test/{ndp/passt => passt/ndp}                 |  2 +-
 test/{shutdown/passt => passt/shutdown}       |  4 +-
 test/{tcp/passt => passt/tcp}                 |  6 +-
 test/{udp/passt => passt/udp}                 |  8 +-
 test/{icmp/passt_in_ns => passt_in_ns/icmp}   |  2 +-
 .../passt_in_ns => passt_in_ns/shutdown}      |  4 +-
 test/{tcp/passt_in_ns => passt_in_ns/tcp}     | 10 +--
 test/{udp/passt_in_ns => passt_in_ns/udp}     |  8 +-
 test/{dhcp/pasta => pasta/dhcp}               |  2 +-
 test/{ndp/pasta => pasta/ndp}                 |  2 +-
 test/{tcp/pasta => pasta/tcp}                 | 13 ++-
 test/{udp/pasta => pasta/udp}                 | 20 ++---
 test/run                                      | 48 +++++------
 30 files changed, 217 insertions(+), 230 deletions(-)
 rename test/{dhcp/passt => passt/dhcp} (98%)
 rename test/{ndp/passt => passt/ndp} (95%)
 rename test/{shutdown/passt => passt/shutdown} (80%)
 rename test/{tcp/passt => passt/tcp} (96%)
 rename test/{udp/passt => passt/udp} (88%)
 rename test/{icmp/passt_in_ns => passt_in_ns/icmp} (94%)
 rename test/{shutdown/passt_in_ns => passt_in_ns/shutdown} (79%)
 rename test/{tcp/passt_in_ns => passt_in_ns/tcp} (97%)
 rename test/{udp/passt_in_ns => passt_in_ns/udp} (97%)
 rename test/{dhcp/pasta => pasta/dhcp} (96%)
 rename test/{ndp/pasta => pasta/ndp} (95%)
 rename test/{tcp/pasta => pasta/tcp} (95%)
 rename test/{udp/pasta => pasta/udp} (74%)

-- 
2.37.3


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

* [PATCH v4 01/12] test: Group tests by context then protocol, rather than the reverse
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 02/12] test: Remove unused variable FFMPEG_PID_FILE David Gibson
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 10144 bytes --]

e.g. passt/dhcp rather than dhcp/passt.  This is more consistent with the
two_guests and other test groups, and makes some other cleanups simpler.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/{dhcp/passt => passt/dhcp}               |  2 +-
 test/{ndp/passt => passt/ndp}                 |  2 +-
 test/{shutdown/passt => passt/shutdown}       |  2 +-
 test/{tcp/passt => passt/tcp}                 |  2 +-
 test/{udp/passt => passt/udp}                 |  2 +-
 test/{icmp/passt_in_ns => passt_in_ns/icmp}   |  2 +-
 .../passt_in_ns => passt_in_ns/shutdown}      |  2 +-
 test/{tcp/passt_in_ns => passt_in_ns/tcp}     |  2 +-
 test/{udp/passt_in_ns => passt_in_ns/udp}     |  2 +-
 test/{dhcp/pasta => pasta/dhcp}               |  2 +-
 test/{ndp/pasta => pasta/ndp}                 |  2 +-
 test/{tcp/pasta => pasta/tcp}                 |  2 +-
 test/{udp/pasta => pasta/udp}                 |  2 +-
 test/run                                      | 38 +++++++++----------
 14 files changed, 32 insertions(+), 32 deletions(-)
 rename test/{dhcp/passt => passt/dhcp} (98%)
 rename test/{ndp/passt => passt/ndp} (95%)
 rename test/{shutdown/passt => passt/shutdown} (87%)
 rename test/{tcp/passt => passt/tcp} (98%)
 rename test/{udp/passt => passt/udp} (97%)
 rename test/{icmp/passt_in_ns => passt_in_ns/icmp} (94%)
 rename test/{shutdown/passt_in_ns => passt_in_ns/shutdown} (87%)
 rename test/{tcp/passt_in_ns => passt_in_ns/tcp} (99%)
 rename test/{udp/passt_in_ns => passt_in_ns/udp} (98%)
 rename test/{dhcp/pasta => pasta/dhcp} (96%)
 rename test/{ndp/pasta => pasta/ndp} (95%)
 rename test/{tcp/pasta => pasta/tcp} (98%)
 rename test/{udp/pasta => pasta/udp} (98%)

diff --git a/test/dhcp/passt b/test/passt/dhcp
similarity index 98%
rename from test/dhcp/passt
rename to test/passt/dhcp
index 37bf6b5..eef5183 100644
--- a/test/dhcp/passt
+++ b/test/passt/dhcp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/dhcp/passt - Check DHCP and DHCPv6 functionality in passt mode
+# test/passt/dhcp - Check DHCP and DHCPv6 functionality in passt mode
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/ndp/passt b/test/passt/ndp
similarity index 95%
rename from test/ndp/passt
rename to test/passt/ndp
index c73fd4d..280b3ae 100644
--- a/test/ndp/passt
+++ b/test/passt/ndp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/ndp/passt - Check NDP functionality in passt mode
+# test/passt/ndp - Check NDP functionality in passt mode
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/shutdown/passt b/test/passt/shutdown
similarity index 87%
rename from test/shutdown/passt
rename to test/passt/shutdown
index ac8ff08..ce90ea9 100644
--- a/test/shutdown/passt
+++ b/test/passt/shutdown
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/shutdown/passt - Shut down passt (or pasta) and check exit code (will
+# test/passt/shutdown - Shut down passt (or pasta) and check exit code (will
 #                       detect valgrind errors amongst others)
 #
 # Copyright (c) 2022 Red Hat GmbH
diff --git a/test/tcp/passt b/test/passt/tcp
similarity index 98%
rename from test/tcp/passt
rename to test/passt/tcp
index 265f270..d5c8164 100644
--- a/test/tcp/passt
+++ b/test/passt/tcp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/tcp/passt - Check TCP functionality in passt mode
+# test/passt/tcp - Check TCP functionality in passt mode
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/udp/passt b/test/passt/udp
similarity index 97%
rename from test/udp/passt
rename to test/passt/udp
index a14e6d2..56d01b3 100644
--- a/test/udp/passt
+++ b/test/passt/udp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/udp/passt - Check UDP functionality in passt mode
+# test/passt/udp - Check UDP functionality in passt mode
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/icmp/passt_in_ns b/test/passt_in_ns/icmp
similarity index 94%
rename from test/icmp/passt_in_ns
rename to test/passt_in_ns/icmp
index e4ac4ff..f326d4b 100644
--- a/test/icmp/passt_in_ns
+++ b/test/passt_in_ns/icmp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/icmp/passt_in_ns - Check ICMP/ICMPv6 functionality for passt in ns
+# test/passt_in_ns/icmp - Check ICMP/ICMPv6 functionality for passt in ns
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/shutdown/passt_in_ns b/test/passt_in_ns/shutdown
similarity index 87%
rename from test/shutdown/passt_in_ns
rename to test/passt_in_ns/shutdown
index 3808adb..abe9d6c 100644
--- a/test/shutdown/passt_in_ns
+++ b/test/passt_in_ns/shutdown
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/shutdown/passt_in_ns - Shut down passt and check exit code (will detect
+# test/passt_in_ns/shutdown - Shut down passt and check exit code (will detect
 #                             valgrind errors amongst others)
 #
 # Copyright (c) 2022 Red Hat GmbH
diff --git a/test/tcp/passt_in_ns b/test/passt_in_ns/tcp
similarity index 99%
rename from test/tcp/passt_in_ns
rename to test/passt_in_ns/tcp
index a248f00..5ec95e8 100644
--- a/test/tcp/passt_in_ns
+++ b/test/passt_in_ns/tcp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/tcp/passt_in_ns - Check TCP functionality for passt in ns with pasta
+# test/passt_in_ns/tcp - Check TCP functionality for passt in ns with pasta
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/udp/passt_in_ns b/test/passt_in_ns/udp
similarity index 98%
rename from test/udp/passt_in_ns
rename to test/passt_in_ns/udp
index d5f08fe..c22a68f 100644
--- a/test/udp/passt_in_ns
+++ b/test/passt_in_ns/udp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/udp/passt_in_ns - Check UDP functionality for passt in ns and pasta
+# test/passt_in_ns/udp - Check UDP functionality for passt in ns and pasta
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/dhcp/pasta b/test/pasta/dhcp
similarity index 96%
rename from test/dhcp/pasta
rename to test/pasta/dhcp
index d1e9611..80eabf5 100644
--- a/test/dhcp/pasta
+++ b/test/pasta/dhcp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/dhcp/pasta - Check DHCP and DHCPv6 functionality in pasta mode
+# test/pasta/dhcp - Check DHCP and DHCPv6 functionality in pasta mode
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/ndp/pasta b/test/pasta/ndp
similarity index 95%
rename from test/ndp/pasta
rename to test/pasta/ndp
index d776055..d2b2c0b 100644
--- a/test/ndp/pasta
+++ b/test/pasta/ndp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/ndp/pasta - Check DHCP and DHCPv6 functionality in pasta mode
+# test/pasta/ndp - Check DHCP and DHCPv6 functionality in pasta mode
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/tcp/pasta b/test/pasta/tcp
similarity index 98%
rename from test/tcp/pasta
rename to test/pasta/tcp
index a13a2ff..7c7de06 100644
--- a/test/tcp/pasta
+++ b/test/pasta/tcp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/tcp/pasta - Check TCP functionality for pasta
+# test/pasta/tcp - Check TCP functionality for pasta
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/udp/pasta b/test/pasta/udp
similarity index 98%
rename from test/udp/pasta
rename to test/pasta/udp
index 0767e0b..0e58152 100644
--- a/test/udp/pasta
+++ b/test/pasta/udp
@@ -6,7 +6,7 @@
 # PASTA - Pack A Subtle Tap Abstraction
 #  for network namespace/tap device mode
 #
-# test/udp/pasta - Check UDP functionality for pasta
+# test/pasta/udp - Check UDP functionality for pasta
 #
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
diff --git a/test/run b/test/run
index 0ec1334..d8b60bf 100755
--- a/test/run
+++ b/test/run
@@ -74,40 +74,40 @@ run() {
 	teardown distro
 
 	setup pasta
-	test ndp/pasta
-	test dhcp/pasta
-	test tcp/pasta
-	test udp/pasta
-	test shutdown/passt
+	test pasta/ndp
+	test pasta/dhcp
+	test pasta/tcp
+	test pasta/udp
+	test passt/shutdown
 	teardown pasta
 
 	setup passt
-	test ndp/passt
-	test dhcp/passt
-	test tcp/passt
-	test udp/passt
-	test shutdown/passt
+	test passt/ndp
+	test passt/dhcp
+	test passt/tcp
+	test passt/udp
+	test passt/shutdown
 	teardown passt
 
 	VALGRIND=1
 	setup passt_in_ns
-	test ndp/passt
-	test dhcp/passt
-	test icmp/passt_in_ns
-	test tcp/passt_in_ns
-	test udp/passt_in_ns
-	test shutdown/passt_in_ns
+	test passt/ndp
+	test passt/dhcp
+	test passt_in_ns/icmp
+	test passt_in_ns/tcp
+	test passt_in_ns/udp
+	test passt_in_ns/shutdown
 	teardown passt_in_ns
 
 	VALGRIND=0
 	setup passt_in_ns
-	test ndp/passt
-	test dhcp/passt
+	test passt/ndp
+	test passt/dhcp
 	test perf/passt_tcp
 	test perf/passt_udp
 	test perf/pasta_tcp
 	test perf/pasta_udp
-	test shutdown/passt_in_ns
+	test passt_in_ns/shutdown
 	teardown passt_in_ns
 
 	setup two_guests
-- 
@@ -74,40 +74,40 @@ run() {
 	teardown distro
 
 	setup pasta
-	test ndp/pasta
-	test dhcp/pasta
-	test tcp/pasta
-	test udp/pasta
-	test shutdown/passt
+	test pasta/ndp
+	test pasta/dhcp
+	test pasta/tcp
+	test pasta/udp
+	test passt/shutdown
 	teardown pasta
 
 	setup passt
-	test ndp/passt
-	test dhcp/passt
-	test tcp/passt
-	test udp/passt
-	test shutdown/passt
+	test passt/ndp
+	test passt/dhcp
+	test passt/tcp
+	test passt/udp
+	test passt/shutdown
 	teardown passt
 
 	VALGRIND=1
 	setup passt_in_ns
-	test ndp/passt
-	test dhcp/passt
-	test icmp/passt_in_ns
-	test tcp/passt_in_ns
-	test udp/passt_in_ns
-	test shutdown/passt_in_ns
+	test passt/ndp
+	test passt/dhcp
+	test passt_in_ns/icmp
+	test passt_in_ns/tcp
+	test passt_in_ns/udp
+	test passt_in_ns/shutdown
 	teardown passt_in_ns
 
 	VALGRIND=0
 	setup passt_in_ns
-	test ndp/passt
-	test dhcp/passt
+	test passt/ndp
+	test passt/dhcp
 	test perf/passt_tcp
 	test perf/passt_udp
 	test perf/pasta_tcp
 	test perf/pasta_udp
-	test shutdown/passt_in_ns
+	test passt_in_ns/shutdown
 	teardown passt_in_ns
 
 	setup two_guests
-- 
2.37.3


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

* [PATCH v4 02/12] test: Remove unused variable FFMPEG_PID_FILE
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
  2022-09-09  3:30 ` [PATCH v4 01/12] test: Group tests by context then protocol, rather than the reverse David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 03/12] test: Actually run cleanup function David Gibson
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 493 bytes --]

FFPMPEG_PID_FILE is set (creating a temporary file), then never used.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/lib/video | 1 -
 1 file changed, 1 deletion(-)

diff --git a/test/lib/video b/test/lib/video
index 22e73bb..f609abf 100755
--- a/test/lib/video
+++ b/test/lib/video
@@ -13,7 +13,6 @@
 # Copyright (c) 2021-2022 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
-FFMPEG_PID_FILE="$(mktemp)"
 VIDEO_START_SECONDS=
 VIDEO_NAME=
 
-- 
@@ -13,7 +13,6 @@
 # Copyright (c) 2021-2022 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
-FFMPEG_PID_FILE="$(mktemp)"
 VIDEO_START_SECONDS=
 VIDEO_NAME=
 
-- 
2.37.3


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

* [PATCH v4 03/12] test: Actually run cleanup function
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
  2022-09-09  3:30 ` [PATCH v4 01/12] test: Group tests by context then protocol, rather than the reverse David Gibson
  2022-09-09  3:30 ` [PATCH v4 02/12] test: Remove unused variable FFMPEG_PID_FILE David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 04/12] test: Create common state directories for temporary files David Gibson
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 911 bytes --]

We install a cleanup() function with 'trap' in order to clean up temporary
files we generate during the tests.  However, we deinstall it after
run_term, which means it won't run in most of the cases where it would be
useful.  Even if "run from_term" exits with an error, that error will be
hidden from the run_term wrapper because it's within a tmux session, so we
will return from run_term normally, uninstall the trap and never clean up.

In fact there's no reason to uninstall the trap at all, it works just as
well on the success exit path as an error exit path.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/run | 1 -
 1 file changed, 1 deletion(-)

diff --git a/test/run b/test/run
index d8b60bf..9b0227b 100755
--- a/test/run
+++ b/test/run
@@ -178,7 +178,6 @@ else
 	:> "${LOGFILE}"
 	trap "cleanup" EXIT
 	run_term
-	trap "" EXIT
 fi
 
 [ ${DEMO} -eq 1 ] && exit 0
-- 
@@ -178,7 +178,6 @@ else
 	:> "${LOGFILE}"
 	trap "cleanup" EXIT
 	run_term
-	trap "" EXIT
 fi
 
 [ ${DEMO} -eq 1 ] && exit 0
-- 
2.37.3


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

* [PATCH v4 04/12] test: Create common state directories for temporary files
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (2 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 03/12] test: Actually run cleanup function David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 05/12] test: Move passt_test_log_pipe to state directory David Gibson
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 2864 bytes --]

The test scripts create a bunch of temporary files to keep track of
internal state.  Some are made in /tmp with individual mktemp calls, some
go in the passt source directory, and some go in $LOGDIR.  This can
sometimes make it messy to clean up after failed test runs.

Start cleaning this up by creating a single "state" directory ($STATEBASE)
in /tmp for all the state or temporary files used by a single test run.
Clean it up automatically in cleanup() - except when DEBUG==1, because
those files can be useful for debugging test script failures.

We create subdirectories under $STATEBASE for each setup function, exposed
as $STATESETUP.  We also create subdirectories for each test script and
expose those to the scripts as __STATEDIR__.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/lib/setup | 2 ++
 test/lib/term  | 2 +-
 test/lib/test  | 4 ++++
 test/run       | 2 ++
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/test/lib/setup b/test/lib/setup
index 957a9cc..b0420fb 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -394,6 +394,8 @@ teardown_demo_podman() {
 # $*:	Suffix list of setup_*() functions to be called
 setup() {
 	for arg do
+		STATESETUP="${STATEBASE}/${arg}"
+		mkdir -p "${STATESETUP}"
 		eval setup_${arg}
 	done
 }
diff --git a/test/lib/term b/test/lib/term
index ae99010..b2a45e4 100755
--- a/test/lib/term
+++ b/test/lib/term
@@ -639,7 +639,7 @@ pause_continue() {
 
 # run_term() - Start tmux session, running entry point, with recording if needed
 run_term() {
-	TMUX="tmux new-session -s passt_test -ePCAP=$PCAP -eDEBUG=$DEBUG"
+	TMUX="tmux new-session -s passt_test -eSTATEBASE=$STATEBASE -ePCAP=$PCAP -eDEBUG=$DEBUG"
 
 	if [ ${CI} -eq 1 ]; then
 		printf '\e[8;50;240t'
diff --git a/test/lib/test b/test/lib/test
index 0d06afd..3dbae0b 100755
--- a/test/lib/test
+++ b/test/lib/test
@@ -351,6 +351,10 @@ test_one() {
 	[ ${CI} -eq 1 ] && video_link "${1}"
 
 	TEST_ONE_subs="$(list_add_pair "" "__BASEPATH__" "${BASEPATH}")"
+	TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__STATESETUP__" "${STATESETUP}")"
+	STATEDIR="${STATEBASE}/${1}"
+	mkdir -p "${STATEDIR}"
+	TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__STATEDIR__" "${STATEDIR}")"
 	TEST_ONE_nok=-1
 	TEST_ONE_perf_nok=0
 	TEST_ONE_skip=0
diff --git a/test/run b/test/run
index 9b0227b..58d9b49 100755
--- a/test/run
+++ b/test/run
@@ -48,6 +48,7 @@ COMMIT="$(git log --oneline --no-decorate -1)"
 
 # cleanup() - Remove temporary files
 cleanup() {
+	[ ${DEBUG} -eq 1 ] || rm -rf "${STATEBASE}"
 	rm -f /tmp/.passt_test_log_pipe
 }
 
@@ -176,6 +177,7 @@ else
 	rm -rf "${LOGDIR}"
 	mkdir -p "${LOGDIR}"
 	:> "${LOGFILE}"
+	STATEBASE="$(mktemp -d --tmpdir passt-tests-XXXXXX)"
 	trap "cleanup" EXIT
 	run_term
 fi
-- 
@@ -48,6 +48,7 @@ COMMIT="$(git log --oneline --no-decorate -1)"
 
 # cleanup() - Remove temporary files
 cleanup() {
+	[ ${DEBUG} -eq 1 ] || rm -rf "${STATEBASE}"
 	rm -f /tmp/.passt_test_log_pipe
 }
 
@@ -176,6 +177,7 @@ else
 	rm -rf "${LOGDIR}"
 	mkdir -p "${LOGDIR}"
 	:> "${LOGFILE}"
+	STATEBASE="$(mktemp -d --tmpdir passt-tests-XXXXXX)"
 	trap "cleanup" EXIT
 	run_term
 fi
-- 
2.37.3


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

* [PATCH v4 05/12] test: Move passt_test_log_pipe to state directory
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (3 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 04/12] test: Create common state directories for temporary files David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 06/12] test: Move context temporary files to state dir David Gibson
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 5953 bytes --]

We use this fifo to send messages to the information pane.  Put it in the
state directory so it doesn't need its own cleanup.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/lib/layout | 16 ++++++++--------
 test/lib/term   | 12 ++++++------
 test/run        |  7 ++-----
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/test/lib/layout b/test/lib/layout
index cc7c688..cf319bf 100644
--- a/test/lib/layout
+++ b/test/lib/layout
@@ -27,7 +27,7 @@ layout_host() {
 
 	get_info_cols
 
-	tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done'
+	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
 	tmux send-keys -t ${PANE_INFO} -N 100 C-m
 	tmux select-pane -t ${PANE_INFO} -T "test log"
 
@@ -61,7 +61,7 @@ layout_pasta() {
 
 	get_info_cols
 
-	tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done'
+	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
 	tmux send-keys -t ${PANE_INFO} -N 100 C-m
 	tmux select-pane -t ${PANE_INFO} -T "test log"
 
@@ -92,7 +92,7 @@ layout_passt() {
 
 	get_info_cols
 
-	tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done'
+	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
 	tmux send-keys -t ${PANE_INFO} -N 100 C-m
 	tmux select-pane -t ${PANE_INFO} -T "test log"
 
@@ -128,7 +128,7 @@ layout_passt_in_pasta() {
 	pane_watch_contexts ${PANE_GUEST} "guest" qemu guest
 	pane_watch_contexts ${PANE_NS} "namespace" ns
 
-	tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done'
+	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
 	tmux send-keys -t ${PANE_INFO} -N 100 C-m
 	tmux select-pane -t ${PANE_INFO} -T "test log"
 
@@ -171,7 +171,7 @@ layout_two_guests() {
 	pane_watch_contexts ${PANE_GUEST_1} "guest #1 in namespace #1" qemu_1 guest_1
 	pane_watch_contexts ${PANE_GUEST_2} "guest #2 in namespace #2" qemu_2 guest_2
 
-	tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done'
+	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
 	tmux send-keys -t ${PANE_INFO} -N 100 C-m
 	tmux select-pane -t ${PANE_INFO} -T "test log"
 
@@ -207,7 +207,7 @@ layout_demo_pasta() {
 	tmux pipe-pane -O -t ${PANE_NS} "cat >> ${LOGDIR}/pane_ns.log"
 	tmux select-pane -t ${PANE_NS} -T "namespace"
 
-	tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done'
+	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
 	tmux send-keys -t ${PANE_INFO} -N 100 C-m
 	tmux select-pane -t ${PANE_INFO} -T ""
 
@@ -243,7 +243,7 @@ layout_demo_passt() {
 	tmux pipe-pane -O -t ${PANE_GUEST} "cat >> ${LOGDIR}/pane_guest.log"
 	tmux select-pane -t ${PANE_GUEST} -T "guest"
 
-	tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done'
+	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
 	tmux send-keys -t ${PANE_INFO} -N 100 C-m
 	tmux select-pane -t ${PANE_INFO} -T ""
 
@@ -282,7 +282,7 @@ layout_demo_podman() {
 	tmux pipe-pane -O -t ${PANE_NS2} "cat >> ${LOGDIR}/pane_ns2.log"
 	tmux select-pane -t ${PANE_NS2} -T "Podman with pasta"
 
-	tmux send-keys -l -t ${PANE_INFO} 'while cat /tmp/.passt_test_log_pipe; do :; done'
+	tmux send-keys -l -t ${PANE_INFO} 'while cat '"$STATEBASE/log_pipe"'; do :; done'
 	tmux send-keys -t ${PANE_INFO} -N 100 C-m
 	tmux select-pane -t ${PANE_INFO} -T ""
 
diff --git a/test/lib/term b/test/lib/term
index b2a45e4..2321664 100755
--- a/test/lib/term
+++ b/test/lib/term
@@ -31,7 +31,7 @@ PR_DELAY_INIT=100 # ms
 # $@:	Message to print
 info() {
 	tmux select-pane -t ${PANE_INFO}
-	echo "${@}" >> /tmp/.passt_test_log_pipe
+	echo "${@}" >> $STATEBASE/log_pipe
 	echo "${@}" >> "${LOGFILE}"
 }
 
@@ -39,7 +39,7 @@ info() {
 # $@:	Message to print
 info_n() {
 	tmux select-pane -t ${PANE_INFO}
-	printf "${@}" >> /tmp/.passt_test_log_pipe
+	printf "${@}" >> $STATEBASE/log_pipe
 	printf "${@}" >> "${LOGFILE}"
 }
 
@@ -47,7 +47,7 @@ info_n() {
 # $@:	Message to print
 info_nolog() {
 	tmux select-pane -t ${PANE_INFO}
-	echo "${@}" >> /tmp/.passt_test_log_pipe
+	echo "${@}" >> $STATEBASE/log_pipe
 }
 
 # info_nolog() - Print message to log file
@@ -365,7 +365,7 @@ status_test_start() {
 info_check() {
 	switch_pane ${PANE_INFO}
 
-	printf "${PR_YELLOW}?${PR_NC} ${@}" >> /tmp/.passt_test_log_pipe
+	printf "${PR_YELLOW}?${PR_NC} ${@}" >> $STATEBASE/log_pipe
 	printf "? ${@}" >> "${LOGFILE}"
 }
 
@@ -373,7 +373,7 @@ info_check() {
 info_check_passed() {
 	switch_pane ${PANE_INFO}
 
-	printf "\n" >> /tmp/.passt_test_log_pipe
+	printf "\n" >> $STATEBASE/log_pipe
 	printf "\n" >> ${LOGFILE}
 }
 
@@ -381,7 +381,7 @@ info_check_passed() {
 info_check_failed() {
 	switch_pane ${PANE_INFO}
 
-	printf " ${PR_RED}!${PR_NC}\n" >> /tmp/.passt_test_log_pipe
+	printf " ${PR_RED}!${PR_NC}\n" >> $STATEBASE/log_pipe
 	printf " < failed.\n" >> "${LOGFILE}"
 }
 
diff --git a/test/run b/test/run
index 58d9b49..4bb9cd8 100755
--- a/test/run
+++ b/test/run
@@ -49,13 +49,11 @@ COMMIT="$(git log --oneline --no-decorate -1)"
 # cleanup() - Remove temporary files
 cleanup() {
 	[ ${DEBUG} -eq 1 ] || rm -rf "${STATEBASE}"
-	rm -f /tmp/.passt_test_log_pipe
 }
 
 # run() - Call setup functions, run tests, handle exit from test session
 run() {
-	rm -f /tmp/.passt_test_log_pipe
-	mkfifo /tmp/.passt_test_log_pipe
+	mkfifo $STATEBASE/log_pipe
 
 	term
 	perf_init
@@ -131,8 +129,7 @@ run() {
 
 # demo() - Simpler path for demo purposes
 demo() {
-	rm -f /tmp/.passt_test_log_pipe
-	mkfifo /tmp/.passt_test_log_pipe
+	mkfifo $STATEBASE/log_pipe
 
 	FAST=0
 
-- 
@@ -49,13 +49,11 @@ COMMIT="$(git log --oneline --no-decorate -1)"
 # cleanup() - Remove temporary files
 cleanup() {
 	[ ${DEBUG} -eq 1 ] || rm -rf "${STATEBASE}"
-	rm -f /tmp/.passt_test_log_pipe
 }
 
 # run() - Call setup functions, run tests, handle exit from test session
 run() {
-	rm -f /tmp/.passt_test_log_pipe
-	mkfifo /tmp/.passt_test_log_pipe
+	mkfifo $STATEBASE/log_pipe
 
 	term
 	perf_init
@@ -131,8 +129,7 @@ run() {
 
 # demo() - Simpler path for demo purposes
 demo() {
-	rm -f /tmp/.passt_test_log_pipe
-	mkfifo /tmp/.passt_test_log_pipe
+	mkfifo $STATEBASE/log_pipe
 
 	FAST=0
 
-- 
2.37.3


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

* [PATCH v4 06/12] test: Move context temporary files to state dir
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (4 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 05/12] test: Move passt_test_log_pipe to state directory David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 07/12] test: Dont regnerate small test file in pasta/tcp David Gibson
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 5046 bytes --]

Currently the context command dispatch subsystem creates a bunch of
temporary files in $LOGDIR, which is messy.  Store them in $STATEDIR which
is for precisely this purpose.  The logs from each context still go into
$LOGDIR.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/lib/context | 61 +++++++++++++++++++++++++-----------------------
 1 file changed, 32 insertions(+), 29 deletions(-)

diff --git a/test/lib/context b/test/lib/context
index ccb0004..43b00dd 100644
--- a/test/lib/context
+++ b/test/lib/context
@@ -17,17 +17,17 @@
 # $1:	Context name
 context_setup_common() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
-	echo -n "${__name}$ " > "${__prefix}.log"
+	__log="${LOGDIR}/context_${__name}.log"
+	echo -n "${__name}$ " > "${__log}"
 }
 
 # context_setup_host() - Create a new context for running commands on the host
 # $1:	Context name
 context_setup_host() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
+	__enter="${STATESETUP}/context_${__name}.enter"
 	context_setup_common "${__name}"
-	echo sh -c > "${__prefix}.enter"
+	echo sh -c > "${__enter}"
 }
 
 # context_setup_nsenter() - Create a new context for running commands in a namespace
@@ -36,9 +36,9 @@ context_setup_host() {
 context_setup_nsenter() {
 	__name="$1"
 	shift
-	__prefix="${LOGDIR}/context_${__name}"
+	__enter="${STATESETUP}/context_${__name}.enter"
 	context_setup_common "${__name}"
-	echo "nsenter $@ sh -c" > "${__prefix}.enter"
+	echo "nsenter $@ sh -c" > "${__enter}"
 }
 
 # context_setup_guest() - Create a new context for running commands in a guest
@@ -47,22 +47,23 @@ context_setup_nsenter() {
 context_setup_guest() {
 	__name="$1"
 	__cid="$2"
-	__prefix="${LOGDIR}/context_${__name}"
+	__enter="${STATESETUP}/context_${__name}.enter"
+	__ssh="${STATESETUP}/context_${__name}.ssh"
 	context_setup_common "${__name}"
 
-	cat > "${__prefix}.ssh" <<EOF
+	cat > "${__ssh}" <<EOF
 Host ${__name}
 	User root
-	UserKnownHostsFile ${__prefix}.hosts
+	UserKnownHostsFile ${STATESETUP}/context_${__name}.hosts
 	StrictHostKeyChecking no
 	IdentityFile ${BASEPATH}/guest-key
 	IdentityAgent none
 	ProxyCommand socat - VSOCK-CONNECT:${__cid}:22
 EOF
-	echo "ssh -F ${__prefix}.ssh ${__name}" > "${__prefix}.enter"
+	echo "ssh -F ${__ssh} ${__name}" > "${__enter}"
 
 	# Wait for the guest to be booted and accepting connections
-	while ! ssh -F "${__prefix}.ssh" "${__name}" :; do
+	while ! ssh -F "${__ssh}" "${__name}" :; do
 		sleep 0.1
 	done
 }
@@ -71,7 +72,7 @@ EOF
 # $1:	Context name
 context_teardown() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
+	__prefix="${STATESETUP}/context_${__name}"
 	rm -f "${__prefix}.enter" "${__prefix}.ssh" "${__prefix}.hosts"
 }
 
@@ -79,8 +80,8 @@ context_teardown() {
 # $1:	Context name
 context_exists() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
-	[ -f "${__prefix}.enter" ]
+	__enter="${STATESETUP}/context_${__name}.enter"
+	[ -f "${__enter}" ]
 }
 
 # context_run() - Run a shell command in a context, and wait for it to finish
@@ -88,18 +89,20 @@ context_exists() {
 # $*:	Command to start
 context_run() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
-	__enter="$(cat "${__prefix}.enter")"
+	__log="${LOGDIR}/context_${__name}.log"
+	__enter="${STATESETUP}/context_${__name}.enter"
+	__stdout="${STATESETUP}/context_${__name}.stdout"
+	__stderr="${STATESETUP}/context_${__name}.stderr"
 	shift
-	echo "$*" >> "${__prefix}.log"
-	mkfifo "${__prefix}.stdout" "${__prefix}.stderr"
-	tee -a "${__prefix}.log" < "${__prefix}.stdout" &
-	tee -a "${__prefix}.log" < "${__prefix}.stderr" >&2 &
-	${__enter} "$*" >> "${__prefix}.stdout" 2>> "${__prefix}.stderr"
+	echo "$*" >> "${__log}"
+	mkfifo "${__stdout}" "${__stderr}"
+	tee -a "${__log}" < "${__stdout}" &
+	tee -a "${__log}" < "${__stderr}" >&2 &
+	$(cat ${__enter}) "$*" >> "${__stdout}" 2>> "${__stderr}"
 	rc=$?
-	rm "${__prefix}.stdout" "${__prefix}.stderr"
-	[ ${DEBUG} -eq 1 ] && echo "[Exit code: $rc]" >> "${__prefix}.log"
-	echo -n "${__name}$ " >> "${__prefix}.log"
+	rm "${__stdout}" "${__stderr}"
+	[ ${DEBUG} -eq 1 ] && echo "[Exit code: $rc]" >> "${__log}"
+	echo -n "${__name}$ " >> "${__log}"
 	return $rc
 }
 
@@ -108,9 +111,9 @@ context_run() {
 # $*:	Command to start
 context_run_bg() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
+	__pidfile="${STATESETUP}/context_${__name}.pid"
 	context_run "$@" &
-	echo $! > "${__prefix}.pid"
+	echo $! > "${__pidfile}"
 }
 
 # context_wait() - Wait for background command in a context to complete
@@ -118,8 +121,8 @@ context_run_bg() {
 # Returns the status of the completed command
 context_wait() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
-	__pid=$(cat "${__prefix}.pid")
-	rm "${__prefix}.pid"
+	__pidfile="${STATESETUP}/context_${__name}.pid"
+	__pid=$(cat "${__pidfile}")
+	rm "${__pidfile}"
 	wait ${__pid}
 }
-- 
@@ -17,17 +17,17 @@
 # $1:	Context name
 context_setup_common() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
-	echo -n "${__name}$ " > "${__prefix}.log"
+	__log="${LOGDIR}/context_${__name}.log"
+	echo -n "${__name}$ " > "${__log}"
 }
 
 # context_setup_host() - Create a new context for running commands on the host
 # $1:	Context name
 context_setup_host() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
+	__enter="${STATESETUP}/context_${__name}.enter"
 	context_setup_common "${__name}"
-	echo sh -c > "${__prefix}.enter"
+	echo sh -c > "${__enter}"
 }
 
 # context_setup_nsenter() - Create a new context for running commands in a namespace
@@ -36,9 +36,9 @@ context_setup_host() {
 context_setup_nsenter() {
 	__name="$1"
 	shift
-	__prefix="${LOGDIR}/context_${__name}"
+	__enter="${STATESETUP}/context_${__name}.enter"
 	context_setup_common "${__name}"
-	echo "nsenter $@ sh -c" > "${__prefix}.enter"
+	echo "nsenter $@ sh -c" > "${__enter}"
 }
 
 # context_setup_guest() - Create a new context for running commands in a guest
@@ -47,22 +47,23 @@ context_setup_nsenter() {
 context_setup_guest() {
 	__name="$1"
 	__cid="$2"
-	__prefix="${LOGDIR}/context_${__name}"
+	__enter="${STATESETUP}/context_${__name}.enter"
+	__ssh="${STATESETUP}/context_${__name}.ssh"
 	context_setup_common "${__name}"
 
-	cat > "${__prefix}.ssh" <<EOF
+	cat > "${__ssh}" <<EOF
 Host ${__name}
 	User root
-	UserKnownHostsFile ${__prefix}.hosts
+	UserKnownHostsFile ${STATESETUP}/context_${__name}.hosts
 	StrictHostKeyChecking no
 	IdentityFile ${BASEPATH}/guest-key
 	IdentityAgent none
 	ProxyCommand socat - VSOCK-CONNECT:${__cid}:22
 EOF
-	echo "ssh -F ${__prefix}.ssh ${__name}" > "${__prefix}.enter"
+	echo "ssh -F ${__ssh} ${__name}" > "${__enter}"
 
 	# Wait for the guest to be booted and accepting connections
-	while ! ssh -F "${__prefix}.ssh" "${__name}" :; do
+	while ! ssh -F "${__ssh}" "${__name}" :; do
 		sleep 0.1
 	done
 }
@@ -71,7 +72,7 @@ EOF
 # $1:	Context name
 context_teardown() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
+	__prefix="${STATESETUP}/context_${__name}"
 	rm -f "${__prefix}.enter" "${__prefix}.ssh" "${__prefix}.hosts"
 }
 
@@ -79,8 +80,8 @@ context_teardown() {
 # $1:	Context name
 context_exists() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
-	[ -f "${__prefix}.enter" ]
+	__enter="${STATESETUP}/context_${__name}.enter"
+	[ -f "${__enter}" ]
 }
 
 # context_run() - Run a shell command in a context, and wait for it to finish
@@ -88,18 +89,20 @@ context_exists() {
 # $*:	Command to start
 context_run() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
-	__enter="$(cat "${__prefix}.enter")"
+	__log="${LOGDIR}/context_${__name}.log"
+	__enter="${STATESETUP}/context_${__name}.enter"
+	__stdout="${STATESETUP}/context_${__name}.stdout"
+	__stderr="${STATESETUP}/context_${__name}.stderr"
 	shift
-	echo "$*" >> "${__prefix}.log"
-	mkfifo "${__prefix}.stdout" "${__prefix}.stderr"
-	tee -a "${__prefix}.log" < "${__prefix}.stdout" &
-	tee -a "${__prefix}.log" < "${__prefix}.stderr" >&2 &
-	${__enter} "$*" >> "${__prefix}.stdout" 2>> "${__prefix}.stderr"
+	echo "$*" >> "${__log}"
+	mkfifo "${__stdout}" "${__stderr}"
+	tee -a "${__log}" < "${__stdout}" &
+	tee -a "${__log}" < "${__stderr}" >&2 &
+	$(cat ${__enter}) "$*" >> "${__stdout}" 2>> "${__stderr}"
 	rc=$?
-	rm "${__prefix}.stdout" "${__prefix}.stderr"
-	[ ${DEBUG} -eq 1 ] && echo "[Exit code: $rc]" >> "${__prefix}.log"
-	echo -n "${__name}$ " >> "${__prefix}.log"
+	rm "${__stdout}" "${__stderr}"
+	[ ${DEBUG} -eq 1 ] && echo "[Exit code: $rc]" >> "${__log}"
+	echo -n "${__name}$ " >> "${__log}"
 	return $rc
 }
 
@@ -108,9 +111,9 @@ context_run() {
 # $*:	Command to start
 context_run_bg() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
+	__pidfile="${STATESETUP}/context_${__name}.pid"
 	context_run "$@" &
-	echo $! > "${__prefix}.pid"
+	echo $! > "${__pidfile}"
 }
 
 # context_wait() - Wait for background command in a context to complete
@@ -118,8 +121,8 @@ context_run_bg() {
 # Returns the status of the completed command
 context_wait() {
 	__name="$1"
-	__prefix="${LOGDIR}/context_${__name}"
-	__pid=$(cat "${__prefix}.pid")
-	rm "${__prefix}.pid"
+	__pidfile="${STATESETUP}/context_${__name}.pid"
+	__pid=$(cat "${__pidfile}")
+	rm "${__pidfile}"
 	wait ${__pid}
 }
-- 
2.37.3


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

* [PATCH v4 07/12] test: Dont regnerate small test file in pasta/tcp
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (5 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 06/12] test: Move context temporary files to state dir David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 08/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives David Gibson
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

In what looks like a copy/paste error, pasta/tcp generates its small test
file twice.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/pasta/tcp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/test/pasta/tcp b/test/pasta/tcp
index 7c7de06..5497f11 100644
--- a/test/pasta/tcp
+++ b/test/pasta/tcp
@@ -91,10 +91,7 @@ hout	HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
 check	[ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
 
 test	TCP/IPv6: host to ns: small transfer
-temp	TEMP_SMALL
-temp	TEMP_NS_SMALL
 nsb	socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_SMALL__,create,trunc
-host	dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__
 host	socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10002
 nsw
 hout	MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1
-- 
@@ -91,10 +91,7 @@ hout	HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
 check	[ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
 
 test	TCP/IPv6: host to ns: small transfer
-temp	TEMP_SMALL
-temp	TEMP_NS_SMALL
 nsb	socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_SMALL__,create,trunc
-host	dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__
 host	socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10002
 nsw
 hout	MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1
-- 
2.37.3


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

* [PATCH v4 08/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (6 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 07/12] test: Dont regnerate small test file in pasta/tcp David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09 15:00   ` Stefano Brivio
  2022-09-09  3:30 ` [PATCH v4 09/12] test: Move pause temporary file to state directory David Gibson
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 21185 bytes --]

Instead of using the 'temp' and 'tempdir' DSL directives to create
temporary files, use fixed paths relative to __STATEDIR__.  This has two
advantages:
  1) The files are automatically cleaned up if the tests fail (and even if
     that doesn't work they're easier to clean up manuall)
  2) When debugging tests it's easier to figure out which of the temporary
     files are relevant to whatever's going wrong

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/build/all       | 31 +++++++++++++++----------------
 test/demo/passt      |  9 ++++-----
 test/demo/pasta      | 12 +++++-------
 test/demo/podman     | 11 +++++------
 test/distro/debian   |  2 +-
 test/distro/fedora   |  2 +-
 test/distro/opensuse | 16 +++++++++-------
 test/distro/ubuntu   |  8 ++++----
 test/lib/test        | 10 ----------
 test/passt/tcp       |  4 ++--
 test/passt/udp       |  6 +++---
 test/passt_in_ns/tcp |  8 ++++----
 test/passt_in_ns/udp |  6 +++---
 test/pasta/tcp       |  8 ++++----
 test/pasta/udp       | 18 +++++++++---------
 15 files changed, 69 insertions(+), 82 deletions(-)

diff --git a/test/build/all b/test/build/all
index 1a89b77..bacb1d1 100644
--- a/test/build/all
+++ b/test/build/all
@@ -41,22 +41,21 @@ check	[ -f passt ]
 check	[ -h pasta ]
 check	[ -f qrap ]
 
-tempdir	TEMP
-
 test	Install
-host	prefix=__TEMP__ make install
-check	[ -f __TEMP__/bin/passt ]
-check	[ -h __TEMP__/bin/pasta ]
-check	[ -f __TEMP__/bin/qrap ]
-check	man -M __TEMP__/share/man -W passt
-check	man -M __TEMP__/share/man -W pasta
-check	man -M __TEMP__/share/man -W qrap
+host	mkdir __STATEDIR__/prefix
+host	prefix=__STATEDIR__/prefix make install
+check	[ -f __STATEDIR__/prefix/bin/passt ]
+check	[ -h __STATEDIR__/prefix/bin/pasta ]
+check	[ -f __STATEDIR__/prefix/bin/qrap ]
+check	man -M __STATEDIR__/prefix/share/man -W passt
+check	man -M __STATEDIR__/prefix/share/man -W pasta
+check	man -M __STATEDIR__/prefix/share/man -W qrap
 
 test	Uninstall
-host	prefix=__TEMP__ make uninstall
-check	! [ -f __TEMP__/bin/passt ]
-check	! [ -h __TEMP__/bin/pasta ]
-check	! [ -f __TEMP__/bin/qrap ]
-check	! man -M __TEMP__/share/man -W passt 2>/dev/null
-check	! man -M __TEMP__/share/man -W pasta 2>/dev/null
-check	! man -M __TEMP__/share/man -W qrap 2>/dev/null
+host	prefix=__STATEDIR__/prefix make uninstall
+check	! [ -f __STATEDIR__/prefix/bin/passt ]
+check	! [ -h __STATEDIR__/prefix/bin/pasta ]
+check	! [ -f __STATEDIR__/prefix/bin/qrap ]
+check	! man -M __STATEDIR__/prefix/share/man -W passt 2>/dev/null
+check	! man -M __STATEDIR__/prefix/share/man -W pasta 2>/dev/null
+check	! man -M __STATEDIR__/prefix/share/man -W qrap 2>/dev/null
diff --git a/test/demo/passt b/test/demo/passt
index 673afd9..dd6a119 100644
--- a/test/demo/passt
+++ b/test/demo/passt
@@ -20,8 +20,7 @@ sleep	3
 
 say	Let's fetch the source
 sleep	1
-tempdir	TEMPDIR
-host	cd __TEMPDIR__
+host	cd __STATEDIR__
 host	git clone git://passt.top/passt
 sleep	1
 
@@ -52,10 +51,10 @@ host	q
 nl
 nl
 say	Let's create a small initramfs image for the guest.
-guest	cd __TEMPDIR__
+guest	cd __STATEDIR__
 guest	git clone git://mbuto.sh/mbuto
 guest	cd mbuto
-guest	./mbuto -f passt.img -p __TEMPDIR__/passt/test/passt.mbuto -c lz4
+guest	./mbuto -f passt.img -p __STATEDIR__/passt/test/passt.mbuto -c lz4
 sleep	2
 
 nl
@@ -69,7 +68,7 @@ nl
 say	  'pasta' demo above.
 sleep	3
 
-passt	cd __TEMPDIR__/passt
+passt	cd __STATEDIR__/passt
 passtb	./pasta -P /tmp/pasta.pid
 sleep	3
 passt	/sbin/dhclient -4 --no-pid
diff --git a/test/demo/pasta b/test/demo/pasta
index 393149e..22479f8 100644
--- a/test/demo/pasta
+++ b/test/demo/pasta
@@ -20,8 +20,7 @@ sleep	3
 
 say	Let's fetch the source
 sleep	1
-tempdir	TEMPDIR
-host	cd __TEMPDIR__
+host	cd __STATEDIR__
 host	git clone git://passt.top/passt
 sleep	1
 
@@ -47,7 +46,7 @@ sleep	10
 nl
 say	  without PID, it will create a namespace.
 sleep	3
-passt	cd __TEMPDIR__/passt
+passt	cd __STATEDIR__/passt
 passtb	./pasta -P /tmp/pasta.pid
 sleep	3
 
@@ -140,13 +139,12 @@ say	 can also take packet captures.
 sleep	3
 passt	exit
 sleep	2
-temp	TEMP
-passtb	./pasta -p __TEMP__.pcap
+passtb	./pasta -p __STATEDIR__/demo_pasta.pcap
 sleep	2
 passt	
 passt	/sbin/dhclient -4 --no-pid
 sleep	2
-hostb	tshark -r __TEMP__.pcap
+hostb	tshark -r __STATEDIR__/demo_pasta.pcap
 sleep	5
 
 nl
@@ -257,7 +255,7 @@ sleep	2
 killp	PASST
 killp	HOST
 sleep	2
-ns	cd __TEMPDIR__/passt
+ns	cd __STATEDIR__/passt
 nsb	perf report -g --max-stack 3
 sleep	10
 
diff --git a/test/demo/podman b/test/demo/podman
index f3411d8..a83a04f 100644
--- a/test/demo/podman
+++ b/test/demo/podman
@@ -24,14 +24,13 @@ sleep	3
 
 say	Let's fetch Podman
 sleep	1
-tempdir	TEMPDIR
-host	git -C __TEMPDIR__ clone https://github.com/containers/podman.git
+host	git -C __STATEDIR__ clone https://github.com/containers/podman.git
 sleep	1
 
 say	, patch it
 sleep	1
-host	cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __TEMPDIR__/podman
-host	cd __TEMPDIR__/podman
+host	cp ../contrib/podman/0001-libpod-Add-pasta-networking-mode.patch __STATEDIR__/podman
+host	cd __STATEDIR__/podman
 host	git am -3 0001-libpod-Add-pasta-networking-mode.patch
 sleep	1
 
@@ -54,7 +53,7 @@ nl
 say	Let's start a container with it
 sleep	1
 
-ns1	cd __TEMPDIR__/podman
+ns1	cd __STATEDIR__/podman
 ns1b	./bin/podman run --rm -ti alpine sh
 sleep	2
 
@@ -64,7 +63,7 @@ say	and one with
 em	pasta
 say	 instead.
 
-ns2	cd __TEMPDIR__/podman
+ns2	cd __STATEDIR__/podman
 ns2b	./bin/podman run --net=pasta --rm -ti alpine sh
 sleep	2
 
diff --git a/test/distro/debian b/test/distro/debian
index 83fb32d..4a19f95 100644
--- a/test/distro/debian
+++ b/test/distro/debian
@@ -11,7 +11,7 @@
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
-temp	PIDFILE
+set	PIDFILE __STATEDIR__/passt.pid
 htools	cat kill qemu-system-x86_64 qemu-system-aarch64 qemu-system-ppc64
 
 # Quick pasta test: send message from init to ns, and from ns to init
diff --git a/test/distro/fedora b/test/distro/fedora
index daad6a4..a8d3b51 100644
--- a/test/distro/fedora
+++ b/test/distro/fedora
@@ -11,7 +11,7 @@
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
-temp	PIDFILE
+set	PIDFILE __STATEDIR__/passt.pid
 htools	cat kill qemu-system-x86_64
 
 # Quick pasta test: send message from init to ns, and from ns to init
diff --git a/test/distro/opensuse b/test/distro/opensuse
index d48deb7..314870f 100644
--- a/test/distro/opensuse
+++ b/test/distro/opensuse
@@ -11,7 +11,7 @@
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
-temp	PIDFILE
+set	PIDFILE __STATEDIR__/passt.pid
 htools	qemu-img virt-edit guestfish head sed cat kill qemu-system-x86_64 qemu-system-aarch64 xzcat tr
 
 # Quick pasta test: send message from init to ns, and from ns to init
@@ -44,7 +44,7 @@ hout	GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile README.md | tr '\n'
 
 test	OpenSUSE Leap 15.1
 
-temp	IMG
+set	IMG __STATEDIR__/opensuse-15.1-x86_64.img
 host	qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.1-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__
 host	guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
@@ -73,6 +73,7 @@ hout	PID cat __PIDFILE__
 
 test	OpenSUSE Leap 15.2
 
+set	IMG __STATEDIR__/opensuse-15.2-x86_64.img
 host	qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.2-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__
 host	guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
@@ -98,6 +99,7 @@ sleep	1
 
 test	OpenSUSE Leap 15.3
 
+set	IMG __STATEDIR__/opensuse-15.3-x86_64.img
 host	qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__
 host	guestfish --rw -a __IMG__ -i rm '/usr/lib/systemd/system/systemd-journald.service'
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
@@ -125,7 +127,7 @@ sleep	1
 
 test	OpenSUSE Tumbleweed aarch64
 
-temp	IMG
+set	IMG __STATEDIR__/opensuse-tumbleweed-aarch64.img
 host	xzcat __BASEPATH__/openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.raw.xz > __IMG__
 host	virt-edit -a __IMG__ -m /dev/sda3 /usr/lib/systemd/system/serial-getty(a).service -e 's/ExecStart=.*/ExecStart=\/sbin\/agetty --timeout 5000 --autologin root -i -8 --keep-baud 115200,38400,9600 %I $TERM/g'
 host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
@@ -150,9 +152,9 @@ sleep	1
 
 test	OpenSUSE Tumbleweed armv7l
 
-temp	IMG
-temp	ZIMAGE
-temp	INITRD
+set	IMG __STATEDIR__/opensuse-tumbleweed-armv7l.img
+set	ZIMAGE __STATEDIR__/opensuse-tumbleweed-armv7l.zimage
+set	INITRD __STATEDIR__/opensuse-tumbleweed-armv7l.initrd
 host	xzcat __BASEPATH__/openSUSE-Tumbleweed-ARM-JeOS-efi.armv7l.raw.xz > __IMG__
 host	guestfish -a __IMG__ -i download /boot/zImage __ZIMAGE__
 host	guestfish -a __IMG__ -i download /boot/initrd __INITRD__
@@ -178,7 +180,7 @@ sleep	1
 
 test	OpenSUSE Tumbleweed
 
-temp	IMG
+set	IMG __STATEDIR__/opensuse-tumbleweed-x86_64.img
 host	qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/openSUSE-Tumbleweed-JeOS.x86_64-kvm-and-xen.qcow2 __IMG__
 host	guestfish --rw -a __IMG__ -i rm /usr/lib/systemd/system/systemd-journald.service
 host	guestfish --rw -a __IMG__ -i rm /etc/systemd/system/default.target.wants/jeos-firstboot.service
diff --git a/test/distro/ubuntu b/test/distro/ubuntu
index 5e67a46..aa42c99 100644
--- a/test/distro/ubuntu
+++ b/test/distro/ubuntu
@@ -11,7 +11,7 @@
 # Copyright (c) 2021 Red Hat GmbH
 # Author: Stefano Brivio <sbrivio(a)redhat.com>
 
-temp	PIDFILE
+set	PIDFILE __STATEDIR__/passt.pid
 htools	qemu-img virt-edit guestfish cat kill qemu-system-x86_64 qemu-system-ppc64 qemu-system-s390x
 
 # Quick pasta test: send message from init to ns, and from ns to init
@@ -68,7 +68,7 @@ hout	GUEST_FILES ls -1 *.c *.h *.sh passt.1 qrap.1 Makefile README.md | tr '\n'
 
 test	Ubuntu 14.04.5 LTS (Trusty Tahr), amd64
 
-temp	IMG
+set	IMG __STATEDIR__/ubuntu-14.04-amd64.img
 host	qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-amd64-disk1.img __IMG__
 host	virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autologin root/'
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
@@ -101,7 +101,7 @@ hout	PID cat __PIDFILE__
 
 test	Ubuntu 14.04.5 LTS (Trusty Tahr), i386
 
-temp	IMG
+set	IMG __STATEDIR__/ubuntu-14.04-i386.img
 host	qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-i386-disk1.img __IMG__
 host	virt-edit -a __IMG__ /etc/init/ttyS0.conf -e 's/\/getty/\/getty --autologin root/'
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
@@ -131,7 +131,7 @@ sleep	1
 
 test	Ubuntu 14.04.5 LTS (Trusty Tahr), ppc64le
 
-temp	IMG
+set	IMG __STATEDIR__/ubuntu-14.04-ppc64le.img
 host	qemu-img create -f qcow2 -F qcow2 -b __BASEPATH__/trusty-server-cloudimg-ppc64el-disk1.img __IMG__
 host	virt-edit -a __IMG__ /etc/init/hvc0.conf -e 's/\/getty/\/getty --autologin root/'
 host	guestfish --rw -a __IMG__ -i rm /etc/init/cloud-config.conf
diff --git a/test/lib/test b/test/lib/test
index 3dbae0b..3ad178f 100755
--- a/test/lib/test
+++ b/test/lib/test
@@ -99,16 +99,6 @@ test_one_line() {
 		IFS= eval TEST_ONE_DEF_$TEST_ONE_in_def=
 		IFS="${__ifs}"
 		;;
-	"tempdir")
-		__tmpdir="$(mktemp -d)"
-		TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tmpdir}")"
-		TEST_ONE_dirclean="$(list_add "${TEST_ONE_dirclean}" "${__tmpdir}")"
-		;;
-	"temp")
-		__tmpfile="$(mktemp)"
-		TEST_ONE_subs="$(list_add_pair "${TEST_ONE_subs}" "__${__arg}__" "${__tmpfile}")"
-		TEST_ONE_dirclean="$(list_add "${TEST_ONE_dirclean}" "${__tmpfile}")"
-		;;
 	"test")
 		[ ${TEST_ONE_perf_nok} -eq 0 ] || TEST_ONE_nok=1
 		[ ${TEST_ONE_nok} -eq 1 ] && status_test_fail
diff --git a/test/passt/tcp b/test/passt/tcp
index d5c8164..7af9c54 100644
--- a/test/passt/tcp
+++ b/test/passt/tcp
@@ -15,7 +15,7 @@ gtools	socat ip jq md5sum cut
 htools	dd socat ip jq md5sum cut
 
 test	TCP/IPv4: host to guest: big transfer
-temp	TEMP_BIG
+set	TEMP_BIG __STATEDIR__/big
 guestb	socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_big.bin,create,trunc
 sleep	1
 host	dd if=/dev/urandom bs=1M count=10 > __TEMP_BIG__
@@ -34,7 +34,7 @@ hout	HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
 check	[ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ]
 
 test	TCP/IPv4: host to guest: small transfer
-temp	TEMP_SMALL
+set	TEMP_SMALL __STATEDIR__/small
 guestb	socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_small.bin,create,trunc
 sleep	1
 host	dd if=/dev/urandom bs=2k count=1 > __TEMP_SMALL__
diff --git a/test/passt/udp b/test/passt/udp
index 56d01b3..0253a86 100644
--- a/test/passt/udp
+++ b/test/passt/udp
@@ -15,9 +15,9 @@ gtools	socat tee grep cat ip jq md5sum cut
 htools	printf dd socat tee grep cat ip jq md5sum cut
 
 test	UDP/IPv4: host to guest
-temp	TEMP
-temp	SC_PID
-guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > __SC_PID__) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
+set	TEMP __STATEDIR__/data
+set	SC_PID __STATEDIR__/socat.pid
+guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))
 sleep	1
 host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
 host	socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001
diff --git a/test/passt_in_ns/tcp b/test/passt_in_ns/tcp
index 5ec95e8..a2cb667 100644
--- a/test/passt_in_ns/tcp
+++ b/test/passt_in_ns/tcp
@@ -16,7 +16,7 @@ htools	dd socat ip jq md5sum cut
 nstools	socat ip jq md5sum cut
 
 test	TCP/IPv4: host to guest: big transfer
-temp	TEMP_BIG
+set	TEMP_BIG __STATEDIR__/big.img
 guestb	socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc
 sleep	1
 host	dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__
@@ -27,7 +27,7 @@ gout	GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
 check	[ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
 
 test	TCP/IPv4: host to ns: big transfer
-temp	TEMP_NS_BIG
+set	TEMP_NS_BIG __STATEDIR__/big_ns.img
 nsb	socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc
 host	socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002
 nsw
@@ -82,7 +82,7 @@ gout	GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
 check	[ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
 
 test	TCP/IPv4: host to guest: small transfer
-temp	TEMP_SMALL
+set	TEMP_SMALL __STATEDIR__/small.img
 guestb	socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc
 sleep	1
 host	dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__
@@ -93,7 +93,7 @@ gout	GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1
 check	[ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
 
 test	TCP/IPv4: host to ns: small transfer
-temp	TEMP_NS_SMALL
+set	TEMP_NS_SMALL __STATEDIR__/small_ns.img
 nsb	socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc
 host	socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002
 nsw
diff --git a/test/passt_in_ns/udp b/test/passt_in_ns/udp
index c22a68f..3b1e521 100644
--- a/test/passt_in_ns/udp
+++ b/test/passt_in_ns/udp
@@ -16,8 +16,8 @@ nstools	socat tee grep cat ip jq md5sum cut
 htools	printf dd socat tee grep cat ip jq md5sum cut
 
 test	UDP/IPv4: host to guest
-temp	TEMP
-temp	SC_PID
+set	TEMP __STATEDIR__/data
+set	SC_PID __STATEDIR__/socat.pid
 guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))
 sleep	1
 host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
@@ -28,7 +28,7 @@ gout	GUEST_MD5 md5sum test.bin | cut -d' ' -f1
 check	[ "__GUEST_MD5__" = "__MD5__" ]
 
 test	UDP/IPv4: host to ns
-temp	TEMP_NS
+set	TEMP_NS __STATEDIR__/data_ns
 nsb	(socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 host	socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10002
 nsw
diff --git a/test/pasta/tcp b/test/pasta/tcp
index 5497f11..d37e21c 100644
--- a/test/pasta/tcp
+++ b/test/pasta/tcp
@@ -15,8 +15,8 @@ htools	dd socat ip jq md5sum cut
 nstools	socat ip jq md5sum cut
 
 test	TCP/IPv4: host to ns: big transfer
-temp	TEMP_BIG
-temp	TEMP_NS_BIG
+set	TEMP_BIG __STATEDIR__/big
+set	TEMP_NS_BIG __STATEDIR__/big_ns
 nsb	socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_BIG__,create,trunc
 host	dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__
 host	socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002
@@ -41,8 +41,8 @@ hout	HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
 check	[ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
 
 test	TCP/IPv4: host to ns: small transfer
-temp	TEMP_SMALL
-temp	TEMP_NS_SMALL
+set	TEMP_SMALL __STATEDIR__/small
+set	TEMP_NS_SMALL __STATEDIR__/small_ns
 nsb	socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_SMALL__,create,trunc
 host	dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__
 host	socat OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002
diff --git a/test/pasta/udp b/test/pasta/udp
index 0e58152..74148e3 100644
--- a/test/pasta/udp
+++ b/test/pasta/udp
@@ -15,10 +15,10 @@ nstools	socat tee grep cat ip jq md5sum cut
 htools	printf dd socat tee grep cat ip jq md5sum cut
 
 test	UDP/IPv4: host to ns
-temp	TEMP
-temp	TEMP_NS
-temp	NC_PID
-nsb	(socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+set	TEMP __STATEDIR__/data
+set	TEMP_NS __STATEDIR__/data_ns
+set	SC_PID __STATEDIR__/socat.pid
+nsb	(socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
 
 host	socat OPEN:__TEMP__ UDP4:127.0.0.1:10002
@@ -28,7 +28,7 @@ nsout	NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
 check	[ "__NS_MD5__" = "__MD5__" ]
 
 test	UDP/IPv4: ns to host (recvmmsg/sendmmsg)
-hostb	(socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb	(socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 sleep	1
 ns	socat OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003
 hostw
@@ -36,7 +36,7 @@ hout	HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
 check	[ "__HOST_MD5__" = "__MD5__" ]
 
 test	UDP/IPv4: ns to host (via tap)
-hostb	(socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb	(socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 nsout	GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
 ns	socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003
 hostw
@@ -44,7 +44,7 @@ hout	HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
 check	[ "__HOST_MD5__" = "__MD5__" ]
 
 test	UDP/IPv6: host to ns
-nsb	(socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+nsb	(socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 host	socat -u OPEN:__TEMP__ UDP6:[::1]:10002
 nsw
 hout	MD5 md5sum __TEMP__ | cut -d' ' -f1
@@ -52,7 +52,7 @@ nsout	NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
 check	[ "__NS_MD5__" = "__MD5__" ]
 
 test	UDP/IPv6: ns to host (recvmmsg/sendmmsg)
-hostb	(socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb	(socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 sleep	1
 ns	socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003
 hostw
@@ -60,7 +60,7 @@ hout	HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
 check	[ "__HOST_MD5__" = "__MD5__" ]
 
 test	UDP/IPv6: ns to host (via tap)
-hostb	(socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb	(socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
 nsout	IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
 ns	socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003
-- 
@@ -15,10 +15,10 @@ nstools	socat tee grep cat ip jq md5sum cut
 htools	printf dd socat tee grep cat ip jq md5sum cut
 
 test	UDP/IPv4: host to ns
-temp	TEMP
-temp	TEMP_NS
-temp	NC_PID
-nsb	(socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+set	TEMP __STATEDIR__/data
+set	TEMP_NS __STATEDIR__/data_ns
+set	SC_PID __STATEDIR__/socat.pid
+nsb	(socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
 
 host	socat OPEN:__TEMP__ UDP4:127.0.0.1:10002
@@ -28,7 +28,7 @@ nsout	NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
 check	[ "__NS_MD5__" = "__MD5__" ]
 
 test	UDP/IPv4: ns to host (recvmmsg/sendmmsg)
-hostb	(socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb	(socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 sleep	1
 ns	socat OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003
 hostw
@@ -36,7 +36,7 @@ hout	HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
 check	[ "__HOST_MD5__" = "__MD5__" ]
 
 test	UDP/IPv4: ns to host (via tap)
-hostb	(socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb	(socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 nsout	GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
 ns	socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003
 hostw
@@ -44,7 +44,7 @@ hout	HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
 check	[ "__HOST_MD5__" = "__MD5__" ]
 
 test	UDP/IPv6: host to ns
-nsb	(socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+nsb	(socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 host	socat -u OPEN:__TEMP__ UDP6:[::1]:10002
 nsw
 hout	MD5 md5sum __TEMP__ | cut -d' ' -f1
@@ -52,7 +52,7 @@ nsout	NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
 check	[ "__NS_MD5__" = "__MD5__" ]
 
 test	UDP/IPv6: ns to host (recvmmsg/sendmmsg)
-hostb	(socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb	(socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 sleep	1
 ns	socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003
 hostw
@@ -60,7 +60,7 @@ hout	HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
 check	[ "__HOST_MD5__" = "__MD5__" ]
 
 test	UDP/IPv6: ns to host (via tap)
-hostb	(socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
+hostb	(socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
 nsout	GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
 nsout	IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
 ns	socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003
-- 
2.37.3


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

* [PATCH v4 09/12] test: Move pause temporary file to state directory
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (7 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 08/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 10/12] test: Store pcap files in $LOGDIR instead of /tmp David Gibson
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 549 bytes --]

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/lib/term | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/lib/term b/test/lib/term
index 2321664..d6869c7 100755
--- a/test/lib/term
+++ b/test/lib/term
@@ -599,8 +599,8 @@ pause_continue() {
 	info_nolog "${1}"
 	info_nolog_n "${2}"
 
-	__pause_tmp="$(mktemp)"
-	echo >> "${__pause_tmp}"
+	__pause_tmp="${STATEBASE}/pause.tmp"
+	echo > "${__pause_tmp}"
 	tmux pipe-pane -O -t ${PANE_INFO} "cat >> ${__pause_tmp}"
 	__pane_buf=
 	__wait=0
-- 
@@ -599,8 +599,8 @@ pause_continue() {
 	info_nolog "${1}"
 	info_nolog_n "${2}"
 
-	__pause_tmp="$(mktemp)"
-	echo >> "${__pause_tmp}"
+	__pause_tmp="${STATEBASE}/pause.tmp"
+	echo > "${__pause_tmp}"
 	tmux pipe-pane -O -t ${PANE_INFO} "cat >> ${__pause_tmp}"
 	__pane_buf=
 	__wait=0
-- 
2.37.3


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

* [PATCH v4 10/12] test: Store pcap files in $LOGDIR instead of /tmp
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (8 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 09/12] test: Move pause temporary file to state directory David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 11/12] test: Move pidfiles and nsholder sockets into state directory David Gibson
  2022-09-09  3:30 ` [PATCH v4 12/12] test: Move video processing files to $STATEBASE David Gibson
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 3460 bytes --]

The capture files are more or less a different form of log output from the
tests, so place them in $LOGDIR.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/lib/setup | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/test/lib/setup b/test/lib/setup
index b0420fb..87eb05a 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -47,7 +47,7 @@ setup_passt() {
 	#  10003                |      as server
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -94,7 +94,7 @@ setup_pasta() {
 	#  10003   spliced to init  |      as server
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -124,7 +124,7 @@ setup_passt_in_ns() {
 	#  10031    as server  | forwarded to guest |
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_with_passt.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_with_passt.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -142,7 +142,7 @@ setup_passt_in_ns() {
 	context_run ns "/sbin/dhclient -6 --no-pid ${__ifname}"
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_in_pasta.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_in_pasta.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -194,7 +194,7 @@ setup_two_guests() {
 	#  10005            |           |           |  as server |  to ns #2
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_1.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_1.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 	context_run_bg pasta_1 "./pasta ${__opts} -P pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ns1.hold hold"
@@ -202,7 +202,7 @@ setup_two_guests() {
 	context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pid}
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_2.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_2.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 	context_run_bg pasta_2 "./pasta ${__opts} -P pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ns2.hold hold"
@@ -220,7 +220,7 @@ setup_two_guests() {
 	context_run qemu_2 "/sbin/dhclient -6 --no-pid ${__ifname}"
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_1.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_1.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -228,7 +228,7 @@ setup_two_guests() {
 	sleep 1
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_2.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_2.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-- 
@@ -47,7 +47,7 @@ setup_passt() {
 	#  10003                |      as server
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -94,7 +94,7 @@ setup_pasta() {
 	#  10003   spliced to init  |      as server
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -124,7 +124,7 @@ setup_passt_in_ns() {
 	#  10031    as server  | forwarded to guest |
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_with_passt.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_with_passt.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -142,7 +142,7 @@ setup_passt_in_ns() {
 	context_run ns "/sbin/dhclient -6 --no-pid ${__ifname}"
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_in_pasta.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_in_pasta.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -194,7 +194,7 @@ setup_two_guests() {
 	#  10005            |           |           |  as server |  to ns #2
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_1.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_1.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 	context_run_bg pasta_1 "./pasta ${__opts} -P pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ns1.hold hold"
@@ -202,7 +202,7 @@ setup_two_guests() {
 	context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pid}
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/pasta_2.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_2.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 	context_run_bg pasta_2 "./pasta ${__opts} -P pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ns2.hold hold"
@@ -220,7 +220,7 @@ setup_two_guests() {
 	context_run qemu_2 "/sbin/dhclient -6 --no-pid ${__ifname}"
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_1.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_1.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
@@ -228,7 +228,7 @@ setup_two_guests() {
 	sleep 1
 
 	__opts=
-	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p /tmp/passt_2.pcap"
+	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/passt_2.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-- 
2.37.3


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

* [PATCH v4 11/12] test: Move pidfiles and nsholder sockets into state directory
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (9 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 10/12] test: Store pcap files in $LOGDIR instead of /tmp David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09  3:30 ` [PATCH v4 12/12] test: Move video processing files to $STATEBASE David Gibson
  11 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 11033 bytes --]

Currently they go in the passt source tree with a fixed names, which means
their presence can mess with subsequent test runs.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 .gitignore                |  1 -
 test/lib/setup            | 66 +++++++++++++++++++--------------------
 test/passt/shutdown       |  2 +-
 test/passt_in_ns/shutdown |  2 +-
 4 files changed, 35 insertions(+), 36 deletions(-)

diff --git a/.gitignore b/.gitignore
index 80967f3..d3d0e2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,5 @@
 /qrap
 /pasta.1
 /seccomp.h
-/*.pid
 /s*.json
 README.plain.md
diff --git a/test/lib/setup b/test/lib/setup
index 87eb05a..bda53f8 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -53,7 +53,7 @@ setup_passt() {
 
 	context_run passt "make clean"
 	context_run passt "make valgrind"
-	context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P passt.pid"
+	context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt ${__opts} -f -t 10001 -u 10001 -P ${STATESETUP}/passt.pid"
 	sleep 5
 
 	GUEST_CID=94557
@@ -67,7 +67,7 @@ setup_passt() {
 		'virtio-net.napi_tx=1"'					   \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"  \
 		" -netdev socket,fd=5,id=hostnet0"			   \
-		" -pidfile passt_qemu.pid"				   \
+		" -pidfile ${STATESETUP}/qemu.pid"			   \
 		" -device vhost-vsock-pci,guest-cid=$GUEST_CID"
 
 	context_setup_guest guest $GUEST_CID
@@ -81,8 +81,8 @@ setup_pasta() {
 
 	layout_pasta
 
-	context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ns.hold hold"
-	__target_pid=$(${NSHOLDER} ns.hold pid)
+	context_run_bg unshare "unshare -rUnpf ${NSHOLDER} ${STATESETUP}/ns.hold hold"
+	__target_pid=$(${NSHOLDER} ${STATESETUP}/ns.hold pid)
 
 	context_setup_nsenter ns -U -n -p --preserve-credentials -t ${__target_pid}
 
@@ -98,7 +98,7 @@ setup_pasta() {
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-	context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 -P passt.pid ${__target_pid}"
+	context_run_bg passt "./pasta ${__opts} -f -t 10002 -T 10003 -u 10002 -U 10003 -P ${STATESETUP}/passt.pid ${__target_pid}"
 	sleep 1
 }
 
@@ -128,9 +128,9 @@ setup_passt_in_ns() {
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-	context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P pasta.pid ${NSHOLDER} ns.hold hold"
+	context_run_bg pasta "./pasta ${__opts} -t 10001,10002,10011,10012 -T 10003,10013 -u 10001,10002,10011,10012 -U 10003,10013 -P ${STATESETUP}/pasta.pid ${NSHOLDER} ${STATESETUP}/ns.hold hold"
 	sleep 1
-	__ns_pid=$(${NSHOLDER} ns.hold pid)
+	__ns_pid=$(${NSHOLDER} ${STATESETUP}/ns.hold pid)
 
 	context_setup_nsenter qemu "-t ${__ns_pid} -U -n -p --preserve-credentials"
 	context_setup_nsenter ns "-t ${__ns_pid} -U -n -p --preserve-credentials"
@@ -149,11 +149,11 @@ setup_passt_in_ns() {
 	if [ ${VALGRIND} -eq 1 ]; then
 		context_run passt "make clean"
 		context_run passt "make valgrind"
-		context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid"
+		context_run_bg passt "valgrind --max-stackframe=$((4 * 1024 * 1024)) --trace-children=yes --vgdb=no --error-exitcode=1 --suppressions=test/valgrind.supp ./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P ${STATESETUP}/passt.pid"
 	else
 		context_run passt "make clean"
 		context_run passt "make"
-		context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P passt.pid"
+		context_run_bg passt "./passt -f ${__opts} -t 10001,10011,10021,10031 -u 10001,10011,10021,10031 -P ${STATESETUP}/passt.pid"
 	fi
 	sleep 5
 
@@ -169,7 +169,7 @@ setup_passt_in_ns() {
 		'virtio-net.napi_tx=1"'					   \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=524288" \
 		" -netdev socket,fd=5,id=hostnet0"			   \
-		' -pidfile passt_in_ns_qemu.pid'			   \
+		" -pidfile ${STATESETUP}/qemu.pid"			   \
 		" -device vhost-vsock-pci,guest-cid=$GUEST_CID"
 
 	context_setup_guest guest $GUEST_CID
@@ -197,16 +197,16 @@ setup_two_guests() {
 	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_1.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
-	context_run_bg pasta_1 "./pasta ${__opts} -P pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ns1.hold hold"
-	__ns1_pid=$(${NSHOLDER} ns1.hold pid)
+	context_run_bg pasta_1 "./pasta ${__opts} -P ${STATESETUP}/pasta_1.pid -t 10001,10002 -T 10003,10004 -u 10001,10002 -U 10003,10004 ${NSHOLDER} ${STATESETUP}/ns1.hold hold"
+	__ns1_pid=$(${NSHOLDER} ${STATESETUP}/ns1.hold pid)
 	context_setup_nsenter passt_1 -U -n -p --preserve-credentials -t ${__ns1_pid}
 
 	__opts=
 	[ ${PCAP} -eq 1 ] && __opts="${__opts} -p ${LOGDIR}/pasta_2.pcap"
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
-	context_run_bg pasta_2 "./pasta ${__opts} -P pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ns2.hold hold"
-	__ns2_pid=$(${NSHOLDER} ns2.hold pid)
+	context_run_bg pasta_2 "./pasta ${__opts} -P ${STATESETUP}/pasta_2.pid -t 10004,10005 -T 10003,10001 -u 10004,10005 -U 10003,10001 ${NSHOLDER} ${STATESETUP}/ns2.hold hold"
+	__ns2_pid=$(${NSHOLDER} ${STATESETUP}/ns2.hold pid)
 	context_setup_nsenter passt_2 -U -n -p --preserve-credentials -t ${__ns2_pid}
 
 	context_setup_nsenter qemu_1 -U -n -p --preserve-credentials -t ${__ns1_pid}
@@ -224,7 +224,7 @@ setup_two_guests() {
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-	context_run_bg passt_1 "./passt -P passt_1.pid -f ${__opts} -t 10001 -u 10001"
+	context_run_bg passt_1 "./passt -P ${STATESETUP}/passt_1.pid -f ${__opts} -t 10001 -u 10001"
 	sleep 1
 
 	__opts=
@@ -232,7 +232,7 @@ setup_two_guests() {
 	[ ${DEBUG} -eq 1 ] && __opts="${__opts} -d"
 	[ ${TRACE} -eq 1 ] && __opts="${__opts} --trace"
 
-	context_run_bg passt_2 "./passt -P passt_2.pid -f ${__opts} -t 10004 -u 10004"
+	context_run_bg passt_2 "./passt -P ${STATESETUP}/passt_2.pid -f ${__opts} -t 10004 -u 10004"
 
 	GUEST_1_CID=94557
 	context_run_bg qemu_1 './qrap 5 qemu-system-$(uname -m)'             \
@@ -245,7 +245,7 @@ setup_two_guests() {
 		'virtio-net.napi_tx=1"'					     \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"    \
 		" -netdev socket,fd=5,id=hostnet0"			     \
-		' -pidfile two_guests_qemu_1.pid'			     \
+		" -pidfile ${STATESETUP}/qemu_1.pid"			     \
 		" -device vhost-vsock-pci,guest-cid=$GUEST_1_CID"
 
 	GUEST_2_CID=94558
@@ -259,7 +259,7 @@ setup_two_guests() {
 		'virtio-net.napi_tx=1"'					     \
 		" -device virtio-net-pci,netdev=hostnet0,x-txburst=16384"    \
 		" -netdev socket,fd=5,id=hostnet0"			     \
-		' -pidfile two_guests_qemu_2.pid'			     \
+		" -pidfile ${STATESETUP}/qemu_2.pid"			     \
 		" -device vhost-vsock-pci,guest-cid=$GUEST_2_CID"
 
 	context_setup_guest guest_1 ${GUEST_1_CID}
@@ -290,9 +290,9 @@ teardown_distro() {
 
 # teardown_passt() - Kill qemu, remove passt PID file
 teardown_passt() {
-	kill $(cat passt_qemu.pid)
+	kill $(cat "${STATESETUP}/qemu.pid")
 
-	rm passt.pid
+	rm "${STATESETUP}/passt.pid"
 
 	teardown_context_watch ${PANE_HOST} host
 	teardown_context_watch ${PANE_PASST} passt
@@ -301,7 +301,7 @@ teardown_passt() {
 
 # teardown_passt() - Exit namespace, kill pasta process
 teardown_pasta() {
-	${NSHOLDER} ns.hold stop
+	${NSHOLDER} "${STATESETUP}/ns.hold" stop
 	context_wait unshare
 
 	teardown_context_watch ${PANE_HOST} host
@@ -311,13 +311,13 @@ teardown_pasta() {
 
 # teardown_passt_in_ns() - Exit namespace, kill qemu and pasta, remove pid file
 teardown_passt_in_ns() {
-	context_run ns kill $(cat passt_in_ns_qemu.pid)
+	context_run ns kill $(cat "${STATESETUP}/qemu.pid")
 	context_wait qemu
 
-	${NSHOLDER} ns.hold stop
+	${NSHOLDER} "${STATESETUP}/ns.hold" stop
 	context_wait pasta
 
-	rm passt.pid pasta.pid
+	rm "${STATESETUP}/passt.pid" "${STATESETUP}/pasta.pid"
 
 	teardown_context_watch ${PANE_HOST} host
 	teardown_context_watch ${PANE_PASST} pasta passt
@@ -327,23 +327,23 @@ teardown_passt_in_ns() {
 
 # teardown_two_guests() - Exit namespaces, kill qemu processes, passt and pasta
 teardown_two_guests() {
-	__ns1_pid=$(${NSHOLDER} ns1.hold pid)
-	__ns2_pid=$(${NSHOLDER} ns2.hold pid)
-	nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat two_guests_qemu_1.pid)
-	nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat two_guests_qemu_2.pid)
+	__ns1_pid=$(${NSHOLDER} "${STATESETUP}/ns1.hold" pid)
+	__ns2_pid=$(${NSHOLDER} "${STATESETUP}/ns2.hold" pid)
+	nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${STATESETUP}/qemu_1.pid")
+	nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESETUP}/qemu_2.pid")
 	context_wait qemu_1
 	context_wait qemu_2
 
-	nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat passt_1.pid)
-	nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat passt_2.pid)
+	nsenter -U -p --preserve-credentials -t ${__ns1_pid} kill $(cat "${STATESETUP}/passt_1.pid")
+	nsenter -U -p --preserve-credentials -t ${__ns2_pid} kill $(cat "${STATESETUP}/passt_2.pid")
 	context_wait passt_1
 	context_wait passt_2
-	${NSHOLDER} ns1.hold stop
-	${NSHOLDER} ns2.hold stop
+	${NSHOLDER} "${STATESETUP}/ns1.hold" stop
+	${NSHOLDER} "${STATESETUP}/ns2.hold" stop
 	context_wait pasta_1
 	context_wait pasta_2
 
-	rm -f passt_[12].pid pasta_[12].pid
+	rm -f "${STATESETUP}/passt__[12].pid" "${STATESETUP}/pasta_[12].pid"
 
 	teardown_context_watch ${PANE_HOST} host
 	teardown_context_watch ${PANE_GUEST_1} qemu_1 guest_1
diff --git a/test/passt/shutdown b/test/passt/shutdown
index ce90ea9..34ddb64 100644
--- a/test/passt/shutdown
+++ b/test/passt/shutdown
@@ -14,7 +14,7 @@
 
 test	shutdown: exit code
 
-hout	PASST_PID cat passt.pid
+hout	PASST_PID cat __STATESETUP__/passt.pid
 host	kill __PASST_PID__
 sleep	1
 passtw
diff --git a/test/passt_in_ns/shutdown b/test/passt_in_ns/shutdown
index abe9d6c..b602ec2 100644
--- a/test/passt_in_ns/shutdown
+++ b/test/passt_in_ns/shutdown
@@ -14,7 +14,7 @@
 
 test	shutdown: exit code
 
-nsout	PASST_PID cat passt.pid
+nsout	PASST_PID cat __STATESETUP__/passt.pid
 ns	kill __PASST_PID__
 sleep	1
 passtw
-- 
@@ -14,7 +14,7 @@
 
 test	shutdown: exit code
 
-nsout	PASST_PID cat passt.pid
+nsout	PASST_PID cat __STATESETUP__/passt.pid
 ns	kill __PASST_PID__
 sleep	1
 passtw
-- 
2.37.3


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

* [PATCH v4 12/12] test: Move video processing files to $STATEBASE
  2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
                   ` (10 preceding siblings ...)
  2022-09-09  3:30 ` [PATCH v4 11/12] test: Move pidfiles and nsholder sockets into state directory David Gibson
@ 2022-09-09  3:30 ` David Gibson
  2022-09-09 15:00   ` Stefano Brivio
  11 siblings, 1 reply; 20+ messages in thread
From: David Gibson @ 2022-09-09  3:30 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 3871 bytes --]

The asciinema video handling creates a number of temporary files (.uncat,
.start, .stop) which currently go into the source tree.  Put them in the
temporary state directory to avoid clutter.  Put the final processed video
into the test_logs/ directory, since it's essentially a test output
artefact.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/.gitignore |  3 ---
 test/lib/term   |  8 ++++----
 test/lib/video  | 19 ++++++++++---------
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/test/.gitignore b/test/.gitignore
index 0f91c7d..58c8cf2 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -6,9 +6,6 @@ QEMU_EFI.fd
 *.qcow2
 *.raw
 *.raw.xz
-*.uncut
-*.start
-*.stop
 *.js
 nsholder
 guest-key
diff --git a/test/lib/term b/test/lib/term
index d6869c7..5a391e6 100755
--- a/test/lib/term
+++ b/test/lib/term
@@ -643,12 +643,12 @@ run_term() {
 
 	if [ ${CI} -eq 1 ]; then
 		printf '\e[8;50;240t'
-		asciinema rec --overwrite ci.uncut -c "$TMUX /bin/sh -c './ci from_term'"
-		video_postprocess ci.uncut
+		asciinema rec --overwrite "${STATEBASE}/ci.uncut" -c "$TMUX /bin/sh -c './ci from_term'"
+		video_postprocess "${STATEBASE}/ci.uncut"
 	elif [ ${DEMO} -eq 1 ]; then
 		printf '\e[8;40;130t'
-		asciinema rec --overwrite demo.uncut -c "$TMUX /bin/sh -c './run_demo from_term'"
-		video_postprocess demo.uncut
+		asciinema rec --overwrite "${STATEBASE}/demo.uncut" -c "$TMUX /bin/sh -c './run_demo from_term'"
+		video_postprocess "${STATEBASE}/demo.uncut"
 	else
 		$TMUX /bin/sh -c './run from_term'
 	fi
diff --git a/test/lib/video b/test/lib/video
index f609abf..915a42f 100755
--- a/test/lib/video
+++ b/test/lib/video
@@ -77,8 +77,8 @@ video_start() {
 	VIDEO_START_SECONDS=$(sed -n 's/\([0-9]*\).[0-9]* [0-9]*.[0-9]*/\1/p' /proc/uptime)
 
 	sync
-	[ ${DEMO} -eq 1 ] && tail -1 "${BASEPATH}/demo.uncut" > "${BASEPATH}/${VIDEO_NAME}.start"
-	[ ${CI} -eq 1 ] && tail -1 "${BASEPATH}/ci.uncut" > "${BASEPATH}/${VIDEO_NAME}.start"
+	[ ${DEMO} -eq 1 ] && tail -1 "${STATEBASE}/demo.uncut" > "${STATEBASE}/${VIDEO_NAME}.start"
+	[ ${CI} -eq 1 ] && tail -1 "${STATEBASE}/ci.uncut" > "${STATEBASE}/${VIDEO_NAME}.start"
 	sync
 
 	tmux refresh-client
@@ -89,8 +89,8 @@ video_stop() {
 	tmux refresh-client
 
 	sync
-	[ ${DEMO} -eq 1 ] && tail -1 "${BASEPATH}/demo.uncut" > "${BASEPATH}/${VIDEO_NAME}.stop"
-	[ ${CI} -eq 1 ] && tail -1 "${BASEPATH}/ci.uncut" > "${BASEPATH}/${VIDEO_NAME}.stop"
+	[ ${DEMO} -eq 1 ] && tail -1 "${STATEBASE}/demo.uncut" > "${STATEBASE}/${VIDEO_NAME}.stop"
+	[ ${CI} -eq 1 ] && tail -1 "${STATEBASE}/ci.uncut" > "${STATEBASE}/${VIDEO_NAME}.stop"
 	sync
 
 	sed -i 's/^.*$/&\\/g' "${BASEPATH}/${VIDEO_NAME}.js"
@@ -108,12 +108,13 @@ video_postprocess() {
 		[ -z "${__header}" ] && __header="${__l}" && continue
 
 		if [ -z "${__cast_name}" ]; then
-			for __cast_cut in *.start; do
+		        for __cast_cut in "${STATEBASE}/"*.start; do
 				[ "${__l}" != "$(cat "${__cast_cut}")" ] && continue
-				__cast_name="${__cast_cut%.start}"
+				__cast_name="$(basename "${__cast_cut}")"
+                                __cast_name="${__cast_name%.start}"
 				__cast_offset=
-				__stop_line="$(cat ${__cast_name}.stop)"
-				echo "${__header}" > "${__cast_name}.cast"
+				__stop_line="$(cat "${STATEBASE}/${__cast_name}.stop")"
+				echo "${__header}" > "${LOGDIR}/${__cast_name}.cast"
 				break
 			done
 			continue
@@ -125,7 +126,7 @@ video_postprocess() {
 		__l_rest="${__l#*.}"
 		[ -z "${__cast_offset}" ] && __cast_offset=${__l_offset}
 		__l_offset=$((__l_offset - __cast_offset))
-		printf '[%s.%s\n' "${__l_offset}" "${__l_rest}" >> "${__cast_name}".cast
+		printf '[%s.%s\n' "${__l_offset}" "${__l_rest}" >> "${LOGDIR}/${__cast_name}".cast
 	done
 	unset IFS
 }
-- 
@@ -77,8 +77,8 @@ video_start() {
 	VIDEO_START_SECONDS=$(sed -n 's/\([0-9]*\).[0-9]* [0-9]*.[0-9]*/\1/p' /proc/uptime)
 
 	sync
-	[ ${DEMO} -eq 1 ] && tail -1 "${BASEPATH}/demo.uncut" > "${BASEPATH}/${VIDEO_NAME}.start"
-	[ ${CI} -eq 1 ] && tail -1 "${BASEPATH}/ci.uncut" > "${BASEPATH}/${VIDEO_NAME}.start"
+	[ ${DEMO} -eq 1 ] && tail -1 "${STATEBASE}/demo.uncut" > "${STATEBASE}/${VIDEO_NAME}.start"
+	[ ${CI} -eq 1 ] && tail -1 "${STATEBASE}/ci.uncut" > "${STATEBASE}/${VIDEO_NAME}.start"
 	sync
 
 	tmux refresh-client
@@ -89,8 +89,8 @@ video_stop() {
 	tmux refresh-client
 
 	sync
-	[ ${DEMO} -eq 1 ] && tail -1 "${BASEPATH}/demo.uncut" > "${BASEPATH}/${VIDEO_NAME}.stop"
-	[ ${CI} -eq 1 ] && tail -1 "${BASEPATH}/ci.uncut" > "${BASEPATH}/${VIDEO_NAME}.stop"
+	[ ${DEMO} -eq 1 ] && tail -1 "${STATEBASE}/demo.uncut" > "${STATEBASE}/${VIDEO_NAME}.stop"
+	[ ${CI} -eq 1 ] && tail -1 "${STATEBASE}/ci.uncut" > "${STATEBASE}/${VIDEO_NAME}.stop"
 	sync
 
 	sed -i 's/^.*$/&\\/g' "${BASEPATH}/${VIDEO_NAME}.js"
@@ -108,12 +108,13 @@ video_postprocess() {
 		[ -z "${__header}" ] && __header="${__l}" && continue
 
 		if [ -z "${__cast_name}" ]; then
-			for __cast_cut in *.start; do
+		        for __cast_cut in "${STATEBASE}/"*.start; do
 				[ "${__l}" != "$(cat "${__cast_cut}")" ] && continue
-				__cast_name="${__cast_cut%.start}"
+				__cast_name="$(basename "${__cast_cut}")"
+                                __cast_name="${__cast_name%.start}"
 				__cast_offset=
-				__stop_line="$(cat ${__cast_name}.stop)"
-				echo "${__header}" > "${__cast_name}.cast"
+				__stop_line="$(cat "${STATEBASE}/${__cast_name}.stop")"
+				echo "${__header}" > "${LOGDIR}/${__cast_name}.cast"
 				break
 			done
 			continue
@@ -125,7 +126,7 @@ video_postprocess() {
 		__l_rest="${__l#*.}"
 		[ -z "${__cast_offset}" ] && __cast_offset=${__l_offset}
 		__l_offset=$((__l_offset - __cast_offset))
-		printf '[%s.%s\n' "${__l_offset}" "${__l_rest}" >> "${__cast_name}".cast
+		printf '[%s.%s\n' "${__l_offset}" "${__l_rest}" >> "${LOGDIR}/${__cast_name}".cast
 	done
 	unset IFS
 }
-- 
2.37.3


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

* Re: [PATCH v4 08/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives
  2022-09-09  3:30 ` [PATCH v4 08/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives David Gibson
@ 2022-09-09 15:00   ` Stefano Brivio
  2022-09-10  7:44     ` David Gibson
  0 siblings, 1 reply; 20+ messages in thread
From: Stefano Brivio @ 2022-09-09 15:00 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 4216 bytes --]

On Fri,  9 Sep 2022 13:30:24 +1000
David Gibson <david(a)gibson.dropbear.id.au> wrote:

> Instead of using the 'temp' and 'tempdir' DSL directives to create
> temporary files, use fixed paths relative to __STATEDIR__.  This has two
> advantages:
>   1) The files are automatically cleaned up if the tests fail (and even if
>      that doesn't work they're easier to clean up manuall)
>   2) When debugging tests it's easier to figure out which of the temporary
>      files are relevant to whatever's going wrong
> 
> Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
>
> [...]
>
> +++ b/test/passt/udp
> @@ -15,9 +15,9 @@ gtools	socat tee grep cat ip jq md5sum cut
>  htools	printf dd socat tee grep cat ip jq md5sum cut
>  
>  test	UDP/IPv4: host to guest
> -temp	TEMP
> -temp	SC_PID
> -guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > __SC_PID__) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
> +set	TEMP __STATEDIR__/data
> +set	SC_PID __STATEDIR__/socat.pid
> +guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))

Here it's sc.pid,

>  sleep	1
>  host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
>  host	socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001
> diff --git a/test/passt_in_ns/tcp b/test/passt_in_ns/tcp
> index 5ec95e8..a2cb667 100644
> --- a/test/passt_in_ns/tcp
> +++ b/test/passt_in_ns/tcp
> @@ -16,7 +16,7 @@ htools	dd socat ip jq md5sum cut
>  nstools	socat ip jq md5sum cut
>  
>  test	TCP/IPv4: host to guest: big transfer
> -temp	TEMP_BIG
> +set	TEMP_BIG __STATEDIR__/big.img
>  guestb	socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc
>  sleep	1
>  host	dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__
> @@ -27,7 +27,7 @@ gout	GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
>  check	[ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
>  
>  test	TCP/IPv4: host to ns: big transfer
> -temp	TEMP_NS_BIG
> +set	TEMP_NS_BIG __STATEDIR__/big_ns.img
>  nsb	socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc
>  host	socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002
>  nsw
> @@ -82,7 +82,7 @@ gout	GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
>  check	[ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
>  
>  test	TCP/IPv4: host to guest: small transfer
> -temp	TEMP_SMALL
> +set	TEMP_SMALL __STATEDIR__/small.img
>  guestb	socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc
>  sleep	1
>  host	dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__
> @@ -93,7 +93,7 @@ gout	GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1
>  check	[ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
>  
>  test	TCP/IPv4: host to ns: small transfer
> -temp	TEMP_NS_SMALL
> +set	TEMP_NS_SMALL __STATEDIR__/small_ns.img
>  nsb	socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc
>  host	socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002
>  nsw
> diff --git a/test/passt_in_ns/udp b/test/passt_in_ns/udp
> index c22a68f..3b1e521 100644
> --- a/test/passt_in_ns/udp
> +++ b/test/passt_in_ns/udp
> @@ -16,8 +16,8 @@ nstools	socat tee grep cat ip jq md5sum cut
>  htools	printf dd socat tee grep cat ip jq md5sum cut
>  
>  test	UDP/IPv4: host to guest
> -temp	TEMP
> -temp	SC_PID
> +set	TEMP __STATEDIR__/data
> +set	SC_PID __STATEDIR__/socat.pid
>  guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))

here, too,

>  sleep	1
>  host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
> @@ -28,7 +28,7 @@ gout	GUEST_MD5 md5sum test.bin | cut -d' ' -f1
>  check	[ "__GUEST_MD5__" = "__MD5__" ]
>  
>  test	UDP/IPv4: host to ns
> -temp	TEMP_NS
> +set	TEMP_NS __STATEDIR__/data_ns
>  nsb	(socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))

...here it's __SC_PID__.

It looks a bit random to me, but anyway all those go away with your
(much needed) patch "test: Simpler termination handling for UDP tests",
so I'm also fine to apply it like that.

-- 
Stefano


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

* Re: [PATCH v4 12/12] test: Move video processing files to $STATEBASE
  2022-09-09  3:30 ` [PATCH v4 12/12] test: Move video processing files to $STATEBASE David Gibson
@ 2022-09-09 15:00   ` Stefano Brivio
  2022-09-10  7:45     ` David Gibson
  0 siblings, 1 reply; 20+ messages in thread
From: Stefano Brivio @ 2022-09-09 15:00 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

On Fri,  9 Sep 2022 13:30:28 +1000
David Gibson <david(a)gibson.dropbear.id.au> wrote:

> The asciinema video handling creates a number of temporary files (.uncat,
> .start, .stop) which currently go into the source tree.  Put them in the
> temporary state directory to avoid clutter.  Put the final processed video
> into the test_logs/ directory, since it's essentially a test output
> artefact.

This needs an update in hooks/pre-push in any case, but... I wouldn't
mix those. The current directory listing at:
  https://passt.top/builds/latest/test/

is sort of usable right now, and if I just scp everything into there,
it wouldn't be anymore.

Maybe we could move the cast files to test_logs/web/, then scp:

- test_logs/* (files only) to latest/test/
- test_logs/web/* to latest/web/

instead?

-- 
Stefano


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

* Re: [PATCH v4 08/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives
  2022-09-09 15:00   ` Stefano Brivio
@ 2022-09-10  7:44     ` David Gibson
  2022-09-10 20:41       ` Stefano Brivio
  0 siblings, 1 reply; 20+ messages in thread
From: David Gibson @ 2022-09-10  7:44 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 4925 bytes --]

On Fri, Sep 09, 2022 at 05:00:02PM +0200, Stefano Brivio wrote:
> On Fri,  9 Sep 2022 13:30:24 +1000
> David Gibson <david(a)gibson.dropbear.id.au> wrote:
> 
> > Instead of using the 'temp' and 'tempdir' DSL directives to create
> > temporary files, use fixed paths relative to __STATEDIR__.  This has two
> > advantages:
> >   1) The files are automatically cleaned up if the tests fail (and even if
> >      that doesn't work they're easier to clean up manuall)
> >   2) When debugging tests it's easier to figure out which of the temporary
> >      files are relevant to whatever's going wrong
> > 
> > Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
> >
> > [...]
> >
> > +++ b/test/passt/udp
> > @@ -15,9 +15,9 @@ gtools	socat tee grep cat ip jq md5sum cut
> >  htools	printf dd socat tee grep cat ip jq md5sum cut
> >  
> >  test	UDP/IPv4: host to guest
> > -temp	TEMP
> > -temp	SC_PID
> > -guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > __SC_PID__) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
> > +set	TEMP __STATEDIR__/data
> > +set	SC_PID __STATEDIR__/socat.pid
> > +guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))
> 
> Here it's sc.pid,
> 
> >  sleep	1
> >  host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
> >  host	socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001
> > diff --git a/test/passt_in_ns/tcp b/test/passt_in_ns/tcp
> > index 5ec95e8..a2cb667 100644
> > --- a/test/passt_in_ns/tcp
> > +++ b/test/passt_in_ns/tcp
> > @@ -16,7 +16,7 @@ htools	dd socat ip jq md5sum cut
> >  nstools	socat ip jq md5sum cut
> >  
> >  test	TCP/IPv4: host to guest: big transfer
> > -temp	TEMP_BIG
> > +set	TEMP_BIG __STATEDIR__/big.img
> >  guestb	socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc
> >  sleep	1
> >  host	dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__
> > @@ -27,7 +27,7 @@ gout	GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
> >  check	[ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
> >  
> >  test	TCP/IPv4: host to ns: big transfer
> > -temp	TEMP_NS_BIG
> > +set	TEMP_NS_BIG __STATEDIR__/big_ns.img
> >  nsb	socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc
> >  host	socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002
> >  nsw
> > @@ -82,7 +82,7 @@ gout	GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
> >  check	[ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
> >  
> >  test	TCP/IPv4: host to guest: small transfer
> > -temp	TEMP_SMALL
> > +set	TEMP_SMALL __STATEDIR__/small.img
> >  guestb	socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc
> >  sleep	1
> >  host	dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__
> > @@ -93,7 +93,7 @@ gout	GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1
> >  check	[ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
> >  
> >  test	TCP/IPv4: host to ns: small transfer
> > -temp	TEMP_NS_SMALL
> > +set	TEMP_NS_SMALL __STATEDIR__/small_ns.img
> >  nsb	socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc
> >  host	socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002
> >  nsw
> > diff --git a/test/passt_in_ns/udp b/test/passt_in_ns/udp
> > index c22a68f..3b1e521 100644
> > --- a/test/passt_in_ns/udp
> > +++ b/test/passt_in_ns/udp
> > @@ -16,8 +16,8 @@ nstools	socat tee grep cat ip jq md5sum cut
> >  htools	printf dd socat tee grep cat ip jq md5sum cut
> >  
> >  test	UDP/IPv4: host to guest
> > -temp	TEMP
> > -temp	SC_PID
> > +set	TEMP __STATEDIR__/data
> > +set	SC_PID __STATEDIR__/socat.pid
> >  guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))
> 
> here, too,
> 
> >  sleep	1
> >  host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
> > @@ -28,7 +28,7 @@ gout	GUEST_MD5 md5sum test.bin | cut -d' ' -f1
> >  check	[ "__GUEST_MD5__" = "__MD5__" ]
> >  
> >  test	UDP/IPv4: host to ns
> > -temp	TEMP_NS
> > +set	TEMP_NS __STATEDIR__/data_ns
> >  nsb	(socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
> 
> ...here it's __SC_PID__.
> 
> It looks a bit random to me, but anyway all those go away with your
> (much needed) patch "test: Simpler termination handling for UDP tests",
> so I'm also fine to apply it like that.

It's __SC_PID__ on host and namespace, sc.pid for the guest.  The
guest doesn't share a filesystem so __STATEDIR__ isn't meeaningful
there.

In any case they both go away with the test cleanup that goes along
with the handling of 0-length UDP packets.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v4 12/12] test: Move video processing files to $STATEBASE
  2022-09-09 15:00   ` Stefano Brivio
@ 2022-09-10  7:45     ` David Gibson
  2022-09-10 20:41       ` Stefano Brivio
  0 siblings, 1 reply; 20+ messages in thread
From: David Gibson @ 2022-09-10  7:45 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]

On Fri, Sep 09, 2022 at 05:00:35PM +0200, Stefano Brivio wrote:
> On Fri,  9 Sep 2022 13:30:28 +1000
> David Gibson <david(a)gibson.dropbear.id.au> wrote:
> 
> > The asciinema video handling creates a number of temporary files (.uncat,
> > .start, .stop) which currently go into the source tree.  Put them in the
> > temporary state directory to avoid clutter.  Put the final processed video
> > into the test_logs/ directory, since it's essentially a test output
> > artefact.
> 
> This needs an update in hooks/pre-push in any case, but... I wouldn't

Uh.. right.  The hooks aren't part of the repo contents, though, so I
can't change that.

> mix those. The current directory listing at:
>   https://passt.top/builds/latest/test/
> 
> is sort of usable right now, and if I just scp everything into there,
> it wouldn't be anymore.
> 
> Maybe we could move the cast files to test_logs/web/, then scp:
> 
> - test_logs/* (files only) to latest/test/
> - test_logs/web/* to latest/web/
> 
> instead?

Sure, we could do that.  It's really up to you what you want the
workflow to be.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v4 12/12] test: Move video processing files to $STATEBASE
  2022-09-10  7:45     ` David Gibson
@ 2022-09-10 20:41       ` Stefano Brivio
  2022-09-13  4:41         ` David Gibson
  0 siblings, 1 reply; 20+ messages in thread
From: Stefano Brivio @ 2022-09-10 20:41 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 2088 bytes --]

On Sat, 10 Sep 2022 17:45:48 +1000
David Gibson <david(a)gibson.dropbear.id.au> wrote:

> On Fri, Sep 09, 2022 at 05:00:35PM +0200, Stefano Brivio wrote:
> > On Fri,  9 Sep 2022 13:30:28 +1000
> > David Gibson <david(a)gibson.dropbear.id.au> wrote:
> >   
> > > The asciinema video handling creates a number of temporary files (.uncat,
> > > .start, .stop) which currently go into the source tree.  Put them in the
> > > temporary state directory to avoid clutter.  Put the final processed video
> > > into the test_logs/ directory, since it's essentially a test output
> > > artefact.  
> > 
> > This needs an update in hooks/pre-push in any case, but... I wouldn't  
> 
> Uh.. right.  The hooks aren't part of the repo contents, though, so I
> can't change that.

They are, in some sense:

  $ git log --oneline -1 hooks/pre-push
  ba72c83 hooks: Copy .webp diagram versions too

I then copy that single hook to .git whenever I clone a repository, as
suggested in the comment:

  $ grep .git hooks/pre-push
  # cp hooks/pre-push .git/hooks/pre-push

...this should eventually become a server-side post-receive hook, I
guess, using a temporary branch for testing and then forwarding the
updates to master if the tests pass.

But I haven't looked yet into headless asciinema captures -- I guess
it's doable and I've been doing something similar with Xvfb, it might
need some extra setup in the test scripts though.

> > mix those. The current directory listing at:
> >   https://passt.top/builds/latest/test/
> > 
> > is sort of usable right now, and if I just scp everything into there,
> > it wouldn't be anymore.
> > 
> > Maybe we could move the cast files to test_logs/web/, then scp:
> > 
> > - test_logs/* (files only) to latest/test/
> > - test_logs/web/* to latest/web/
> > 
> > instead?  
> 
> Sure, we could do that.  It's really up to you what you want the
> workflow to be.

Hmm, yes, that would be my preferred option at the moment. I can also
take care of updating the hook when I apply your patches.

-- 
Stefano


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

* Re: [PATCH v4 08/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives
  2022-09-10  7:44     ` David Gibson
@ 2022-09-10 20:41       ` Stefano Brivio
  0 siblings, 0 replies; 20+ messages in thread
From: Stefano Brivio @ 2022-09-10 20:41 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 5101 bytes --]

On Sat, 10 Sep 2022 17:44:03 +1000
David Gibson <david(a)gibson.dropbear.id.au> wrote:

> On Fri, Sep 09, 2022 at 05:00:02PM +0200, Stefano Brivio wrote:
> > On Fri,  9 Sep 2022 13:30:24 +1000
> > David Gibson <david(a)gibson.dropbear.id.au> wrote:
> >   
> > > Instead of using the 'temp' and 'tempdir' DSL directives to create
> > > temporary files, use fixed paths relative to __STATEDIR__.  This has two
> > > advantages:
> > >   1) The files are automatically cleaned up if the tests fail (and even if
> > >      that doesn't work they're easier to clean up manuall)
> > >   2) When debugging tests it's easier to figure out which of the temporary
> > >      files are relevant to whatever's going wrong
> > > 
> > > Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
> > >
> > > [...]
> > >
> > > +++ b/test/passt/udp
> > > @@ -15,9 +15,9 @@ gtools	socat tee grep cat ip jq md5sum cut
> > >  htools	printf dd socat tee grep cat ip jq md5sum cut
> > >  
> > >  test	UDP/IPv4: host to guest
> > > -temp	TEMP
> > > -temp	SC_PID
> > > -guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > __SC_PID__) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))
> > > +set	TEMP __STATEDIR__/data
> > > +set	SC_PID __STATEDIR__/socat.pid
> > > +guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))  
> > 
> > Here it's sc.pid,
> >   
> > >  sleep	1
> > >  host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
> > >  host	socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001
> > > diff --git a/test/passt_in_ns/tcp b/test/passt_in_ns/tcp
> > > index 5ec95e8..a2cb667 100644
> > > --- a/test/passt_in_ns/tcp
> > > +++ b/test/passt_in_ns/tcp
> > > @@ -16,7 +16,7 @@ htools	dd socat ip jq md5sum cut
> > >  nstools	socat ip jq md5sum cut
> > >  
> > >  test	TCP/IPv4: host to guest: big transfer
> > > -temp	TEMP_BIG
> > > +set	TEMP_BIG __STATEDIR__/big.img
> > >  guestb	socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc
> > >  sleep	1
> > >  host	dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__
> > > @@ -27,7 +27,7 @@ gout	GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
> > >  check	[ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
> > >  
> > >  test	TCP/IPv4: host to ns: big transfer
> > > -temp	TEMP_NS_BIG
> > > +set	TEMP_NS_BIG __STATEDIR__/big_ns.img
> > >  nsb	socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc
> > >  host	socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002
> > >  nsw
> > > @@ -82,7 +82,7 @@ gout	GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
> > >  check	[ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
> > >  
> > >  test	TCP/IPv4: host to guest: small transfer
> > > -temp	TEMP_SMALL
> > > +set	TEMP_SMALL __STATEDIR__/small.img
> > >  guestb	socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc
> > >  sleep	1
> > >  host	dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__
> > > @@ -93,7 +93,7 @@ gout	GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1
> > >  check	[ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
> > >  
> > >  test	TCP/IPv4: host to ns: small transfer
> > > -temp	TEMP_NS_SMALL
> > > +set	TEMP_NS_SMALL __STATEDIR__/small_ns.img
> > >  nsb	socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc
> > >  host	socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002
> > >  nsw
> > > diff --git a/test/passt_in_ns/udp b/test/passt_in_ns/udp
> > > index c22a68f..3b1e521 100644
> > > --- a/test/passt_in_ns/udp
> > > +++ b/test/passt_in_ns/udp
> > > @@ -16,8 +16,8 @@ nstools	socat tee grep cat ip jq md5sum cut
> > >  htools	printf dd socat tee grep cat ip jq md5sum cut
> > >  
> > >  test	UDP/IPv4: host to guest
> > > -temp	TEMP
> > > -temp	SC_PID
> > > +set	TEMP __STATEDIR__/data
> > > +set	SC_PID __STATEDIR__/socat.pid
> > >  guestb	(socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid))  
> > 
> > here, too,
> >   
> > >  sleep	1
> > >  host	dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__
> > > @@ -28,7 +28,7 @@ gout	GUEST_MD5 md5sum test.bin | cut -d' ' -f1
> > >  check	[ "__GUEST_MD5__" = "__MD5__" ]
> > >  
> > >  test	UDP/IPv4: host to ns
> > > -temp	TEMP_NS
> > > +set	TEMP_NS __STATEDIR__/data_ns
> > >  nsb	(socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__))  
> > 
> > ...here it's __SC_PID__.
> > 
> > It looks a bit random to me, but anyway all those go away with your
> > (much needed) patch "test: Simpler termination handling for UDP tests",
> > so I'm also fine to apply it like that.  
> 
> It's __SC_PID__ on host and namespace, sc.pid for the guest.  The
> guest doesn't share a filesystem so __STATEDIR__ isn't meeaningful
> there.

Oh, right, I missed that.

> In any case they both go away with the test cleanup that goes along
> with the handling of 0-length UDP packets.

-- 
Stefano


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

* Re: [PATCH v4 12/12] test: Move video processing files to $STATEBASE
  2022-09-10 20:41       ` Stefano Brivio
@ 2022-09-13  4:41         ` David Gibson
  0 siblings, 0 replies; 20+ messages in thread
From: David Gibson @ 2022-09-13  4:41 UTC (permalink / raw)
  To: passt-dev

[-- Attachment #1: Type: text/plain, Size: 2851 bytes --]

On Sat, Sep 10, 2022 at 10:41:19PM +0200, Stefano Brivio wrote:
> On Sat, 10 Sep 2022 17:45:48 +1000
> David Gibson <david(a)gibson.dropbear.id.au> wrote:
> 
> > On Fri, Sep 09, 2022 at 05:00:35PM +0200, Stefano Brivio wrote:
> > > On Fri,  9 Sep 2022 13:30:28 +1000
> > > David Gibson <david(a)gibson.dropbear.id.au> wrote:
> > >   
> > > > The asciinema video handling creates a number of temporary files (.uncat,
> > > > .start, .stop) which currently go into the source tree.  Put them in the
> > > > temporary state directory to avoid clutter.  Put the final processed video
> > > > into the test_logs/ directory, since it's essentially a test output
> > > > artefact.  
> > > 
> > > This needs an update in hooks/pre-push in any case, but... I wouldn't  
> > 
> > Uh.. right.  The hooks aren't part of the repo contents, though, so I
> > can't change that.
> 
> They are, in some sense:
> 
>   $ git log --oneline -1 hooks/pre-push
>   ba72c83 hooks: Copy .webp diagram versions too
> 
> I then copy that single hook to .git whenever I clone a repository, as
> suggested in the comment:

Huh, I completely missed that there.

>   $ grep .git hooks/pre-push
>   # cp hooks/pre-push .git/hooks/pre-push
> 
> ...this should eventually become a server-side post-receive hook, I
> guess, using a temporary branch for testing and then forwarding the
> updates to master if the tests pass.

Right.  It wouldn't make sense for me or anyone else to have this as a
pre-push hook.

> But I haven't looked yet into headless asciinema captures -- I guess
> it's doable and I've been doing something similar with Xvfb, it might
> need some extra setup in the test scripts though.

Right.  It should be ok as long as $TERM and the stty settings match.
Obviously a pty will have to be allocated for the command, which I
suspect asciinema rec must do anyway.  It might be as simple as
setting the --cols and --rows options.

> > > mix those. The current directory listing at:
> > >   https://passt.top/builds/latest/test/
> > > 
> > > is sort of usable right now, and if I just scp everything into there,
> > > it wouldn't be anymore.
> > > 
> > > Maybe we could move the cast files to test_logs/web/, then scp:
> > > 
> > > - test_logs/* (files only) to latest/test/
> > > - test_logs/web/* to latest/web/
> > > 
> > > instead?  
> > 
> > Sure, we could do that.  It's really up to you what you want the
> > workflow to be.
> 
> Hmm, yes, that would be my preferred option at the moment. I can also
> take care of updating the hook when I apply your patches.

Ok, I've done that in the next spin.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2022-09-13  4:41 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09  3:30 [PATCH v4 00/12] Improve handling of test temporary files David Gibson
2022-09-09  3:30 ` [PATCH v4 01/12] test: Group tests by context then protocol, rather than the reverse David Gibson
2022-09-09  3:30 ` [PATCH v4 02/12] test: Remove unused variable FFMPEG_PID_FILE David Gibson
2022-09-09  3:30 ` [PATCH v4 03/12] test: Actually run cleanup function David Gibson
2022-09-09  3:30 ` [PATCH v4 04/12] test: Create common state directories for temporary files David Gibson
2022-09-09  3:30 ` [PATCH v4 05/12] test: Move passt_test_log_pipe to state directory David Gibson
2022-09-09  3:30 ` [PATCH v4 06/12] test: Move context temporary files to state dir David Gibson
2022-09-09  3:30 ` [PATCH v4 07/12] test: Dont regnerate small test file in pasta/tcp David Gibson
2022-09-09  3:30 ` [PATCH v4 08/12] test: Use paths in __STATEDIR__ instead of 'temp' and 'tempdir' directives David Gibson
2022-09-09 15:00   ` Stefano Brivio
2022-09-10  7:44     ` David Gibson
2022-09-10 20:41       ` Stefano Brivio
2022-09-09  3:30 ` [PATCH v4 09/12] test: Move pause temporary file to state directory David Gibson
2022-09-09  3:30 ` [PATCH v4 10/12] test: Store pcap files in $LOGDIR instead of /tmp David Gibson
2022-09-09  3:30 ` [PATCH v4 11/12] test: Move pidfiles and nsholder sockets into state directory David Gibson
2022-09-09  3:30 ` [PATCH v4 12/12] test: Move video processing files to $STATEBASE David Gibson
2022-09-09 15:00   ` Stefano Brivio
2022-09-10  7:45     ` David Gibson
2022-09-10 20:41       ` Stefano Brivio
2022-09-13  4:41         ` David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).