Richard W.M. Jones
2023-Oct-09 14:51 UTC
[Libguestfs] [nbdkit] Two POSIX questions for you ...
So one thing we could do for this test is to require (for the test)
that /bin/sh is bash, something like the patch below. I was only able
to test this in the positive case.
diff --git a/tests/test-log-script-info.sh b/tests/test-log-script-info.sh
index fa9b2ed32..d65f6415d 100755
--- a/tests/test-log-script-info.sh
+++ b/tests/test-log-script-info.sh
@@ -38,6 +38,10 @@ requires_run
requires_nbdinfo
requires_filter log
+# This test implicitly assumes /bin/sh is bash, see:
+# https://listman.redhat.com/archives/libguestfs/2023-October/032767.html
+BASH_VERSION=no requires /bin/sh -c 'test "x$BASH_VERSION" !=
"xno"'
+
if ! nbdinfo --help | grep -- --map ; then
echo "$0: nbdinfo --map option required to run this test"
exit 77
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html
On 10/9/23 16:51, Richard W.M. Jones wrote:> > So one thing we could do for this test is to require (for the test) > that /bin/sh is bash, something like the patch below. I was only able > to test this in the positive case. > > diff --git a/tests/test-log-script-info.sh b/tests/test-log-script-info.sh > index fa9b2ed32..d65f6415d 100755 > --- a/tests/test-log-script-info.sh > +++ b/tests/test-log-script-info.sh > @@ -38,6 +38,10 @@ requires_run > requires_nbdinfo > requires_filter log > > +# This test implicitly assumes /bin/sh is bash, see: > +# https://listman.redhat.com/archives/libguestfs/2023-October/032767.html > +BASH_VERSION=no requires /bin/sh -c 'test "x$BASH_VERSION" != "xno"' > + > if ! nbdinfo --help | grep -- --map ; then > echo "$0: nbdinfo --map option required to run this test" > exit 77 > >Clever! Reviewed-by: Laszlo Ersek <lersek at redhat.com> You can test it with "dash" BTW (it must be available in Fedora, because it is available in EPEL-9): BASH_VERSION=no /bin/bash -c 'test "x$BASH_VERSION" != "xno"; echo $?' BASH_VERSION=no /bin/dash -c 'test "x$BASH_VERSION" != "xno"; echo $?' Laszlo