[PATCH 2/3] virshtest: Add tests for '--help'

Peter Krempa posted 3 patches 6 months, 1 week ago
[PATCH 2/3] virshtest: Add tests for '--help'
Posted by Peter Krempa 6 months, 1 week ago
Add test cases for help handling.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/virshtest.c                   |  3 ++
 tests/virshtestdata/help-option.in  |  4 ++
 tests/virshtestdata/help-option.out | 64 +++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)
 create mode 100644 tests/virshtestdata/help-option.in
 create mode 100644 tests/virshtestdata/help-option.out

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 03d499b759..b86c39285a 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -309,6 +309,9 @@ mymain(void)
     DO_TEST("#unbalanced; 'quotes\"\necho a # b");
     DO_TEST("\\# ignored;echo a\n'#also' ignored");

+    /* test of the --help option handling */
+    DO_TEST_SCRIPT("help-option", NULL, VIRSH_DEFAULT, "-q");
+
     /* test of splitting in vshStringToArray */
     DO_TEST_SCRIPT("echo-split", NULL, VIRSH_DEFAULT, "-q");

diff --git a/tests/virshtestdata/help-option.in b/tests/virshtestdata/help-option.in
new file mode 100644
index 0000000000..655952eefb
--- /dev/null
+++ b/tests/virshtestdata/help-option.in
@@ -0,0 +1,4 @@
+help echo
+echo --help
+echo --help=data
+echo --help data
diff --git a/tests/virshtestdata/help-option.out b/tests/virshtestdata/help-option.out
new file mode 100644
index 0000000000..5b7510b612
--- /dev/null
+++ b/tests/virshtestdata/help-option.out
@@ -0,0 +1,64 @@
+  NAME
+    echo - echo arguments. Used for internal testing.
+
+  SYNOPSIS
+    echo [--shell] [--xml] [--split] [--err] [--prefix <string>] [<string>]...
+
+  DESCRIPTION
+    Echo back arguments, possibly with quoting. Used for internal testing.
+
+  OPTIONS
+    --shell          escape for shell use
+    --xml            escape for XML use
+    --split          split each argument on ','; ',,' is an escape sequence
+    --err            output to stderr
+    --prefix <string>  prefix the message
+    [--string] <string>...  arguments to echo
+  NAME
+    echo - echo arguments. Used for internal testing.
+
+  SYNOPSIS
+    echo [--shell] [--xml] [--split] [--err] [--prefix <string>] [<string>]...
+
+  DESCRIPTION
+    Echo back arguments, possibly with quoting. Used for internal testing.
+
+  OPTIONS
+    --shell          escape for shell use
+    --xml            escape for XML use
+    --split          split each argument on ','; ',,' is an escape sequence
+    --err            output to stderr
+    --prefix <string>  prefix the message
+    [--string] <string>...  arguments to echo
+  NAME
+    echo - echo arguments. Used for internal testing.
+
+  SYNOPSIS
+    echo [--shell] [--xml] [--split] [--err] [--prefix <string>] [<string>]...
+
+  DESCRIPTION
+    Echo back arguments, possibly with quoting. Used for internal testing.
+
+  OPTIONS
+    --shell          escape for shell use
+    --xml            escape for XML use
+    --split          split each argument on ','; ',,' is an escape sequence
+    --err            output to stderr
+    --prefix <string>  prefix the message
+    [--string] <string>...  arguments to echo
+  NAME
+    echo - echo arguments. Used for internal testing.
+
+  SYNOPSIS
+    echo [--shell] [--xml] [--split] [--err] [--prefix <string>] [<string>]...
+
+  DESCRIPTION
+    Echo back arguments, possibly with quoting. Used for internal testing.
+
+  OPTIONS
+    --shell          escape for shell use
+    --xml            escape for XML use
+    --split          split each argument on ','; ',,' is an escape sequence
+    --err            output to stderr
+    --prefix <string>  prefix the message
+    [--string] <string>...  arguments to echo
-- 
2.45.0