From nobody Mon Feb 9 10:32:27 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1713532547414299.4330109454595; Fri, 19 Apr 2024 06:15:47 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 572311DED; Fri, 19 Apr 2024 09:15:46 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 609B71DC4; Fri, 19 Apr 2024 09:05:57 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id AEB4E1D91; Fri, 19 Apr 2024 09:05:44 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 874C31C67 for ; Fri, 19 Apr 2024 09:05:40 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-RWy83x7vPZi8I0wRbTIjYw-1; Fri, 19 Apr 2024 09:05:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69372800CAC for ; Fri, 19 Apr 2024 13:05:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id D270E2166B34 for ; Fri, 19 Apr 2024 13:05:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: RWy83x7vPZi8I0wRbTIjYw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 05/13] virshtest: Add test cases for command completion helper Date: Fri, 19 Apr 2024 15:05:23 +0200 Message-ID: <121a2728ff514dfed2777eb07837b9f20bb34da8.1713531810.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: KITJXUQP2B4DYYGTKTY36LLFHYY23PVK X-Message-ID-Hash: KITJXUQP2B4DYYGTKTY36LLFHYY23PVK X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713532548056100001 Add both single invocations as well as a script containing the same commands. Signed-off-by: Peter Krempa --- 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-n= ext.out create mode 100644 tests/virshtestdata/completion-arg-positional-partial.o= ut 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_C= USTOM, + "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_CUS= TOM, + "complete", "--", "domstate", "fv", ""); + + DO_TEST_SCRIPT("completion", NULL, VIRSH_DEFAULT); + if (virTestRun("read-big-pipe", testVirshPipe, NULL) < 0) ret =3D -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/virsh= testdata/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/virsh= testdata/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/test= s/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/vir= shtestdata/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/virshte= stdata/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/test= s/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/te= sts/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.o= ut 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/virsh= testdata/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/vi= rshtestdata/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/virshtestda= ta/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/comple= tion.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/compl= etion.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 --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org