[PATCH 05/13] virshtest: Add test cases for command completion helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add both single invocations as well as a script containing the same
commands.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 tests/virshtest.c                             | 37 ++++++++++
 .../completion-arg-full-argv-next.out         |  2 +
 .../completion-arg-full-argv.out              |  2 +
 .../completion-arg-full-bool-next.out         |  7 ++
 .../completion-arg-full-bool.out              |  2 +
 .../completion-arg-full-string-next.out       |  7 ++
 .../completion-arg-full-string.out            |  2 +
 .../virshtestdata/completion-arg-partial.out  |  4 ++
 .../completion-arg-positional-empty.out       |  3 +
 ...completion-arg-positional-partial-next.out |  2 +
 .../completion-arg-positional-partial.out     |  2 +
 tests/virshtestdata/completion-args.out       |  7 ++
 .../completion-argv-multiple-next.out         | 25 +++++++
 ...mpletion-argv-multiple-positional-next.out | 25 +++++++
 .../completion-argv-multiple-positional.out   |  2 +
 .../completion-argv-multiple.out              |  2 +
 .../completion-command-complete.out           |  2 +
 tests/virshtestdata/completion-command.out    |  2 +
 tests/virshtestdata/completion.in             | 16 +++++
 tests/virshtestdata/completion.out            | 71 +++++++++++++++++++
 20 files changed, 222 insertions(+)
 create mode 100644 tests/virshtestdata/completion-arg-full-argv-next.out
 create mode 100644 tests/virshtestdata/completion-arg-full-argv.out
 create mode 100644 tests/virshtestdata/completion-arg-full-bool-next.out
 create mode 100644 tests/virshtestdata/completion-arg-full-bool.out
 create mode 100644 tests/virshtestdata/completion-arg-full-string-next.out
 create mode 100644 tests/virshtestdata/completion-arg-full-string.out
 create mode 100644 tests/virshtestdata/completion-arg-partial.out
 create mode 100644 tests/virshtestdata/completion-arg-positional-empty.out
 create mode 100644 tests/virshtestdata/completion-arg-positional-partial-next.out
 create mode 100644 tests/virshtestdata/completion-arg-positional-partial.out
 create mode 100644 tests/virshtestdata/completion-args.out
 create mode 100644 tests/virshtestdata/completion-argv-multiple-next.out
 create mode 100644 tests/virshtestdata/completion-argv-multiple-positional-next.out
 create mode 100644 tests/virshtestdata/completion-argv-multiple-positional.out
 create mode 100644 tests/virshtestdata/completion-argv-multiple.out
 create mode 100644 tests/virshtestdata/completion-command-complete.out
 create mode 100644 tests/virshtestdata/completion-command.out
 create mode 100644 tests/virshtestdata/completion.in
 create mode 100644 tests/virshtestdata/completion.out

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 14a96f2d35..869ecbb358 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -342,6 +342,43 @@ mymain(void)
                  "checkpoint-create test --redefine checkpoint-c2.xml ;"
                  "checkpoint-info test c2");

+    DO_TEST_FULL("completion-command", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "ech");
+    DO_TEST_FULL("completion-command-complete", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "echo");
+    DO_TEST_FULL("completion-args", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "echo", "");
+    DO_TEST_FULL("completion-arg-partial", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "echo", "--xm", "--s");
+    DO_TEST_FULL("completion-arg-full-bool", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "echo", "--nonexistant-arg", "--xml");
+    DO_TEST_FULL("completion-arg-full-bool-next", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "echo", "--nonexistant-arg", "--xml", "");
+    DO_TEST_FULL("completion-arg-full-string", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "echo", "--nonexistant-arg", "--prefix");
+    DO_TEST_FULL("completion-arg-full-string-next", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "echo", "--nonexistant-arg", "--prefix", "");
+    DO_TEST_FULL("completion-arg-full-argv", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "domstats", "--domain");
+    DO_TEST_FULL("completion-arg-full-argv-next", NULL, VIRSH_DEFAULT,
+                 "complete", "--", "domstats", "--domain", "");
+    DO_TEST_FULL("completion-argv-multiple", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "domstats", "--domain", "fc", "--domain", "fv");
+    DO_TEST_FULL("completion-argv-multiple-next", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "domstats", "--domain", "fv", "--domain", "fc", "");
+    DO_TEST_FULL("completion-argv-multiple-positional", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "domstats", "--domain", "fc", "fv");
+    DO_TEST_FULL("completion-argv-multiple-positional-next", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "domstats", "--domain", "fc", "fv", "");
+    DO_TEST_FULL("completion-arg-positional-empty", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "domstate", "");
+    DO_TEST_FULL("completion-arg-positional-partial", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "domstate", "fv");
+    DO_TEST_FULL("completion-arg-positional-partial-next", NULL, VIRSH_CUSTOM,
+                 "complete", "--", "domstate", "fv", "");
+
+    DO_TEST_SCRIPT("completion", NULL, VIRSH_DEFAULT);
+
     if (virTestRun("read-big-pipe", testVirshPipe, NULL) < 0)
         ret = -1;

