Displaying 20 results from an estimated 219 matches for "cleanup_fn".
2018 Sep 13
0
[PATCH v2 nbdkit 4/5] tests: Use a generic cleanup mechanism instead of explicit trap.
...changed, 73 insertions(+), 157 deletions(-)
diff --git a/tests/functions.sh.in b/tests/functions.sh.in
index 62fdfe5..42e3925 100644
--- a/tests/functions.sh.in
+++ b/tests/functions.sh.in
@@ -32,6 +32,31 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
+# cleanup_fn f [args]
+#
+# A generic trap handling function. This runs the function f + args
+# when the script exits for any reason.
+declare -a _cleanup_hook
+cleanup_fn ()
+{
+ _cleanup_hook[${#_cleanup_hook[@]}]="$@"
+}
+
+_run_cleanup_hooks ()
+{
+ status=$?
+ set +e
+ trap '...
2018 Sep 13
8
[PATCH v2 nbdkit 0/5] tests: Move common functions into tests/functions.sh
v1 was here:
https://www.redhat.com/archives/libguestfs/2018-September/msg00057.html
v2:
- Fix tab vs spaces in configure.ac.
- To generate list of plugins, use printf instead of xargs.
- Use 'source ./functions.sh' instead of 'source functions'.
- functions.sh: Consistent quoting in foreach_plugin function.
- functions.sh: Change the contract of start_nbdkit so it
2018 Sep 13
0
[PATCH v2 nbdkit 5/5] tests: Add a helper function which waits for nbdkit to start up.
...{1..10}; do
+ if test -f "$pidfile"; then
+ break
+ fi
+ sleep 1
+ done
+ if ! test -f "$pidfile"; then
+ echo "$0: start_nbdkit: PID file $pidfile was not created"
+ exit 1
+ fi
+
+ # Kill nbdkit on exit.
+ cleanup_fn kill "$(cat $pidfile)"
+}
+
# foreach_plugin f
#
# For each plugin that was built, call test function f with the plugin
diff --git a/tests/test-blocksize.sh b/tests/test-blocksize.sh
index 21b55b9..aa3cc13 100755
--- a/tests/test-blocksize.sh
+++ b/tests/test-blocksize.sh
@@ -50,14 +50...
2019 Jan 23
2
[PATCH v2 nbdkit] tests: Add generic requires.
v1 was here:
https://www.redhat.com/archives/libguestfs/2019-January/thread.html#00198
For v2 I changed most existing prerequisite tests to use the new
mechanism.
I only changed simple tests. There are a few more complex tests that
don't fit the “requires model” and those are not changed.
I normalized qemu-io/qemu-img testing to always use the --version
flag, where previously we used a mix
2019 Jan 23
0
[PATCH v2 nbdkit] tests: Add generic ‘requires’ function for test prerequisites.
...-git a/tests/test-data-7E.sh b/tests/test-data-7E.sh
index e27984f..2e48e1b 100755
--- a/tests/test-data-7E.sh
+++ b/tests/test-data-7E.sh
@@ -38,16 +38,12 @@ source ./functions.sh
set -e
set -x
+requires qemu-io --version
+
files="data-7E.out data-7E.pid data-7E.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit.
start_nbdkit -P data-7E.pid -U data-7E.sock --export= \
--filter=partition \
diff --git a/tests/test-data-base64.sh b/tes...
2018 Sep 13
1
Re: [PATCH v2 nbdkit 4/5] tests: Use a generic cleanup mechanism instead of explicit trap.
On 9/13/18 11:09 AM, Richard W.M. Jones wrote:
> Thanks: Eric Blake for the suggestion here:
> https://www.redhat.com/archives/libguestfs/2018-September/msg00069.html
> ---
I'm glad the idea worked!
> +# cleanup_fn f [args]
> +#
> +# A generic trap handling function. This runs the function f + args
Not just functions, but any command name...
> +# when the script exits for any reason.
> +declare -a _cleanup_hook
> +cleanup_fn ()
> +{
> + _cleanup_hook[${#_cleanup_hook[@]}]="$@&q...
2019 Jan 23
2
Re: [PATCH v2 nbdkit] tests: Add generic ‘requires’ function for test prerequisites.
...ot;
> + echo "$0: test prerequisite is missing or not working"
> + exit 77
> + }
> +}
Updated function looks good.
> +++ b/tests/test-ip.sh
> @@ -37,26 +37,17 @@
> source ./functions.sh
> set -e
>
> -rm -f ip.pid ipv4.out ipv6.out
> -cleanup_fn rm -f ip.pid ipv4.out ipv6.out
> +requires ss --version
> +requires ip -V
> +requires qemu-img --version
>
> -# Don't fail if certain commands aren't available.
> -if ! ss --version; then
> - echo "$0: 'ss' command not available"
> - exit 77...
2020 Mar 20
2
[nbdkit PATCH] tests: Don't strand hung nbdkit processes
...not supported"; then
- echo "$0: IPv6 loopback is not available, skipping this test"
- exit 77
+ echo "$0: IPv6 loopback is not available, skipping this test"
+ exit 77
fi
}
@@ -139,7 +139,32 @@ start_nbdkit ()
fi
# Kill nbdkit on exit.
- cleanup_fn kill "$(cat "$pidfile")"
+ cleanup_fn kill_nbdkit "$(cat "$pidfile")"
+}
+
+# kill_nbdkit pid
+#
+# End the nbkdit process that created pidfile. Exit this script with an
+# error if nbdkit does not gracefully shutdown in a timely manner.
+kill_nbdkit ()
+...
2020 Aug 03
5
[libnbd PATCH 0/4] More nbdinfo fixes
This rounds up the remaining bugs that I originally identified in:
https://www.redhat.com/archives/libguestfs/2020-July/msg00153.html
Eric Blake (4):
api: Permit export list APIs when Connected
info: Support --list with serializing servers
info: Fix --json output when list size != 1
info: Permit --size --json
generator/API.ml | 6 +++---
info/info-list-json.sh | 9 +++++++++
2020 Jul 29
0
[libnbd PATCH 2/2] info: Expose description in list mode
...fo/info-list.sh | 3 ++-
info/nbdinfo.c | 21 ++++++++++++++++-----
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/info/info-list-json.sh b/info/info-list-json.sh
index 3845875..af29064 100755
--- a/info/info-list-json.sh
+++ b/info/info-list-json.sh
@@ -33,7 +33,7 @@ cleanup_fn rm -f $img $out $pid $sock
rm -f $img $out $pid $sock
truncate -s 1M $img
-qemu-nbd -t --socket=$sock --pid-file=$pid -x "hello" $img &
+qemu-nbd -t --socket=$sock --pid-file=$pid -x "hello" -D "world" $img &
cleanup_fn kill $!
# Wait for qemu-nbd to star...
2019 Jan 23
0
Re: [PATCH v2 nbdkit] tests: Add generic ‘requires’ function for test prerequisites.
On Wed, Jan 23, 2019 at 10:02:18AM -0600, Eric Blake wrote:
> > +++ b/tests/test-ip.sh
> > @@ -37,26 +37,17 @@
> > source ./functions.sh
> > set -e
> >
> > -rm -f ip.pid ipv4.out ipv6.out
> > -cleanup_fn rm -f ip.pid ipv4.out ipv6.out
> > +requires ss --version
> > +requires ip -V
> > +requires qemu-img --version
> >
> > -# Don't fail if certain commands aren't available.
> > -if ! ss --version; then
> > - echo "$0: 'ss' command no...
2019 Jan 23
2
[PATCH nbdkit] tests: Add generic requires function.
I only did a handful of the tests to demonstrate the point. If the
patch approach is accepted then I'll do the remainder of the tests in v2.
Rich.
2019 Jan 23
0
[PATCH nbdkit] tests: Add generic ‘requires’ function to testing test prerequisites.
...ests/test-memory-largest.sh
index a6c269e..50708f9 100755
--- a/tests/test-memory-largest.sh
+++ b/tests/test-memory-largest.sh
@@ -37,16 +37,12 @@
source ./functions.sh
set -e
+requires qemu-io --help
+
files="memory-largest.out memory-largest.pid memory-largest.sock"
rm -f $files
cleanup_fn rm -f $files
-# Test that qemu-io works
-if ! qemu-io --help >/dev/null; then
- echo "$0: missing or broken qemu-io"
- exit 77
-fi
-
# Run nbdkit with memory plugin.
# size = 2^63-1
start_nbdkit -P memory-largest.pid -U memory-largest.sock \
diff --git a/tests/test-partition...
2019 Oct 01
3
[PATCH libnbd 0/2] Change qemu-nbd interop tests to use socket activation.
Now that we have implemented systemd socket activation, we can use
this to run qemu-nbd in tests.
The first patch leaves some dead code around (the -DSERVE_OVER_TCP=1
path). It's possible we might want to use this to test against a
putative future NBD server that only supports TCP, but on the other
hand maybe we should just remove it.
Tests & valgrind still pass for me.
Rich.
2023 Mar 21
2
[libnbd PATCH v4 0/2] lib/utils: introduce async-signal-safe execvpe()
...t -e
+set -ex
# Determine the absolute pathname of the execvpe helper binary. The "realpath"
# utility is not in POSIX, but Linux, FreeBSD and OpenBSD all have it.
@@ -155,7 +155,7 @@ success()
# Create a temporary directory and change the working directory to it.
tmpd=$(mktemp -d)
-cleanup_fn rm -r -- "$tmpd"
+#cleanup_fn rm -r -- "$tmpd"
cd "$tmpd"
# If the "file" parameter of execvpe() is an empty string, then we must fail --
$ podman build -f ci/containers/alpine-edge.Dockerfile -t libnbd-alpine-edge
$ podman run -it --rm --userns=keep-id -...
2023 Mar 21
2
[libnbd PATCH v4 0/2] lib/utils: introduce async-signal-safe execvpe()
...he absolute pathname of the execvpe helper binary. The "realpath"
> # utility is not in POSIX, but Linux, FreeBSD and OpenBSD all have it.
> @@ -155,7 +155,7 @@ success()
>
> # Create a temporary directory and change the working directory to it.
> tmpd=$(mktemp -d)
> -cleanup_fn rm -r -- "$tmpd"
> +#cleanup_fn rm -r -- "$tmpd"
> cd "$tmpd"
>
> # If the "file" parameter of execvpe() is an empty string, then we must fail --
>
> $ podman build -f ci/containers/alpine-edge.Dockerfile -t libnbd-alpine-edge
> $ podma...
2023 Mar 22
1
[libnbd PATCH v4 0/2] lib/utils: introduce async-signal-safe execvpe()
...ecvpe helper binary. The "realpath"
> > # utility is not in POSIX, but Linux, FreeBSD and OpenBSD all have it.
> > @@ -155,7 +155,7 @@ success()
> >
> > # Create a temporary directory and change the working directory to it.
> > tmpd=$(mktemp -d)
> > -cleanup_fn rm -r -- "$tmpd"
> > +#cleanup_fn rm -r -- "$tmpd"
> > cd "$tmpd"
> >
> > # If the "file" parameter of execvpe() is an empty string, then we must fail --
> >
> > $ podman build -f ci/containers/alpine-edge.Dockerfile -t l...
2020 Feb 13
0
[PATCH nbdkit 2/2] vddk: Drive library loading from libdir parameter.
...eal.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# nbdkit
-# Copyright (C) 2018-2019 Red Hat Inc.
+# Copyright (C) 2018-2020 Red Hat Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -51,15 +51,7 @@ cleanup_fn rm -f $files
qemu-img create -f vmdk test-vddk-real.vmdk 100M
-export old_ld_library_path="$LD_LIBRARY_PATH"
-export LD_LIBRARY_PATH="$vddkdir/lib64:$LD_LIBRARY_PATH"
-
nbdkit -f -v -U - \
--filter=readahead \
vddk libdir="$vddkdir" file=test-vddk...
2019 Sep 30
1
Re: [PATCH nbdkit v2 4/4] info: Add tests for time, uptime and conntime modes.
...nged, 204 insertions(+)
>
> +# Test the info plugin with mode=conntime.
> +
> +source ./functions.sh
> +set -e
> +set -x
> +
> +requires nbdsh --version
> +
> +sock=`mktemp -u`
> +files="info-conntime.out info-conntime.pid $sock"
> +rm -f $files
> +cleanup_fn rm -f $files
> +
> +# Run nbdkit.
> +start_nbdkit -P info-conntime.pid -U $sock info mode=conntime
> +
For conntime, is it worth testing 2 separate connections:
Connection 1: connect, sleep 1, read
Connection 2: connect, read
where the delta read by connection 2 should be less than t...
2020 Feb 13
2
[PATCH nbdkit 1/2] vddk: Delay loading VDDK until config_complete.
We were previously dlopen-ing it in the load() method. This is very
early and in particular means that the only possible way to configure
where we find the library is through environment variables and not
through config parameters. Also it's not necessary as we don't call
any functions from the library (such as VixDiskLib_InitEx) until
config_complete.
This change is neutral refactoring