Ultimately, I'd like to add a unit test covering our recent fix for
handling globals from consecutive -c, but let's start with a simple
test that --help output is sane. Sanity includes a mention of the man
page for more details (similar to nbdkit --help, although I couldn't
figure out how to make python's argparse output that sentence last).
---
python/nbdsh.py | 3 ++-
sh/Makefile.am | 9 ++++++---
sh/test-help.sh | 32 ++++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 4 deletions(-)
create mode 100755 sh/test-help.sh
diff --git a/python/nbdsh.py b/python/nbdsh.py
index 553e632..117c824 100644
--- a/python/nbdsh.py
+++ b/python/nbdsh.py
@@ -23,7 +23,8 @@ def shell():
import nbd
- description = '''Network Block Device (NBD) shell'''
+ description = '''Network Block Device (NBD) shell. Please read the
+ nbdsh(1) manual page for full usage.'''
parser = argparse.ArgumentParser (prog='nbdsh', description=description)
parser.add_argument ('--connect',
help="connect to NBD URI")
diff --git a/sh/Makefile.am b/sh/Makefile.am
index 2e04e46..2e9a047 100644
--- a/sh/Makefile.am
+++ b/sh/Makefile.am
@@ -21,6 +21,7 @@ EXTRA_DIST = \
nbdsh.pod \
examples/LICENSE-FOR-EXAMPLES \
examples/hexdump.sh \
+ test-help.sh \
$(NULL)
if HAVE_PYTHON
@@ -40,8 +41,10 @@ nbdsh.1: nbdsh.pod $(top_builddir)/podwrapper.pl
endif HAVE_POD
-if HAVE_NBDKIT
-
TESTS_ENVIRONMENT = LIBNBD_DEBUG=1
LOG_COMPILER = $(top_builddir)/run
-TESTS =
+TESTS = test-help.sh
+
+if HAVE_NBDKIT
+
+TESTS +=
endif HAVE_NBDKIT
diff --git a/sh/test-help.sh b/sh/test-help.sh
new file mode 100755
index 0000000..6ed1c9c
--- /dev/null
+++ b/sh/test-help.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# nbd client library in userspace
+# Copyright (C) 2019 Red Hat Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Test that nbdsh --help looks sane.
+
+fail=0
+output=$(nbdsh --help)
+if [ $? != 0 ]; then
+ echo "$0: unexpected exit status"
+ fail=1
+fi
+if [[ ! ( "$output" =~ "usage:" && "$output" =~
"manual page" ) ]]; then
+ echo "$0: unexpected output"
+ fail=1
+fi
+echo "$output"
+exit $fail
--
2.21.0