diff --git a/tests/virshtestdata/completion-arg-full-argv-next.out b/tests/virshtestdata/completion-arg-full-argv-next.out
new file mode 100644
index 0000000000..76e579ae4c
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-full-argv-next.out
@@ -0,0 +1,2 @@
+test
+
diff --git a/tests/virshtestdata/completion-arg-full-argv.out b/tests/virshtestdata/completion-arg-full-argv.out
new file mode 100644
index 0000000000..2d795410c2
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-full-argv.out
@@ -0,0 +1,2 @@
+--domain
+
diff --git a/tests/virshtestdata/completion-arg-full-bool-next.out b/tests/virshtestdata/completion-arg-full-bool-next.out
new file mode 100644
index 0000000000..3fc6e035d0
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-full-bool-next.out
@@ -0,0 +1,7 @@
+--shell
+--xml
+--split
+--err
+--prefix
+--string
+
diff --git a/tests/virshtestdata/completion-arg-full-bool.out b/tests/virshtestdata/completion-arg-full-bool.out
new file mode 100644
index 0000000000..511582e4c9
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-full-bool.out
@@ -0,0 +1,2 @@
+--xml
+
diff --git a/tests/virshtestdata/completion-arg-full-string-next.out b/tests/virshtestdata/completion-arg-full-string-next.out
new file mode 100644
index 0000000000..3fc6e035d0
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-full-string-next.out
@@ -0,0 +1,7 @@
+--shell
+--xml
+--split
+--err
+--prefix
+--string
+
diff --git a/tests/virshtestdata/completion-arg-full-string.out b/tests/virshtestdata/completion-arg-full-string.out
new file mode 100644
index 0000000000..b29473399a
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-full-string.out
@@ -0,0 +1,2 @@
+--prefix
+
diff --git a/tests/virshtestdata/completion-arg-partial.out b/tests/virshtestdata/completion-arg-partial.out
new file mode 100644
index 0000000000..cc2820d9a8
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-partial.out
@@ -0,0 +1,4 @@
+--shell
+--split
+--string
+
diff --git a/tests/virshtestdata/completion-arg-positional-empty.out b/tests/virshtestdata/completion-arg-positional-empty.out
new file mode 100644
index 0000000000..cf2bdf1586
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-positional-empty.out
@@ -0,0 +1,3 @@
+--domain
+--reason
+
diff --git a/tests/virshtestdata/completion-arg-positional-partial-next.out b/tests/virshtestdata/completion-arg-positional-partial-next.out
new file mode 100644
index 0000000000..d9e9cd0a05
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-positional-partial-next.out
@@ -0,0 +1,2 @@
+--reason
+
diff --git a/tests/virshtestdata/completion-arg-positional-partial.out b/tests/virshtestdata/completion-arg-positional-partial.out
new file mode 100644
index 0000000000..4289a724d9
--- /dev/null
+++ b/tests/virshtestdata/completion-arg-positional-partial.out
@@ -0,0 +1,2 @@
+fv0
+
diff --git a/tests/virshtestdata/completion-args.out b/tests/virshtestdata/completion-args.out
new file mode 100644
index 0000000000..3fc6e035d0
--- /dev/null
+++ b/tests/virshtestdata/completion-args.out
@@ -0,0 +1,7 @@
+--shell
+--xml
+--split
+--err
+--prefix
+--string
+
diff --git a/tests/virshtestdata/completion-argv-multiple-next.out b/tests/virshtestdata/completion-argv-multiple-next.out
new file mode 100644
index 0000000000..b29a060eff
--- /dev/null
+++ b/tests/virshtestdata/completion-argv-multiple-next.out
@@ -0,0 +1,25 @@
+--state
+--cpu-total
+--balloon
+--vcpu
+--interface
+--block
+--perf
+--iothread
+--memory
+--dirtyrate
+--vm
+--list-active
+--list-inactive
+--list-persistent
+--list-transient
+--list-running
+--list-paused
+--list-shutoff
+--list-other
+--raw
+--enforce
+--backing
+--nowait
+--domain
+
diff --git a/tests/virshtestdata/completion-argv-multiple-positional-next.out b/tests/virshtestdata/completion-argv-multiple-positional-next.out
new file mode 100644
index 0000000000..b29a060eff
--- /dev/null
+++ b/tests/virshtestdata/completion-argv-multiple-positional-next.out
@@ -0,0 +1,25 @@
+--state
+--cpu-total
+--balloon
+--vcpu
+--interface
+--block
+--perf
+--iothread
+--memory
+--dirtyrate
+--vm
+--list-active
+--list-inactive
+--list-persistent
+--list-transient
+--list-running
+--list-paused
+--list-shutoff
+--list-other
+--raw
+--enforce
+--backing
+--nowait
+--domain
+
diff --git a/tests/virshtestdata/completion-argv-multiple-positional.out b/tests/virshtestdata/completion-argv-multiple-positional.out
new file mode 100644
index 0000000000..4289a724d9
--- /dev/null
+++ b/tests/virshtestdata/completion-argv-multiple-positional.out
@@ -0,0 +1,2 @@
+fv0
+
diff --git a/tests/virshtestdata/completion-argv-multiple.out b/tests/virshtestdata/completion-argv-multiple.out
new file mode 100644
index 0000000000..4289a724d9
--- /dev/null
+++ b/tests/virshtestdata/completion-argv-multiple.out
@@ -0,0 +1,2 @@
+fv0
+
diff --git a/tests/virshtestdata/completion-command-complete.out b/tests/virshtestdata/completion-command-complete.out
new file mode 100644
index 0000000000..40cf7bd7c0
--- /dev/null
+++ b/tests/virshtestdata/completion-command-complete.out
@@ -0,0 +1,2 @@
+echo
+
diff --git a/tests/virshtestdata/completion-command.out b/tests/virshtestdata/completion-command.out
new file mode 100644
index 0000000000..40cf7bd7c0
--- /dev/null
+++ b/tests/virshtestdata/completion-command.out
@@ -0,0 +1,2 @@
+echo
+
diff --git a/tests/virshtestdata/completion.in b/tests/virshtestdata/completion.in
new file mode 100644
index 0000000000..cd2594609f
--- /dev/null
+++ b/tests/virshtestdata/completion.in
@@ -0,0 +1,16 @@
+complete -- ech
+complete -- echo
+complete -- echo ''
+complete -- echo --xm --s
+complete -- echo --nonexistant-arg --xml
+complete -- echo --nonexistant-arg --xml ''
+complete -- echo --nonexistant-arg --prefix
+complete -- echo --nonexistant-arg --prefix ''
+complete -- domstats --domain
+complete -- domstats --domain ''
+complete -- domstats --domain f
+complete -- domstats --domain fc --domain fv
+complete -- domstats --domain fv --domain fc ''
+complete -- domstats --domain fc fv
+complete -- domstate ''
+complete -- domstate fv
diff --git a/tests/virshtestdata/completion.out b/tests/virshtestdata/completion.out
new file mode 100644
index 0000000000..9cceb088e3
--- /dev/null
+++ b/tests/virshtestdata/completion.out
@@ -0,0 +1,71 @@
+echo
+
+echo
+
+--shell
+--xml
+--split
+--err
+--prefix
+--string
+
+--shell
+--split
+--string
+
+--xml
+
+--shell
+--xml
+--split
+--err
+--prefix
+--string
+
+--prefix
+
+--shell
+--xml
+--split
+--err
+--prefix
+--string
+
+--domain
+
+test
+
+
+
+--state
+--cpu-total
+--balloon
+--vcpu
+--interface
+--block
+--perf
+--iothread
+--memory
+--dirtyrate
+--vm
+--list-active
+--list-inactive
+--list-persistent
+--list-transient
+--list-running
+--list-paused
+--list-shutoff
+--list-other
+--raw
+--enforce
+--backing
+--nowait
+--domain
+
+
+--domain
+--reason
+
+
+
+## Exit code: 1
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux