From nobody Mon Feb 9 17:24:14 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 1711194402217806.0009840168018; Sat, 23 Mar 2024 04:46:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EDBA31CE6; Sat, 23 Mar 2024 07:46:40 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 09785217A; Sat, 23 Mar 2024 07:34:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7AE3E1F4A; Sat, 23 Mar 2024 07:34:22 -0400 (EDT) Received: from mx1.osci.io (polly.osci.io [8.43.85.229]) (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 5EB5D1B74 for ; Sat, 23 Mar 2024 07:32:52 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id E74D2223D8; Fri, 22 Mar 2024 13:56:37 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by mx1.osci.io (Postfix) with ESMTPS id 556D1223D6 for ; Fri, 22 Mar 2024 13:56:37 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-jjaDM1qWPceepDeavkZxaw-1; Fri, 22 Mar 2024 13:56:35 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 E8A7C1C01714 for ; Fri, 22 Mar 2024 17:56:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBFAA492BD0 for ; Fri, 22 Mar 2024 17:56:33 +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,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: jjaDM1qWPceepDeavkZxaw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 16/35] virshtest: Adapt argument parsing tests from 'virsh-optparse' Date: Fri, 22 Mar 2024 18:55:54 +0100 Message-ID: <92fc3fc1db39fd63f6fa7454990aee5928a4d6bb.1711129973.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: ANRYDDAP7IIVMJVN7BTIOEJY75F7IV2E X-Message-ID-Hash: ANRYDDAP7IIVMJVN7BTIOEJY75F7IV2E X-MailFrom: SRS0=Xa5W=K4=redhat.com=pkrempa@osci.io 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: 1711194404020100001 Move the argument parsing tests excercising 'virsh setvcpus' from 'virsh-optparse' to 'virshtest'. Signed-off-by: Peter Krempa --- tests/virsh-optparse | 29 ------- tests/virshtest.c | 3 + tests/virshtestdata/argument-assignment.in | 15 ++++ tests/virshtestdata/argument-assignment.out | 91 +++++++++++++++++++++ 4 files changed, 109 insertions(+), 29 deletions(-) create mode 100644 tests/virshtestdata/argument-assignment.in create mode 100644 tests/virshtestdata/argument-assignment.out diff --git a/tests/virsh-optparse b/tests/virsh-optparse index 3fe38b2931..77e754d73a 100755 --- a/tests/virsh-optparse +++ b/tests/virsh-optparse @@ -28,39 +28,10 @@ if test "$VERBOSE" =3D yes; then $VIRSH --version fi -cat <<\EOF > exp-out || framework_failure - -setvcpus: trying as domain NAME -setvcpus: count(optdata): 2 -setvcpus: domain(optdata): test -setvcpus: found option : test -EOF - fail=3D0 test_url=3Dtest:///default -for args in \ - 'test 2' \ - '--domain test 2' \ - '--domain=3Dtest 2' \ - 'test --count 2' \ - 'test --count=3D2' \ - '--domain test --count 2' \ - '--domain=3Dtest --count 2' \ - '--domain test --count=3D2' \ - '--domain=3Dtest --count=3D2' \ - '--count 2 --domain test' \ - '--count 2 --domain=3Dtest' \ - '--count=3D2 --domain test' \ - '--count=3D2 --domain=3Dtest' \ - '--count 2 test' \ - '--count=3D2 test' \ -; do - $VIRSH -k0 -d0 -c $test_url setvcpus $args >out 2>>err || fail=3D1 - LC_ALL=3DC sort out | compare exp-out - || fail=3D1 -done - # Another complex parsing example cat <<\EOF > exp-out || framework_failure diff --git a/tests/virshtest.c b/tests/virshtest.c index 926f919d8d..1baa402648 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -198,6 +198,9 @@ mymain(void) DO_TEST_SCRIPT("echo-split", NULL, VIRSH_DEFAULT, "-q"); # undef DO_TEST + /* comprehensive coverage of argument assignment */ + DO_TEST_SCRIPT("argument-assignment", NULL, VIRSH_DEFAULT, "-k0", "-d0= "); + VIR_FREE(custom_uri); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/virshtestdata/argument-assignment.in b/tests/virshtestda= ta/argument-assignment.in new file mode 100644 index 0000000000..283f521b1c --- /dev/null +++ b/tests/virshtestdata/argument-assignment.in @@ -0,0 +1,15 @@ +setvcpus test 2 +setvcpus --domain test 2 +setvcpus --domain=3Dtest 2 +setvcpus test --count 2 +setvcpus test --count=3D2 +setvcpus --domain test --count 2 +setvcpus --domain=3Dtest --count 2 +setvcpus --domain test --count=3D2 +setvcpus --domain=3Dtest --count=3D2 +setvcpus --count 2 --domain test +setvcpus --count 2 --domain=3Dtest +setvcpus --count=3D2 --domain test +setvcpus --count=3D2 --domain=3Dtest +setvcpus --count 2 test +setvcpus --count=3D2 test diff --git a/tests/virshtestdata/argument-assignment.out b/tests/virshtestd= ata/argument-assignment.out new file mode 100644 index 0000000000..501f0add33 --- /dev/null +++ b/tests/virshtestdata/argument-assignment.out @@ -0,0 +1,91 @@ +commands: "setvcpus test 2 +setvcpus --domain test 2 +setvcpus --domain=3Dtest 2 +setvcpus test --count 2 +setvcpus test --count=3D2 +setvcpus --domain test --count 2 +setvcpus --domain=3Dtest --count 2 +setvcpus --domain test --count=3D2 +setvcpus --domain=3Dtest --count=3D2 +setvcpus --count 2 --domain test +setvcpus --count 2 --domain=3Dtest +setvcpus --count=3D2 --domain test +setvcpus --count=3D2 --domain=3Dtest +setvcpus --count 2 test +setvcpus --count=3D2 test +" +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: count(optdata): 2 +setvcpus: domain(optdata): test +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + +setvcpus: found option : test +setvcpus: trying as domain NAME + --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org