From nobody Sat May 11 20:13:42 2024 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 1711130287851640.7342175159522; Fri, 22 Mar 2024 10:58:07 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6499D1C65; Fri, 22 Mar 2024 13:58:06 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 340421A96; Fri, 22 Mar 2024 13:56:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B562D1A62; Fri, 22 Mar 2024 13:56:23 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 A088A1A62 for ; Fri, 22 Mar 2024 13:56:22 -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-439-ybMIE7ZIPD2yFqI80oL9Tg-1; Fri, 22 Mar 2024 13:56:20 -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 8195918653A2 for ; Fri, 22 Mar 2024 17:56:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0195492BFA for ; Fri, 22 Mar 2024 17:56:19 +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: ybMIE7ZIPD2yFqI80oL9Tg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 01/35] virshtest: Prepare for testing against output files Date: Fri, 22 Mar 2024 18:55:39 +0100 Message-ID: <94e6294c98fc98f83666183e45bbe2bded932e78.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: 443YS22KFKQQBPMRLRBH2QWRCHZW43VL X-Message-ID-Hash: 443YS22KFKQQBPMRLRBH2QWRCHZW43VL 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: 1711130290073100001 Modify testCompareOutputLit to take a filename argument and compare it against and populate the arguments. For tests which don't use the 'data' from virTestRun, we'll expect to pass the output filename, thus we also propagate it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- build-aux/syntax-check.mk | 6 +- tests/virshtest.c | 130 +++++++++++++++++++++----------------- 2 files changed, 76 insertions(+), 60 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 2ac8c5760f..0759372b2b 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1386,7 +1386,7 @@ exclude_file_name_regexp--sc_prohibit_close =3D \ (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/vir(file|event)\.c|src/libvirt= -stream\.c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/= nss/libvirt_nss_(leases|macs)\.c)|tools/virt-qemu-qmp-proxy$$) exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF =3D \ - ((^tests/(nodedevmdevctl|viracpi|virhostcpu|virpcitest|virstoragetest|qe= munbdkit)data/|docs/js/.*\.js|docs/fonts/.*\.woff|\.diff|tests/virconfdata/= no-newline\.conf$$)|\.bin) + ((^tests/(nodedevmdevctl|viracpi|virhostcpu|virpcitest|virstoragetest|qe= munbdkit|virshtest)data/|docs/js/.*\.js|docs/fonts/.*\.woff|\.diff|tests/vi= rconfdata/no-newline\.conf$$)|\.bin) exclude_file_name_regexp--sc_prohibit_fork_wrappers =3D \ (^(src/(util/(vircommand|virdaemon)|lxc/lxc_controller)|tests/testutils)= \.c$$) @@ -1437,7 +1437,7 @@ exclude_file_name_regexp--sc_require_config_h_first = =3D \ ^(examples/|tools/virsh-edit\.c$$|tests/virmockstathelpers\.c$$|scripts/r= pcgen/tests/test_demo\.c$$) exclude_file_name_regexp--sc_trailing_blank =3D \ - /sysinfodata/.*\.data|/virhostcpudata/.*\.cpuinfo$$ + /sysinfodata/.*\.data|/virhostcpudata/.*\.cpuinfo|tests/virshtestdata/.*= $$ exclude_file_name_regexp--sc_unmarked_diagnostics =3D \ ^(scripts/apibuild.py|tests/virt-aa-helper-test|docs/js/.*\.js)$$ @@ -1466,7 +1466,7 @@ exclude_file_name_regexp--sc_prohibit_mixed_case_abbr= eviations =3D \ ^src/(vbox/vbox_CAPI.*.h|esx/esx_vi.(c|h)|esx/esx_storage_backend_iscsi.= c)$$ exclude_file_name_regexp--sc_prohibit_empty_first_line =3D \ - ^tests/vmwareverdata/fusion-5.0.3.txt|scripts/rpcgen/tests/demo\.c$$ + ^tests/vmwareverdata/fusion-5.0.3.txt|scripts/rpcgen/tests/demo\.c|^test= s/virshtestdata/.*$$ exclude_file_name_regexp--sc_prohibit_useless_translation =3D \ ^tests/virpolkittest.c diff --git a/tests/virshtest.c b/tests/virshtest.c index cf834bb847..5a5068dc78 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -108,8 +108,10 @@ static int testFilterLine(char *buffer, } static int -testCompareOutputLit(const char *expectData, - const char *filter, const char *const argv[]) +testCompareOutputLit(const char *expectFile, + const char *expectData, + const char *filter, + const char *const argv[]) { g_autofree char *actualData =3D NULL; const char *empty =3D ""; @@ -134,8 +136,14 @@ testCompareOutputLit(const char *expectData, if (filter && testFilterLine(actualData, filter) < 0) return -1; - if (virTestCompareToString(expectData, actualData) < 0) { - return -1; + if (expectData) { + if (virTestCompareToString(expectData, actualData) < 0) + return -1; + } + + if (expectFile) { + if (virTestCompareToFileFull(actualData, expectFile, false) < 0) + return -1; } return 0; @@ -151,7 +159,7 @@ static char *custom_uri; "--connect", \ custom_uri -static int testCompareListDefault(const void *data G_GNUC_UNUSED) +static int testCompareListDefault(const void *data) { const char *const argv[] =3D { VIRSH_DEFAULT, "list", NULL }; const char *exp =3D "\ @@ -159,10 +167,10 @@ static int testCompareListDefault(const void *data G_= GNUC_UNUSED) ----------------------\n\ 1 test running\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareListCustom(const void *data G_GNUC_UNUSED) +static int testCompareListCustom(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "list", NULL }; const char *exp =3D "\ @@ -172,10 +180,10 @@ static int testCompareListCustom(const void *data G_G= NUC_UNUSED) 2 fc4 running\n\ 3 fc5 running\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareNodeinfoDefault(const void *data G_GNUC_UNUSED) +static int testCompareNodeinfoDefault(const void *data) { const char *const argv[] =3D { VIRSH_DEFAULT, "nodeinfo", NULL }; const char *exp =3D "\ @@ -188,10 +196,10 @@ Thread(s) per core: 2\n\ NUMA cell(s): 2\n\ Memory size: 3145728 KiB\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareNodeinfoCustom(const void *data G_GNUC_UNUSED) +static int testCompareNodeinfoCustom(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, @@ -208,115 +216,115 @@ Thread(s) per core: 2\n\ NUMA cell(s): 4\n\ Memory size: 8192000 KiB\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDominfoByID(const void *data G_GNUC_UNUSED) +static int testCompareDominfoByID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", "2", NULL }; const char *exp =3D dominfo_fc4; - return testCompareOutputLit(exp, "\nCPU time:", argv); + return testCompareOutputLit((const char *) data, exp, "\nCPU time:", a= rgv); } -static int testCompareDominfoByUUID(const void *data G_GNUC_UNUSED) +static int testCompareDominfoByUUID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", DOM_FC4_UUID, = NULL }; const char *exp =3D dominfo_fc4; - return testCompareOutputLit(exp, "\nCPU time:", argv); + return testCompareOutputLit((const char *) data, exp, "\nCPU time:", a= rgv); } -static int testCompareDominfoByName(const void *data G_GNUC_UNUSED) +static int testCompareDominfoByName(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", "fc4", NULL }; const char *exp =3D dominfo_fc4; - return testCompareOutputLit(exp, "\nCPU time:", argv); + return testCompareOutputLit((const char *) data, exp, "\nCPU time:", a= rgv); } -static int testCompareTaintedDominfoByName(const void *data G_GNUC_UNUSED) +static int testCompareTaintedDominfoByName(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", "fc5", NULL }; const char *exp =3D dominfo_fc5; - return testCompareOutputLit(exp, "\nCPU time:", argv); + return testCompareOutputLit((const char *) data, exp, "\nCPU time:", a= rgv); } -static int testCompareDomuuidByID(const void *data G_GNUC_UNUSED) +static int testCompareDomuuidByID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domuuid", "2", NULL }; const char *exp =3D domuuid_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomuuidByName(const void *data G_GNUC_UNUSED) +static int testCompareDomuuidByName(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domuuid", "fc4", NULL }; const char *exp =3D domuuid_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomidByName(const void *data G_GNUC_UNUSED) +static int testCompareDomidByName(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domid", "fc4", NULL }; const char *exp =3D domid_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomidByUUID(const void *data G_GNUC_UNUSED) +static int testCompareDomidByUUID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domid", DOM_FC4_UUID, NU= LL }; const char *exp =3D domid_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomnameByID(const void *data G_GNUC_UNUSED) +static int testCompareDomnameByID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domname", "2", NULL }; const char *exp =3D domname_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomnameByUUID(const void *data G_GNUC_UNUSED) +static int testCompareDomnameByUUID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domname", DOM_FC4_UUID, = NULL }; const char *exp =3D domname_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomstateByID(const void *data G_GNUC_UNUSED) +static int testCompareDomstateByID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domstate", "2", NULL }; const char *exp =3D domstate_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomstateByUUID(const void *data G_GNUC_UNUSED) +static int testCompareDomstateByUUID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domstate", DOM_FC4_UUID,= NULL }; const char *exp =3D domstate_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomstateByName(const void *data G_GNUC_UNUSED) +static int testCompareDomstateByName(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domstate", "fc4", NULL }; const char *exp =3D domstate_fc4; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareDomControlInfoByName(const void *data G_GNUC_UNUSED) +static int testCompareDomControlInfoByName(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domcontrol", "fc4", NULL= }; const char *exp =3D "ok\n\n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareGetBlkioParameters(const void *data G_GNUC_UNUSED) +static int testCompareGetBlkioParameters(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "blkiotune", "fv0", NULL = }; const char *exp =3D get_blkio_parameters; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testCompareSetBlkioParameters(const void *data G_GNUC_UNUSED) +static int testCompareSetBlkioParameters(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "blkiotune fv0\ --weight 500\ @@ -332,10 +340,10 @@ static int testCompareSetBlkioParameters(const void *= data G_GNUC_UNUSED) " SET_BLKIO_PARAMETER ";\ blkiotune fv0", NULL }; const char *exp =3D set_blkio_parameters; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testIOThreadAdd(const void *data G_GNUC_UNUSED) +static int testIOThreadAdd(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadinfo --domain fc= 4;\ iothreadadd --domain fc4 --id 6;\ @@ -353,10 +361,10 @@ static int testIOThreadAdd(const void *data G_GNUC_UN= USED) 4 0\n\ 6 0\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testIOThreadDel(const void *data G_GNUC_UNUSED) +static int testIOThreadDel(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadinfo --domain fc= 4;\ iothreaddel --domain fc4 --id 2;\ @@ -372,10 +380,10 @@ static int testIOThreadDel(const void *data G_GNUC_UN= USED) -----------------------------\n\ 4 0\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testIOThreadSet(const void *data G_GNUC_UNUSED) +static int testIOThreadSet(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "domstats --domain fc4;\ iothreadset --domain fc4\ @@ -404,10 +412,10 @@ Domain: 'fc4'\n\ iothread.4.poll-max-ns" EQUAL "32768\n\ iothread.4.poll-grow" EQUAL "0\n\ iothread.4.poll-shrink" EQUAL "0\n\n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } -static int testIOThreadPin(const void *data G_GNUC_UNUSED) +static int testIOThreadPin(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadadd --domain fc5 --id 2;\ @@ -425,18 +433,27 @@ static int testIOThreadPin(const void *data G_GNUC_UN= USED) -----------------------------\n\ 2 0\n\ \n"; - return testCompareOutputLit(exp, NULL, argv); + return testCompareOutputLit((const char *) data, exp, NULL, argv); } struct testInfo { + const char *testname; /* used to generate output filename */ + const char *filter; const char *const *argv; const char *result; }; -static int testCompareEcho(const void *data) +static int testCompare(const void *data) { const struct testInfo *info =3D data; - return testCompareOutputLit(info->result, NULL, info->argv); + g_autofree char *outfile =3D NULL; + + if (info->testname) { + outfile =3D g_strdup_printf("%s/virshtestdata/%s.out", + abs_srcdir, info->testname); + } + + return testCompareOutputLit(outfile, info->result, info->filter, info-= >argv); } @@ -549,9 +566,8 @@ mymain(void) # define DO_TEST(i, result, ...) \ do { \ const char *myargv[] =3D { VIRSH_DEFAULT, __VA_ARGS__, NULL }; \ - const struct testInfo info =3D { myargv, result }; \ - if (virTestRun("virsh echo " #i, \ - testCompareEcho, &info) < 0) \ + const struct testInfo info =3D { NULL, NULL, myargv, result }; \ + if (virTestRun("virsh echo " #i, testCompare, &info) < 0) \ ret =3D -1; \ } while (0) --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711130322880629.7568151881426; Fri, 22 Mar 2024 10:58:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B837B1B09; Fri, 22 Mar 2024 13:58:41 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4FBA31B83; Fri, 22 Mar 2024 13:56:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 89F591A93; Fri, 22 Mar 2024 13:56:24 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 0F0E91A62 for ; Fri, 22 Mar 2024 13:56:24 -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-15-ixfPpy2vObCdQQzGE30Hzg-1; Fri, 22 Mar 2024 13:56:22 -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 649B138012F7 for ; Fri, 22 Mar 2024 17:56:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3E2D492BDD for ; Fri, 22 Mar 2024 17:56:20 +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: ixfPpy2vObCdQQzGE30Hzg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 02/35] virshtest: Allow to test failure of commands Date: Fri, 22 Mar 2024 18:55:40 +0100 Message-ID: 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: WB3XLTRB25R3IWUUX7Y4ZLQPX43VNKTS X-Message-ID-Hash: WB3XLTRB25R3IWUUX7Y4ZLQPX43VNKTS 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: 1711130324077100001 Modify the test code so that if virsh fails both 'stdout' and 'stderr' are captured and compared against the output and also the return value is checked by appending it to the output. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 5a5068dc78..4097c1d427 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -113,36 +113,37 @@ testCompareOutputLit(const char *expectFile, const char *filter, const char *const argv[]) { - g_autofree char *actualData =3D NULL; + g_autofree char *actual =3D NULL; const char *empty =3D ""; g_autoptr(virCommand) cmd =3D NULL; - g_autofree char *errbuf =3D NULL; + int exitstatus =3D 0; cmd =3D virCommandNewArgs(argv); virCommandAddEnvString(cmd, "LANG=3DC"); virCommandSetInputBuffer(cmd, empty); - virCommandSetOutputBuffer(cmd, &actualData); - virCommandSetErrorBuffer(cmd, &errbuf); + virCommandSetOutputBuffer(cmd, &actual); + virCommandSetErrorBuffer(cmd, &actual); - if (virCommandRun(cmd, NULL) < 0) + if (virCommandRun(cmd, &exitstatus) < 0) return -1; - if (STRNEQ(errbuf, "")) { - fprintf(stderr, "Command reported error: %s", errbuf); - return -1; + if (exitstatus !=3D 0) { + g_autofree char *tmp =3D g_steal_pointer(&actual); + + actual =3D g_strdup_printf("%s\n## Exit code: %d\n", tmp, exitstat= us); } - if (filter && testFilterLine(actualData, filter) < 0) + if (filter && testFilterLine(actual, filter) < 0) return -1; if (expectData) { - if (virTestCompareToString(expectData, actualData) < 0) + if (virTestCompareToString(expectData, actual) < 0) return -1; } if (expectFile) { - if (virTestCompareToFileFull(actualData, expectFile, false) < 0) + if (virTestCompareToFileFull(actual, expectFile, false) < 0) return -1; } --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711632210275443.11901099136344; Thu, 28 Mar 2024 06:23:30 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id CC1891E9F; Thu, 28 Mar 2024 09:23:28 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D68521A53; Thu, 28 Mar 2024 09:22:43 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EEC831A33; Thu, 28 Mar 2024 09:22:40 -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 7A1C31A2C for ; Thu, 28 Mar 2024 09:22: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-212-6Lp74cFpOpeTyHsOi-pntw-1; Thu, 28 Mar 2024 09:22:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 A59E4851781 for ; Thu, 28 Mar 2024 13:22:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F29F2024517 for ; Thu, 28 Mar 2024 13:22: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: 6Lp74cFpOpeTyHsOi-pntw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 03/35] virshtest: Filter multiple occurences of string to drop in testFilterLine Date: Thu, 28 Mar 2024 14:22:25 +0100 Message-ID: <2314e62e486ca6e488fcb48c5b466c04d8a1c8f6.1711129973.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: JBIA2IMQNRJXB47XVKTUSIWSKPPUTZFD X-Message-ID-Hash: JBIA2IMQNRJXB47XVKTUSIWSKPPUTZFD 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: 1711632211441100001 Upcoming patches will require that possibly multiple occurences of the string to drop are present in the output string thus we need to adapt testFilterLine to handle them. Additionally we drop the unused return value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 4097c1d427..e0b5cd3150 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -90,21 +90,20 @@ device_read_bytes_sec: " SET_BLKIO_PARAMETER "\n\ device_write_bytes_sec: " SET_BLKIO_PARAMETER "\n\ \n"; -static int testFilterLine(char *buffer, - const char *toRemove) +static void testFilterLine(char *buffer, + const char *toRemove) { char *start; - char *end; - if (!(start =3D strstr(buffer, toRemove))) - return -1; + while ((start =3D strstr(buffer, toRemove))) { + char *end; - if (!(end =3D strstr(start+1, "\n"))) { - *start =3D '\0'; - } else { - memmove(start, end, strlen(end)+1); + if (!(end =3D strstr(start+1, "\n"))) { + *start =3D '\0'; + } else { + memmove(start, end, strlen(end)+1); + } } - return 0; } static int @@ -134,8 +133,8 @@ testCompareOutputLit(const char *expectFile, actual =3D g_strdup_printf("%s\n## Exit code: %d\n", tmp, exitstat= us); } - if (filter && testFilterLine(actual, filter) < 0) - return -1; + if (filter) + testFilterLine(actual, filter); if (expectData) { if (virTestCompareToString(expectData, actual) < 0) --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711632258136638.5557027584127; Thu, 28 Mar 2024 06:24:18 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E48A0225E; Thu, 28 Mar 2024 09:24:16 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2E3381DD5; Thu, 28 Mar 2024 09:22:46 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1203C1A33; Thu, 28 Mar 2024 09:22:42 -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 978E51A2C for ; Thu, 28 Mar 2024 09:22:41 -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-584-y_08n3yuPcSYtoCP3CX2OQ-1; Thu, 28 Mar 2024 09:22:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 8D66B800262 for ; Thu, 28 Mar 2024 13:22:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06CDD2024517 for ; Thu, 28 Mar 2024 13:22:38 +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: y_08n3yuPcSYtoCP3CX2OQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 04/35] virshtest: Add support for testing commands read from input file and adapt alias tests Date: Thu, 28 Mar 2024 14:22:26 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 2PG3HB2BAG2BNWIZUZC6BNAZEWN3ILDV X-Message-ID-Hash: 2PG3HB2BAG2BNWIZUZC6BNAZEWN3ILDV 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: 1711632259615100001 Add support for reading a file and passing it to virsh in 'batch' mode so that multiple commands can be easily tested with one invocation of virsh. To show how it's used adapt the alias handling tests to be invoked all at once. As in batch mode the arguments are read from a string and separated inside virsh, one test is kept separate to be parsed in argv mode. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 25 +++++++++++++++++++++---- tests/virshtestdata/echo-alias.in | 3 +++ tests/virshtestdata/echo-alias.out | 3 +++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 tests/virshtestdata/echo-alias.in create mode 100644 tests/virshtestdata/echo-alias.out diff --git a/tests/virshtest.c b/tests/virshtest.c index e0b5cd3150..376fb861ed 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -561,6 +561,26 @@ mymain(void) testIOThreadPin, NULL) !=3D 0) ret =3D -1; +# define DO_TEST_SCRIPT(testname_, testfilter, ...) \ + { \ + const char *testname =3D testname_; \ + g_autofree char *infile =3D g_strdup_printf("%s/virshtestdata/%s.i= n", \ + abs_srcdir, testname); \ + const char *myargv[] =3D { __VA_ARGS__, NULL, NULL }; \ + const char **tmp =3D myargv; \ + const struct testInfo info =3D { testname, testfilter, myargv, NUL= L }; \ + g_autofree char *scriptarg =3D NULL; \ + if (virFileReadAll(infile, 256 * 1024, &scriptarg) < 0) { \ + fprintf(stderr, "\nfailed to load '%s'\n", infile); \ + ret =3D -1; \ + } \ + while (*tmp) \ + tmp++; \ + *tmp =3D scriptarg; \ + if (virTestRun(testname, testCompare, &info) < 0) \ + ret =3D -1; \ + } while (0); + /* It's a bit awkward listing result before argument, but that's a * limitation of C99 vararg macros. */ # define DO_TEST(i, result, ...) \ @@ -644,11 +664,8 @@ mymain(void) "echo \t '-'\"-\" \t --shell \t a"); /* Tests of alias handling. */ - DO_TEST(31, "hello\n", "echo", "--string", "hello"); - DO_TEST(32, "hello\n", "echo --string hello"); + DO_TEST_SCRIPT("echo-alias", NULL, VIRSH_DEFAULT); DO_TEST(33, "hello\n", "echo", "--str", "hello"); - DO_TEST(34, "hello\n", "echo --str hello"); - DO_TEST(35, "hello\n", "echo --hi"); /* Tests of multiple commands. */ DO_TEST(36, "a\nb\n", " echo a; echo b;"); diff --git a/tests/virshtestdata/echo-alias.in b/tests/virshtestdata/echo-a= lias.in new file mode 100644 index 0000000000..f123437490 --- /dev/null +++ b/tests/virshtestdata/echo-alias.in @@ -0,0 +1,3 @@ +echo --string hello +echo --str hello +echo --hi; diff --git a/tests/virshtestdata/echo-alias.out b/tests/virshtestdata/echo-= alias.out new file mode 100644 index 0000000000..640bb73cf1 --- /dev/null +++ b/tests/virshtestdata/echo-alias.out @@ -0,0 +1,3 @@ +hello +hello +hello --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711632303115205.03173246258052; Thu, 28 Mar 2024 06:25:03 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EA38D1735; Thu, 28 Mar 2024 09:25:01 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 65DB321C0; Thu, 28 Mar 2024 09:22:51 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D56281A2C; Thu, 28 Mar 2024 09:22:42 -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 63EB61A33 for ; Thu, 28 Mar 2024 09:22:42 -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-594-D65XV2h4OrmZ02BNW4Lgaw-1; Thu, 28 Mar 2024 09:22:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 74CA28018A2 for ; Thu, 28 Mar 2024 13:22:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id E23EC200A384 for ; Thu, 28 Mar 2024 13:22:39 +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: D65XV2h4OrmZ02BNW4Lgaw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 05/35] virshtest: Adapt 'echo --split' tests to DO_TEST_SCRIPT Date: Thu, 28 Mar 2024 14:22:27 +0100 Message-ID: <1432ab7d6fda61cdacf23209773e3fa2625f48c2.1711129973.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: GL2HEFJVS4D2OGY6BFNUPCLJWUWZETEB X-Message-ID-Hash: GL2HEFJVS4D2OGY6BFNUPCLJWUWZETEB 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: 1711632303775100001 Optimize invocation of the tests to share one 'virsh' binary as they don't influence each other. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 11 +---------- tests/virshtestdata/echo-split.in | 5 +++++ tests/virshtestdata/echo-split.out | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 tests/virshtestdata/echo-split.in create mode 100644 tests/virshtestdata/echo-split.out diff --git a/tests/virshtest.c b/tests/virshtest.c index 376fb861ed..51314859b9 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -682,16 +682,7 @@ mymain(void) DO_TEST(47, "a\n", "\\# ignored;echo a\n'#also' ignored"); /* test of splitting in vshStringToArray */ - DO_TEST(48, "a\nb,c,\nd,,e,,\nf,,,e\n", - "-q", "echo", "--split", "a,b,,c,,,d,,,,e,,,,,f,,,,,,e"); - DO_TEST(49, "\na\nb,c,\nd,,e,,\nf,,,e\n\n", - "-q", "echo", "--split", ",a,b,,c,,,d,,,,e,,,,,f,,,,,,e,"); - DO_TEST(50, ",a\nb,c,\nd,,e,,\nf,,,e,\n", - "-q", "echo", "--split", ",,a,b,,c,,,d,,,,e,,,,,f,,,,,,e,,"); - DO_TEST(51, ",\na\nb,c,\nd,,e,,\nf,,,e,\n\n", - "-q", "echo", "--split", ",,,a,b,,c,,,d,,,,e,,,,,f,,,,,,e,,,"); - DO_TEST(52, ",,a\nb,c,\nd,,e,,\nf,,,e,,\n", - "-q", "echo", "--split", ",,,,a,b,,c,,,d,,,,e,,,,,f,,,,,,e,,,,= "); + DO_TEST_SCRIPT("echo-split", NULL, VIRSH_DEFAULT, "-q"); # undef DO_TEST VIR_FREE(custom_uri); diff --git a/tests/virshtestdata/echo-split.in b/tests/virshtestdata/echo-s= plit.in new file mode 100644 index 0000000000..2df9f4da97 --- /dev/null +++ b/tests/virshtestdata/echo-split.in @@ -0,0 +1,5 @@ +echo --split a,b,,c,,,d,,,,e,,,,,f,,,,,,e +echo --split ,a,b,,c,,,d,,,,e,,,,,f,,,,,,e, +echo --split ,,a,b,,c,,,d,,,,e,,,,,f,,,,,,e,, +echo --split ,,,a,b,,c,,,d,,,,e,,,,,f,,,,,,e,,, +echo --split ,,,,a,b,,c,,,d,,,,e,,,,,f,,,,,,e,,,, diff --git a/tests/virshtestdata/echo-split.out b/tests/virshtestdata/echo-= split.out new file mode 100644 index 0000000000..88bf09c225 --- /dev/null +++ b/tests/virshtestdata/echo-split.out @@ -0,0 +1,24 @@ +a +b,c, +d,,e,, +f,,,e + +a +b,c, +d,,e,, +f,,,e + +,a +b,c, +d,,e,, +f,,,e, +, +a +b,c, +d,,e,, +f,,,e, + +,,a +b,c, +d,,e,, +f,,,e,, --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711632354936504.76542640057346; Thu, 28 Mar 2024 06:25:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id BE3CC2189; Thu, 28 Mar 2024 09:25:53 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D41E31F03; Thu, 28 Mar 2024 09:22:54 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B03EE1A2C; Thu, 28 Mar 2024 09:22:43 -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 3AB141A2C for ; Thu, 28 Mar 2024 09:22:43 -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-626-UwXaJe0pNmawbL04gxFrtw-1; Thu, 28 Mar 2024 09:22:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 5C1CC101A56C for ; Thu, 28 Mar 2024 13:22:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id C903B202451F for ; Thu, 28 Mar 2024 13:22:40 +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: UwXaJe0pNmawbL04gxFrtw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 06/35] virshtest: Drop some redundant 'echo' cases Date: Thu, 28 Mar 2024 14:22:28 +0100 Message-ID: <5d71005f2fbf8c9f30c4d31ea0e61cdfcb65c89f.1711129973.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: XG2ATMEIY6YJZD7O6KG54ZO7DFYD6PK5 X-Message-ID-Hash: XG2ATMEIY6YJZD7O6KG54ZO7DFYD6PK5 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: 1711632355919100001 Both argument passing and multiple command handling is already tested in the 'multiple commands' cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 51314859b9..a60cfdf7a0 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -592,12 +592,6 @@ mymain(void) } while (0) /* Arg parsing quote removal tests. */ - DO_TEST(0, "\n", - "echo"); - DO_TEST(1, "a\n", - "echo", "a"); - DO_TEST(2, "a b\n", - "echo", "a", "b"); DO_TEST(3, "a b\n", "echo a \t b"); DO_TEST(4, "a \t b\n", @@ -606,10 +600,6 @@ mymain(void) "echo 'a \t b'"); DO_TEST(6, "a \t b\n", "echo a\\ \\\t\\ b"); - DO_TEST(7, "\n\n", - "echo ; echo"); - DO_TEST(8, "a\nb\n", - ";echo a; ; echo b;"); DO_TEST(9, "' \" \\;echo\ta\n", "echo", "'", "\"", "\\;echo\ta"); DO_TEST(10, "' \" ;echo a\n", --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711632773488983.0120213757227; Thu, 28 Mar 2024 06:32:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4CAFC1F6E; Thu, 28 Mar 2024 09:32:52 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0857A2209; Thu, 28 Mar 2024 09:23:06 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D658821F2; Thu, 28 Mar 2024 09:22:57 -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 21ADC1E29 for ; Thu, 28 Mar 2024 09:22:44 -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-650-othctN_BNeuM5aFhFFTlig-1; Thu, 28 Mar 2024 09:22:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 4D84D8007B0 for ; Thu, 28 Mar 2024 13:22:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id B97A8200E1B5 for ; Thu, 28 Mar 2024 13:22:41 +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: othctN_BNeuM5aFhFFTlig-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 07/35] virshtest: Adapt some 'escaping' tests via DO_TEST_SCRIPT Date: Thu, 28 Mar 2024 14:22:29 +0100 Message-ID: <20536480763426529eb2160a419847eeef511fa4.1711129973.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: I2TCGEBOK2FBLPV5D5H6SQZZ67YLVFKF X-Message-ID-Hash: I2TCGEBOK2FBLPV5D5H6SQZZ67YLVFKF 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: 1711632775449100001 Express what's possible via a "virsh script" rather than invoking separate virsh for each one. We need to keep a few for parity as the argument parser behaves differently when processing argv-like input compared to a string. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 20 +------------------- tests/virshtestdata/echo-escaping.in | 11 +++++++++++ tests/virshtestdata/echo-escaping.out | 11 +++++++++++ 3 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 tests/virshtestdata/echo-escaping.in create mode 100644 tests/virshtestdata/echo-escaping.out diff --git a/tests/virshtest.c b/tests/virshtest.c index a60cfdf7a0..4b02ef3a49 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -610,6 +610,7 @@ mymain(void) "echo \"'\" '\"' '\\'\"\\\\\""); /* Tests of echo flags. */ + DO_TEST_SCRIPT("echo-escaping", NULL, VIRSH_DEFAULT); DO_TEST(13, "a A 0 + * ; . ' \" / ? =3D \n < > &\n", "echo", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", "?", "=3D", " ", "\n", "<", ">", "&"); @@ -619,25 +620,6 @@ mymain(void) DO_TEST(15, "a A 0 + * ; . ' " / ? =3D \n < > &\= n", "echo", "--xml", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", "?", "=3D", " ", "\n", "<", ">", "&"); - DO_TEST(16, "a A 0 + '*' ';' . ''\\''' '\"' / '?' =3D ' ' '\n' '<' '>'= '&'\n", - "echo", "--shell", "a", "A", "0", "+", "*", ";", ".", "\'", - "\"", "/", "?", "=3D", " ", "\n", "<", ">", "&"); - DO_TEST(17, "\n", - "echo", ""); - DO_TEST(18, "''\n", - "echo", "--shell", ""); - DO_TEST(19, "\n", - "echo", "--xml", ""); - DO_TEST(20, "''\n", - "echo", "--shell", ""); - DO_TEST(21, "\n", - "echo ''"); - DO_TEST(22, "''\n", - "echo --shell \"\""); - DO_TEST(23, "\n", - "echo --xml ''"); - DO_TEST(24, "''\n", - "echo --shell \"\"''"); /* Tests of -- handling. */ DO_TEST(25, "a\n", diff --git a/tests/virshtestdata/echo-escaping.in b/tests/virshtestdata/ech= o-escaping.in new file mode 100644 index 0000000000..26d4e4cc18 --- /dev/null +++ b/tests/virshtestdata/echo-escaping.in @@ -0,0 +1,11 @@ +echo a A 0 + * . \' / ? =3D < > & +echo --xml a A 0 + * . \' / ? =3D < > & +echo --shell a A 0 + * . \' / ? =3D < > & +echo "" +echo --shell +echo --xml +echo --shell +echo '' +echo --shell "" +echo --xml '' +echo --shell ""'' diff --git a/tests/virshtestdata/echo-escaping.out b/tests/virshtestdata/ec= ho-escaping.out new file mode 100644 index 0000000000..ff3e0a98b3 --- /dev/null +++ b/tests/virshtestdata/echo-escaping.out @@ -0,0 +1,11 @@ +a A 0 + * . ' / ? =3D < > & +a A 0 + * . ' / ? =3D < > & +a A 0 + '*' . ''\''' / '?' =3D '<' '>' '&' + + + + + +'' + +'' --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711632840681941.541192397645; Thu, 28 Mar 2024 06:34:00 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 32A911730; Thu, 28 Mar 2024 09:33:59 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 38C25220D; Thu, 28 Mar 2024 09:23:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2431D1F3A; Thu, 28 Mar 2024 09:22:59 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 5C0071F2C for ; Thu, 28 Mar 2024 09:22:45 -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-17-8zLHTQFtP5K8NXvZrzt7Jw-1; Thu, 28 Mar 2024 09:22:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 3359A185A78E for ; Thu, 28 Mar 2024 13:22:43 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0D97200A384 for ; Thu, 28 Mar 2024 13:22:42 +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: 8zLHTQFtP5K8NXvZrzt7Jw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 08/35] vrishtest: Prepare for simpler testing - echo tests Date: Thu, 28 Mar 2024 14:22:30 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 3OUHPYO3W5JVG4LES6ZBHOWQH6YRIGER X-Message-ID-Hash: 3OUHPYO3W5JVG4LES6ZBHOWQH6YRIGER 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: 1711632841728100001 Embedding the expected output in a C source code makes it very hard to extend tests. In order to be able to test the outputs against data in files on disk we need better naming of the tests themselves. Use virTestCounterNext/Reset with appropriate tags to give reasonable names to the 'virsh echo' tests' and prepare the 'DO_TEST' macro for wider use. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 99 +++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 55 deletions(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 4b02ef3a49..fc1246a96d 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -581,77 +581,66 @@ mymain(void) ret =3D -1; \ } while (0); - /* It's a bit awkward listing result before argument, but that's a - * limitation of C99 vararg macros. */ -# define DO_TEST(i, result, ...) \ +# define DO_TEST_FULL(testname_, filter, result, ...) \ do { \ - const char *myargv[] =3D { VIRSH_DEFAULT, __VA_ARGS__, NULL }; \ + const char *testname =3D testname_; \ + const char *myargv[] =3D { __VA_ARGS__, NULL }; \ const struct testInfo info =3D { NULL, NULL, myargv, result }; \ - if (virTestRun("virsh echo " #i, testCompare, &info) < 0) \ + if (virTestRun(testname, testCompare, &info) < 0) \ ret =3D -1; \ } while (0) + /* automatically numbered test invocation */ +# define DO_TEST(result, ...) \ + DO_TEST_FULL(virTestCounterNext(), NULL, result, VIRSH_DEFAULT, __VA_A= RGS__); + + /* Arg parsing quote removal tests. */ - DO_TEST(3, "a b\n", - "echo a \t b"); - DO_TEST(4, "a \t b\n", - "echo \"a \t b\""); - DO_TEST(5, "a \t b\n", - "echo 'a \t b'"); - DO_TEST(6, "a \t b\n", - "echo a\\ \\\t\\ b"); - DO_TEST(9, "' \" \\;echo\ta\n", - "echo", "'", "\"", "\\;echo\ta"); - DO_TEST(10, "' \" ;echo a\n", - "echo \\' \\\" \\;echo\ta"); - DO_TEST(11, "' \" \\\na\n", - "echo \\' \\\" \\\\;echo\ta"); - DO_TEST(12, "' \" \\\\\n", - "echo \"'\" '\"' '\\'\"\\\\\""); + virTestCounterReset("echo-quote-removal-"); + DO_TEST("a b\n", "echo a \t b"); + DO_TEST("a \t b\n", "echo \"a \t b\""); + DO_TEST("a \t b\n", "echo 'a \t b'"); + DO_TEST("a \t b\n", "echo a\\ \\\t\\ b"); + DO_TEST("' \" \\;echo\ta\n", "echo", "'", "\"", "\\;echo\ta"); + DO_TEST("' \" ;echo a\n", "echo \\' \\\" \\;echo\ta"); + DO_TEST("' \" \\\na\n", "echo \\' \\\" \\\\;echo\ta"); + DO_TEST("' \" \\\\\n", "echo \"'\" '\"' '\\'\"\\\\\""); /* Tests of echo flags. */ DO_TEST_SCRIPT("echo-escaping", NULL, VIRSH_DEFAULT); - DO_TEST(13, "a A 0 + * ; . ' \" / ? =3D \n < > &\n", - "echo", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", "?", - "=3D", " ", "\n", "<", ">", "&"); - DO_TEST(14, "a A 0 + '*' ';' . ''\\''' '\"' / '?' =3D ' ' '\n' '<' '>'= '&'\n", - "echo", "--shell", "a", "A", "0", "+", "*", ";", ".", "'", "\"= ", - "/", "?", "=3D", " ", "\n", "<", ">", "&"); - DO_TEST(15, "a A 0 + * ; . ' " / ? =3D \n < > &\= n", - "echo", "--xml", "a", "A", "0", "+", "*", ";", ".", "'", "\"", - "/", "?", "=3D", " ", "\n", "<", ">", "&"); + + virTestCounterReset("echo-escaping-"); + DO_TEST("a A 0 + * ; . ' \" / ? =3D \n < > &\n", "echo", "a", "A", "= 0", "+", "*", ";", ".", "'", "\"", "/", "?", "=3D", " ", "\n", "<", ">", "&= "); + DO_TEST("a A 0 + '*' ';' . ''\\''' '\"' / '?' =3D ' ' '\n' '<' '>' '&'= \n", "echo", "--shell", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", = "?", "=3D", " ", "\n", "<", ">", "&"); + DO_TEST("a A 0 + * ; . ' " / ? =3D \n < > &\n", = "echo", "--xml", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", "?", "= =3D", " ", "\n", "<", ">", "&"); /* Tests of -- handling. */ - DO_TEST(25, "a\n", - "--", "echo", "--shell", "a"); - DO_TEST(26, "a\n", - "--", "echo", "a", "--shell"); - DO_TEST(27, "a --shell\n", - "--", "echo", "--", "a", "--shell"); - DO_TEST(28, "-- --shell a\n", - "echo", "--", "--", "--shell", "a"); - DO_TEST(29, "a\n", - "echo --s\\h'e'\"l\"l -- a"); - DO_TEST(30, "--shell a\n", - "echo \t '-'\"-\" \t --shell \t a"); + virTestCounterReset("dash-dash-argument-"); + DO_TEST("a\n", "--", "echo", "--shell", "a"); + DO_TEST("a\n", "--", "echo", "a", "--shell"); + DO_TEST("a --shell\n", "--", "echo", "--", "a", "--shell"); + DO_TEST("-- --shell a\n", "echo", "--", "--", "--shell", "a"); + DO_TEST("a\n", "echo --s\\h'e'\"l\"l -- a"); + DO_TEST("--shell a\n", "echo \t '-'\"-\" \t --shell \t a"); /* Tests of alias handling. */ DO_TEST_SCRIPT("echo-alias", NULL, VIRSH_DEFAULT); - DO_TEST(33, "hello\n", "echo", "--str", "hello"); + DO_TEST_FULL("echo-alias-argv", NULL, "hello\n", VIRSH_DEFAULT, "echo"= , "--str", "hello"); /* Tests of multiple commands. */ - DO_TEST(36, "a\nb\n", " echo a; echo b;"); - DO_TEST(37, "a\nb\n", "\necho a\n echo b\n"); - DO_TEST(38, "a\nb\n", "ec\\\nho a\n echo \\\n b;"); - DO_TEST(39, "a\n b\n", "\"ec\\\nho\" a\n echo \"\\\n b\";"); - DO_TEST(40, "a\n\\\n b\n", "ec\\\nho a\n echo '\\\n b';"); - DO_TEST(41, "a\n", "echo a # b"); - DO_TEST(42, "a\nc\n", "echo a #b\necho c"); - DO_TEST(43, "a\nc\n", "echo a # b\\\necho c"); - DO_TEST(44, "a # b\n", "echo a '#' b"); - DO_TEST(45, "a # b\n", "echo a \\# b"); - DO_TEST(46, "a\n", "#unbalanced; 'quotes\"\necho a # b"); - DO_TEST(47, "a\n", "\\# ignored;echo a\n'#also' ignored"); + virTestCounterReset("multiple-commands-"); + DO_TEST("a\nb\n", " echo a; echo b;"); + DO_TEST("a\nb\n", "\necho a\n echo b\n"); + DO_TEST("a\nb\n", "ec\\\nho a\n echo \\\n b;"); + DO_TEST("a\n b\n", "\"ec\\\nho\" a\n echo \"\\\n b\";"); + DO_TEST("a\n\\\n b\n", "ec\\\nho a\n echo '\\\n b';"); + DO_TEST("a\n", "echo a # b"); + DO_TEST("a\nc\n", "echo a #b\necho c"); + DO_TEST("a\nc\n", "echo a # b\\\necho c"); + DO_TEST("a # b\n", "echo a '#' b"); + DO_TEST("a # b\n", "echo a \\# b"); + DO_TEST("a\n", "#unbalanced; 'quotes\"\necho a # b"); + DO_TEST("a\n", "\\# ignored;echo a\n'#also' ignored"); /* test of splitting in vshStringToArray */ DO_TEST_SCRIPT("echo-split", NULL, VIRSH_DEFAULT, "-q"); --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711632987547816.7154028988571; Thu, 28 Mar 2024 06:36:27 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4FD901A6F; Thu, 28 Mar 2024 09:36:26 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 85D652211; Thu, 28 Mar 2024 09:23:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 35CCC2165; Thu, 28 Mar 2024 09:23:01 -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 D78E41F6E for ; Thu, 28 Mar 2024 09:22:45 -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-692-YeJyI05fNVWzl-zTiGKFaQ-1; Thu, 28 Mar 2024 09:22:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 1CCC9101A586 for ; Thu, 28 Mar 2024 13:22:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8823B2024517 for ; Thu, 28 Mar 2024 13:22:43 +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: YeJyI05fNVWzl-zTiGKFaQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 09/35] virshtest: Test against output files ("echo" tests) Date: Thu, 28 Mar 2024 14:22:31 +0100 Message-ID: <1126f5374a990a25e514906f7728b97ae3a5c017.1711129973.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: QZNRIKE2RLWDCPUPUQAAE26WHELBNNJU X-Message-ID-Hash: QZNRIKE2RLWDCPUPUQAAE26WHELBNNJU 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: 1711632988213100001 Managing output files is much simpler especially with VIR_TEST_REGENERATE_OUTPUT compared to putting the expected string blobs into the C source file. For now the output is tested both against the hardcoded strings as well as the output files. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 2 +- tests/virshtestdata/dash-dash-argument-1.out | 1 + tests/virshtestdata/dash-dash-argument-2.out | 1 + tests/virshtestdata/dash-dash-argument-3.out | 1 + tests/virshtestdata/dash-dash-argument-4.out | 1 + tests/virshtestdata/dash-dash-argument-5.out | 1 + tests/virshtestdata/dash-dash-argument-6.out | 1 + tests/virshtestdata/echo-alias-argv.out | 1 + tests/virshtestdata/echo-escaping-1.out | 2 ++ tests/virshtestdata/echo-escaping-2.out | 2 ++ tests/virshtestdata/echo-escaping-3.out | 2 ++ tests/virshtestdata/echo-quote-removal-1.out | 1 + tests/virshtestdata/echo-quote-removal-2.out | 1 + tests/virshtestdata/echo-quote-removal-3.out | 1 + tests/virshtestdata/echo-quote-removal-4.out | 1 + tests/virshtestdata/echo-quote-removal-5.out | 1 + tests/virshtestdata/echo-quote-removal-6.out | 1 + tests/virshtestdata/echo-quote-removal-7.out | 2 ++ tests/virshtestdata/echo-quote-removal-8.out | 1 + tests/virshtestdata/multiple-commands-1.out | 2 ++ tests/virshtestdata/multiple-commands-10.out | 1 + tests/virshtestdata/multiple-commands-11.out | 1 + tests/virshtestdata/multiple-commands-12.out | 1 + tests/virshtestdata/multiple-commands-2.out | 2 ++ tests/virshtestdata/multiple-commands-3.out | 2 ++ tests/virshtestdata/multiple-commands-4.out | 2 ++ tests/virshtestdata/multiple-commands-5.out | 3 +++ tests/virshtestdata/multiple-commands-6.out | 1 + tests/virshtestdata/multiple-commands-7.out | 2 ++ tests/virshtestdata/multiple-commands-8.out | 2 ++ tests/virshtestdata/multiple-commands-9.out | 1 + 31 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/virshtestdata/dash-dash-argument-1.out create mode 100644 tests/virshtestdata/dash-dash-argument-2.out create mode 100644 tests/virshtestdata/dash-dash-argument-3.out create mode 100644 tests/virshtestdata/dash-dash-argument-4.out create mode 100644 tests/virshtestdata/dash-dash-argument-5.out create mode 100644 tests/virshtestdata/dash-dash-argument-6.out create mode 100644 tests/virshtestdata/echo-alias-argv.out create mode 100644 tests/virshtestdata/echo-escaping-1.out create mode 100644 tests/virshtestdata/echo-escaping-2.out create mode 100644 tests/virshtestdata/echo-escaping-3.out create mode 100644 tests/virshtestdata/echo-quote-removal-1.out create mode 100644 tests/virshtestdata/echo-quote-removal-2.out create mode 100644 tests/virshtestdata/echo-quote-removal-3.out create mode 100644 tests/virshtestdata/echo-quote-removal-4.out create mode 100644 tests/virshtestdata/echo-quote-removal-5.out create mode 100644 tests/virshtestdata/echo-quote-removal-6.out create mode 100644 tests/virshtestdata/echo-quote-removal-7.out create mode 100644 tests/virshtestdata/echo-quote-removal-8.out create mode 100644 tests/virshtestdata/multiple-commands-1.out create mode 100644 tests/virshtestdata/multiple-commands-10.out create mode 100644 tests/virshtestdata/multiple-commands-11.out create mode 100644 tests/virshtestdata/multiple-commands-12.out create mode 100644 tests/virshtestdata/multiple-commands-2.out create mode 100644 tests/virshtestdata/multiple-commands-3.out create mode 100644 tests/virshtestdata/multiple-commands-4.out create mode 100644 tests/virshtestdata/multiple-commands-5.out create mode 100644 tests/virshtestdata/multiple-commands-6.out create mode 100644 tests/virshtestdata/multiple-commands-7.out create mode 100644 tests/virshtestdata/multiple-commands-8.out create mode 100644 tests/virshtestdata/multiple-commands-9.out diff --git a/tests/virshtest.c b/tests/virshtest.c index fc1246a96d..1750cc7abd 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -585,7 +585,7 @@ mymain(void) do { \ const char *testname =3D testname_; \ const char *myargv[] =3D { __VA_ARGS__, NULL }; \ - const struct testInfo info =3D { NULL, NULL, myargv, result }; \ + const struct testInfo info =3D { testname, NULL, myargv, result };= \ if (virTestRun(testname, testCompare, &info) < 0) \ ret =3D -1; \ } while (0) diff --git a/tests/virshtestdata/dash-dash-argument-1.out b/tests/virshtest= data/dash-dash-argument-1.out new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/tests/virshtestdata/dash-dash-argument-1.out @@ -0,0 +1 @@ +a diff --git a/tests/virshtestdata/dash-dash-argument-2.out b/tests/virshtest= data/dash-dash-argument-2.out new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/tests/virshtestdata/dash-dash-argument-2.out @@ -0,0 +1 @@ +a diff --git a/tests/virshtestdata/dash-dash-argument-3.out b/tests/virshtest= data/dash-dash-argument-3.out new file mode 100644 index 0000000000..b9f81e916d --- /dev/null +++ b/tests/virshtestdata/dash-dash-argument-3.out @@ -0,0 +1 @@ +a --shell diff --git a/tests/virshtestdata/dash-dash-argument-4.out b/tests/virshtest= data/dash-dash-argument-4.out new file mode 100644 index 0000000000..9367d302cc --- /dev/null +++ b/tests/virshtestdata/dash-dash-argument-4.out @@ -0,0 +1 @@ +-- --shell a diff --git a/tests/virshtestdata/dash-dash-argument-5.out b/tests/virshtest= data/dash-dash-argument-5.out new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/tests/virshtestdata/dash-dash-argument-5.out @@ -0,0 +1 @@ +a diff --git a/tests/virshtestdata/dash-dash-argument-6.out b/tests/virshtest= data/dash-dash-argument-6.out new file mode 100644 index 0000000000..ab8d1a1b1f --- /dev/null +++ b/tests/virshtestdata/dash-dash-argument-6.out @@ -0,0 +1 @@ +--shell a diff --git a/tests/virshtestdata/echo-alias-argv.out b/tests/virshtestdata/= echo-alias-argv.out new file mode 100644 index 0000000000..ce01362503 --- /dev/null +++ b/tests/virshtestdata/echo-alias-argv.out @@ -0,0 +1 @@ +hello diff --git a/tests/virshtestdata/echo-escaping-1.out b/tests/virshtestdata/= echo-escaping-1.out new file mode 100644 index 0000000000..ff7ee063bf --- /dev/null +++ b/tests/virshtestdata/echo-escaping-1.out @@ -0,0 +1,2 @@ +a A 0 + * ; . ' " / ? =3D =20 + < > & diff --git a/tests/virshtestdata/echo-escaping-2.out b/tests/virshtestdata/= echo-escaping-2.out new file mode 100644 index 0000000000..e04d19b8e0 --- /dev/null +++ b/tests/virshtestdata/echo-escaping-2.out @@ -0,0 +1,2 @@ +a A 0 + '*' ';' . ''\''' '"' / '?' =3D ' ' ' +' '<' '>' '&' diff --git a/tests/virshtestdata/echo-escaping-3.out b/tests/virshtestdata/= echo-escaping-3.out new file mode 100644 index 0000000000..f98b72d213 --- /dev/null +++ b/tests/virshtestdata/echo-escaping-3.out @@ -0,0 +1,2 @@ +a A 0 + * ; . ' " / ? =3D =20 + < > & diff --git a/tests/virshtestdata/echo-quote-removal-1.out b/tests/virshtest= data/echo-quote-removal-1.out new file mode 100644 index 0000000000..b2901ea97c --- /dev/null +++ b/tests/virshtestdata/echo-quote-removal-1.out @@ -0,0 +1 @@ +a b diff --git a/tests/virshtestdata/echo-quote-removal-2.out b/tests/virshtest= data/echo-quote-removal-2.out new file mode 100644 index 0000000000..927ce33b9b --- /dev/null +++ b/tests/virshtestdata/echo-quote-removal-2.out @@ -0,0 +1 @@ +a b diff --git a/tests/virshtestdata/echo-quote-removal-3.out b/tests/virshtest= data/echo-quote-removal-3.out new file mode 100644 index 0000000000..927ce33b9b --- /dev/null +++ b/tests/virshtestdata/echo-quote-removal-3.out @@ -0,0 +1 @@ +a b diff --git a/tests/virshtestdata/echo-quote-removal-4.out b/tests/virshtest= data/echo-quote-removal-4.out new file mode 100644 index 0000000000..927ce33b9b --- /dev/null +++ b/tests/virshtestdata/echo-quote-removal-4.out @@ -0,0 +1 @@ +a b diff --git a/tests/virshtestdata/echo-quote-removal-5.out b/tests/virshtest= data/echo-quote-removal-5.out new file mode 100644 index 0000000000..00f7191294 --- /dev/null +++ b/tests/virshtestdata/echo-quote-removal-5.out @@ -0,0 +1 @@ +' " \;echo a diff --git a/tests/virshtestdata/echo-quote-removal-6.out b/tests/virshtest= data/echo-quote-removal-6.out new file mode 100644 index 0000000000..6af6f47e48 --- /dev/null +++ b/tests/virshtestdata/echo-quote-removal-6.out @@ -0,0 +1 @@ +' " ;echo a diff --git a/tests/virshtestdata/echo-quote-removal-7.out b/tests/virshtest= data/echo-quote-removal-7.out new file mode 100644 index 0000000000..e5ec314ba9 --- /dev/null +++ b/tests/virshtestdata/echo-quote-removal-7.out @@ -0,0 +1,2 @@ +' " \ +a diff --git a/tests/virshtestdata/echo-quote-removal-8.out b/tests/virshtest= data/echo-quote-removal-8.out new file mode 100644 index 0000000000..1b5a28c5b3 --- /dev/null +++ b/tests/virshtestdata/echo-quote-removal-8.out @@ -0,0 +1 @@ +' " \\ diff --git a/tests/virshtestdata/multiple-commands-1.out b/tests/virshtestd= ata/multiple-commands-1.out new file mode 100644 index 0000000000..422c2b7ab3 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-1.out @@ -0,0 +1,2 @@ +a +b diff --git a/tests/virshtestdata/multiple-commands-10.out b/tests/virshtest= data/multiple-commands-10.out new file mode 100644 index 0000000000..a5ce8f1469 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-10.out @@ -0,0 +1 @@ +a # b diff --git a/tests/virshtestdata/multiple-commands-11.out b/tests/virshtest= data/multiple-commands-11.out new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-11.out @@ -0,0 +1 @@ +a diff --git a/tests/virshtestdata/multiple-commands-12.out b/tests/virshtest= data/multiple-commands-12.out new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-12.out @@ -0,0 +1 @@ +a diff --git a/tests/virshtestdata/multiple-commands-2.out b/tests/virshtestd= ata/multiple-commands-2.out new file mode 100644 index 0000000000..422c2b7ab3 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-2.out @@ -0,0 +1,2 @@ +a +b diff --git a/tests/virshtestdata/multiple-commands-3.out b/tests/virshtestd= ata/multiple-commands-3.out new file mode 100644 index 0000000000..422c2b7ab3 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-3.out @@ -0,0 +1,2 @@ +a +b diff --git a/tests/virshtestdata/multiple-commands-4.out b/tests/virshtestd= ata/multiple-commands-4.out new file mode 100644 index 0000000000..fa70605cd2 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-4.out @@ -0,0 +1,2 @@ +a + b diff --git a/tests/virshtestdata/multiple-commands-5.out b/tests/virshtestd= ata/multiple-commands-5.out new file mode 100644 index 0000000000..b89bc872d4 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-5.out @@ -0,0 +1,3 @@ +a +\ + b diff --git a/tests/virshtestdata/multiple-commands-6.out b/tests/virshtestd= ata/multiple-commands-6.out new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-6.out @@ -0,0 +1 @@ +a diff --git a/tests/virshtestdata/multiple-commands-7.out b/tests/virshtestd= ata/multiple-commands-7.out new file mode 100644 index 0000000000..0f7bc76605 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-7.out @@ -0,0 +1,2 @@ +a +c diff --git a/tests/virshtestdata/multiple-commands-8.out b/tests/virshtestd= ata/multiple-commands-8.out new file mode 100644 index 0000000000..0f7bc76605 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-8.out @@ -0,0 +1,2 @@ +a +c diff --git a/tests/virshtestdata/multiple-commands-9.out b/tests/virshtestd= ata/multiple-commands-9.out new file mode 100644 index 0000000000..a5ce8f1469 --- /dev/null +++ b/tests/virshtestdata/multiple-commands-9.out @@ -0,0 +1 @@ +a # b --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711195208113345.9964274032743; Sat, 23 Mar 2024 05:00:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EDD8E19F0; Sat, 23 Mar 2024 08:00:06 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A50862132; Sat, 23 Mar 2024 07:37:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0AF161C41; Sat, 23 Mar 2024 07:37:03 -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 E67131C6F for ; Sat, 23 Mar 2024 07:32:53 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 15AA4223C9; Fri, 22 Mar 2024 13:56:32 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 3E7F821DF3 for ; Fri, 22 Mar 2024 13:56:31 -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-606-At8vipMYNZGX4IXWFUCWYA-1; Fri, 22 Mar 2024 13:56:29 -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 D2DDA800272 for ; Fri, 22 Mar 2024 17:56:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D395492BD0 for ; Fri, 22 Mar 2024 17:56:28 +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: At8vipMYNZGX4IXWFUCWYA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 10/35] virshtest: Drop string form of expected output data of "echo" tests Date: Fri, 22 Mar 2024 18:55:48 +0100 Message-ID: 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: GTIC2JNFARAUICTHVOK346SLMBBTLLC7 X-Message-ID-Hash: GTIC2JNFARAUICTHVOK346SLMBBTLLC7 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: 1711195210084100001 Now that the output is tested against files these are not needed any more. The brief existence of both proved that the output is identical. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 73 +++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 1750cc7abd..ef2b8e7ec5 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -440,7 +440,6 @@ struct testInfo { const char *testname; /* used to generate output filename */ const char *filter; const char *const *argv; - const char *result; }; static int testCompare(const void *data) @@ -453,7 +452,7 @@ static int testCompare(const void *data) abs_srcdir, info->testname); } - return testCompareOutputLit(outfile, info->result, info->filter, info-= >argv); + return testCompareOutputLit(outfile, NULL, info->filter, info->argv); } @@ -568,7 +567,7 @@ mymain(void) abs_srcdir, testname); \ const char *myargv[] =3D { __VA_ARGS__, NULL, NULL }; \ const char **tmp =3D myargv; \ - const struct testInfo info =3D { testname, testfilter, myargv, NUL= L }; \ + const struct testInfo info =3D { testname, testfilter, myargv }; \ g_autofree char *scriptarg =3D NULL; \ if (virFileReadAll(infile, 256 * 1024, &scriptarg) < 0) { \ fprintf(stderr, "\nfailed to load '%s'\n", infile); \ @@ -581,66 +580,66 @@ mymain(void) ret =3D -1; \ } while (0); -# define DO_TEST_FULL(testname_, filter, result, ...) \ +# define DO_TEST_FULL(testname_, filter, ...) \ do { \ const char *testname =3D testname_; \ const char *myargv[] =3D { __VA_ARGS__, NULL }; \ - const struct testInfo info =3D { testname, NULL, myargv, result };= \ + const struct testInfo info =3D { testname, NULL, myargv }; \ if (virTestRun(testname, testCompare, &info) < 0) \ ret =3D -1; \ } while (0) /* automatically numbered test invocation */ -# define DO_TEST(result, ...) \ - DO_TEST_FULL(virTestCounterNext(), NULL, result, VIRSH_DEFAULT, __VA_A= RGS__); +# define DO_TEST(...) \ + DO_TEST_FULL(virTestCounterNext(), NULL, VIRSH_DEFAULT, __VA_ARGS__); /* Arg parsing quote removal tests. */ virTestCounterReset("echo-quote-removal-"); - DO_TEST("a b\n", "echo a \t b"); - DO_TEST("a \t b\n", "echo \"a \t b\""); - DO_TEST("a \t b\n", "echo 'a \t b'"); - DO_TEST("a \t b\n", "echo a\\ \\\t\\ b"); - DO_TEST("' \" \\;echo\ta\n", "echo", "'", "\"", "\\;echo\ta"); - DO_TEST("' \" ;echo a\n", "echo \\' \\\" \\;echo\ta"); - DO_TEST("' \" \\\na\n", "echo \\' \\\" \\\\;echo\ta"); - DO_TEST("' \" \\\\\n", "echo \"'\" '\"' '\\'\"\\\\\""); + DO_TEST("echo a \t b"); + DO_TEST("echo \"a \t b\""); + DO_TEST("echo 'a \t b'"); + DO_TEST("echo a\\ \\\t\\ b"); + DO_TEST("echo", "'", "\"", "\\;echo\ta"); + DO_TEST("echo \\' \\\" \\;echo\ta"); + DO_TEST("echo \\' \\\" \\\\;echo\ta"); + DO_TEST("echo \"'\" '\"' '\\'\"\\\\\""); /* Tests of echo flags. */ DO_TEST_SCRIPT("echo-escaping", NULL, VIRSH_DEFAULT); virTestCounterReset("echo-escaping-"); - DO_TEST("a A 0 + * ; . ' \" / ? =3D \n < > &\n", "echo", "a", "A", "= 0", "+", "*", ";", ".", "'", "\"", "/", "?", "=3D", " ", "\n", "<", ">", "&= "); - DO_TEST("a A 0 + '*' ';' . ''\\''' '\"' / '?' =3D ' ' '\n' '<' '>' '&'= \n", "echo", "--shell", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", = "?", "=3D", " ", "\n", "<", ">", "&"); - DO_TEST("a A 0 + * ; . ' " / ? =3D \n < > &\n", = "echo", "--xml", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", "?", "= =3D", " ", "\n", "<", ">", "&"); + DO_TEST("echo", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", "?"= , "=3D", " ", "\n", "<", ">", "&"); + DO_TEST("echo", "--shell", "a", "A", "0", "+", "*", ";", ".", "'", "\"= ", "/", "?", "=3D", " ", "\n", "<", ">", "&"); + DO_TEST("echo", "--xml", "a", "A", "0", "+", "*", ";", ".", "'", "\"",= "/", "?", "=3D", " ", "\n", "<", ">", "&"); /* Tests of -- handling. */ virTestCounterReset("dash-dash-argument-"); - DO_TEST("a\n", "--", "echo", "--shell", "a"); - DO_TEST("a\n", "--", "echo", "a", "--shell"); - DO_TEST("a --shell\n", "--", "echo", "--", "a", "--shell"); - DO_TEST("-- --shell a\n", "echo", "--", "--", "--shell", "a"); - DO_TEST("a\n", "echo --s\\h'e'\"l\"l -- a"); - DO_TEST("--shell a\n", "echo \t '-'\"-\" \t --shell \t a"); + DO_TEST("--", "echo", "--shell", "a"); + DO_TEST("--", "echo", "a", "--shell"); + DO_TEST("--", "echo", "--", "a", "--shell"); + DO_TEST("echo", "--", "--", "--shell", "a"); + DO_TEST("echo --s\\h'e'\"l\"l -- a"); + DO_TEST("echo \t '-'\"-\" \t --shell \t a"); /* Tests of alias handling. */ DO_TEST_SCRIPT("echo-alias", NULL, VIRSH_DEFAULT); - DO_TEST_FULL("echo-alias-argv", NULL, "hello\n", VIRSH_DEFAULT, "echo"= , "--str", "hello"); + DO_TEST_FULL("echo-alias-argv", NULL, VIRSH_DEFAULT, "echo", "--str", = "hello"); /* Tests of multiple commands. */ virTestCounterReset("multiple-commands-"); - DO_TEST("a\nb\n", " echo a; echo b;"); - DO_TEST("a\nb\n", "\necho a\n echo b\n"); - DO_TEST("a\nb\n", "ec\\\nho a\n echo \\\n b;"); - DO_TEST("a\n b\n", "\"ec\\\nho\" a\n echo \"\\\n b\";"); - DO_TEST("a\n\\\n b\n", "ec\\\nho a\n echo '\\\n b';"); - DO_TEST("a\n", "echo a # b"); - DO_TEST("a\nc\n", "echo a #b\necho c"); - DO_TEST("a\nc\n", "echo a # b\\\necho c"); - DO_TEST("a # b\n", "echo a '#' b"); - DO_TEST("a # b\n", "echo a \\# b"); - DO_TEST("a\n", "#unbalanced; 'quotes\"\necho a # b"); - DO_TEST("a\n", "\\# ignored;echo a\n'#also' ignored"); + DO_TEST(" echo a; echo b;"); + DO_TEST("\necho a\n echo b\n"); + DO_TEST("ec\\\nho a\n echo \\\n b;"); + DO_TEST("\"ec\\\nho\" a\n echo \"\\\n b\";"); + DO_TEST("ec\\\nho a\n echo '\\\n b';"); + DO_TEST("echo a # b"); + DO_TEST("echo a #b\necho c"); + DO_TEST("echo a # b\\\necho c"); + DO_TEST("echo a '#' b"); + DO_TEST("echo a \\# b"); + DO_TEST("#unbalanced; 'quotes\"\necho a # b"); + DO_TEST("\\# ignored;echo a\n'#also' ignored"); /* test of splitting in vshStringToArray */ DO_TEST_SCRIPT("echo-split", NULL, VIRSH_DEFAULT, "-q"); --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711195720501196.46858571580003; Sat, 23 Mar 2024 05:08:40 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4503E21F3; Sat, 23 Mar 2024 08:08:39 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1ACA72291; Sat, 23 Mar 2024 07:39:46 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 866E31D18; Sat, 23 Mar 2024 07:39:32 -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 232A11D67 for ; Sat, 23 Mar 2024 07:32:55 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 7005D223BF; Fri, 22 Mar 2024 13:56:33 -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 C20A0223CA for ; Fri, 22 Mar 2024 13:56:32 -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-551-ITwxnhknNtGpK4YWG85sPg-1; Fri, 22 Mar 2024 13:56:30 -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 B8837800264 for ; Fri, 22 Mar 2024 17:56:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32130492BD0 for ; Fri, 22 Mar 2024 17:56:29 +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: ITwxnhknNtGpK4YWG85sPg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 11/35] virshtest: Replace list and nodeinfo tests by equivalent VIR_TEST_SCRIPT variant Date: Fri, 22 Mar 2024 18:55:49 +0100 Message-ID: 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: IO7ZWYZKQDTK5PFREXX7PVR4GWMKJOTS X-Message-ID-Hash: IO7ZWYZKQDTK5PFREXX7PVR4GWMKJOTS 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: 1711195721605100001 Add the basic list and info commands into a script and run it via VIR_TEST_RUN_SCRIPT to simplify the code and save up on 'virsh' instances exec'd for the test. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 79 ++-------------------------- tests/virshtestdata/info-custom.in | 2 + tests/virshtestdata/info-custom.out | 15 ++++++ tests/virshtestdata/info-default.in | 2 + tests/virshtestdata/info-default.out | 13 +++++ 5 files changed, 35 insertions(+), 76 deletions(-) create mode 100644 tests/virshtestdata/info-custom.in create mode 100644 tests/virshtestdata/info-custom.out create mode 100644 tests/virshtestdata/info-default.in create mode 100644 tests/virshtestdata/info-default.out diff --git a/tests/virshtest.c b/tests/virshtest.c index ef2b8e7ec5..cdd5468bc1 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -159,66 +159,6 @@ static char *custom_uri; "--connect", \ custom_uri -static int testCompareListDefault(const void *data) -{ - const char *const argv[] =3D { VIRSH_DEFAULT, "list", NULL }; - const char *exp =3D "\ - Id Name State\n\ -----------------------\n\ - 1 test running\n\ -\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareListCustom(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "list", NULL }; - const char *exp =3D "\ - Id Name State\n\ -----------------------\n\ - 1 fv0 running\n\ - 2 fc4 running\n\ - 3 fc5 running\n\ -\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareNodeinfoDefault(const void *data) -{ - const char *const argv[] =3D { VIRSH_DEFAULT, "nodeinfo", NULL }; - const char *exp =3D "\ -CPU model: i686\n\ -CPU(s): 16\n\ -CPU frequency: 1400 MHz\n\ -CPU socket(s): 2\n\ -Core(s) per socket: 2\n\ -Thread(s) per core: 2\n\ -NUMA cell(s): 2\n\ -Memory size: 3145728 KiB\n\ -\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareNodeinfoCustom(const void *data) -{ - const char *const argv[] =3D { - VIRSH_CUSTOM, - "nodeinfo", - NULL - }; - const char *exp =3D "\ -CPU model: i986\n\ -CPU(s): 50\n\ -CPU frequency: 6000 MHz\n\ -CPU socket(s): 4\n\ -Core(s) per socket: 4\n\ -Thread(s) per core: 2\n\ -NUMA cell(s): 4\n\ -Memory size: 8192000 KiB\n\ -\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - static int testCompareDominfoByID(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", "2", NULL }; @@ -464,22 +404,6 @@ mymain(void) custom_uri =3D g_strdup_printf("test://%s/../examples/xml/test/testnod= e.xml", abs_srcdir); - if (virTestRun("virsh list (default)", - testCompareListDefault, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh list (custom)", - testCompareListCustom, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh nodeinfo (default)", - testCompareNodeinfoDefault, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh nodeinfo (custom)", - testCompareNodeinfoCustom, NULL) !=3D 0) - ret =3D -1; - if (virTestRun("virsh dominfo (by id)", testCompareDominfoByID, NULL) !=3D 0) ret =3D -1; @@ -580,6 +504,9 @@ mymain(void) ret =3D -1; \ } while (0); + DO_TEST_SCRIPT("info-default", NULL, VIRSH_DEFAULT); + DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM); + # define DO_TEST_FULL(testname_, filter, ...) \ do { \ const char *testname =3D testname_; \ diff --git a/tests/virshtestdata/info-custom.in b/tests/virshtestdata/info-= custom.in new file mode 100644 index 0000000000..7767ef1c49 --- /dev/null +++ b/tests/virshtestdata/info-custom.in @@ -0,0 +1,2 @@ +list +nodeinfo diff --git a/tests/virshtestdata/info-custom.out b/tests/virshtestdata/info= -custom.out new file mode 100644 index 0000000000..8307baf4eb --- /dev/null +++ b/tests/virshtestdata/info-custom.out @@ -0,0 +1,15 @@ + Id Name State +---------------------- + 1 fv0 running + 2 fc4 running + 3 fc5 running + +CPU model: i986 +CPU(s): 50 +CPU frequency: 6000 MHz +CPU socket(s): 4 +Core(s) per socket: 4 +Thread(s) per core: 2 +NUMA cell(s): 4 +Memory size: 8192000 KiB + diff --git a/tests/virshtestdata/info-default.in b/tests/virshtestdata/info= -default.in new file mode 100644 index 0000000000..7767ef1c49 --- /dev/null +++ b/tests/virshtestdata/info-default.in @@ -0,0 +1,2 @@ +list +nodeinfo diff --git a/tests/virshtestdata/info-default.out b/tests/virshtestdata/inf= o-default.out new file mode 100644 index 0000000000..56559ab3e4 --- /dev/null +++ b/tests/virshtestdata/info-default.out @@ -0,0 +1,13 @@ + Id Name State +---------------------- + 1 test running + +CPU model: i686 +CPU(s): 16 +CPU frequency: 1400 MHz +CPU socket(s): 2 +Core(s) per socket: 2 +Thread(s) per core: 2 +NUMA cell(s): 2 +Memory size: 3145728 KiB + --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711193690409708.3353842597572; Sat, 23 Mar 2024 04:34:50 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DDD841AAB; Sat, 23 Mar 2024 07:34:48 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C55811DE2; Sat, 23 Mar 2024 07:33:01 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1675F1DCF; Sat, 23 Mar 2024 07:32:56 -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 4A82519CD for ; Sat, 23 Mar 2024 07:32:51 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 8DD7A223D1; Fri, 22 Mar 2024 13:56:34 -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 A95DF223CB for ; Fri, 22 Mar 2024 13:56:33 -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-279-KGqQV190Pvu8waCyKc158g-1; Fri, 22 Mar 2024 13:56:30 -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 9E9E084B165 for ; Fri, 22 Mar 2024 17:56:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 184EA492BDA for ; Fri, 22 Mar 2024 17:56:29 +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: KGqQV190Pvu8waCyKc158g-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 12/35] virshtest: Adapt tests for domain id lookup and state query to DO_TEST_SCRIPT Date: Fri, 22 Mar 2024 18:55:50 +0100 Message-ID: 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: GRV6M5P26WK4HZ3NFPSBCWEAOTDDF25Y X-Message-ID-Hash: GRV6M5P26WK4HZ3NFPSBCWEAOTDDF25Y 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: 1711193691175100001 All of the commands can be tested in one 'virsh' run in batch mode and tested against a file rather than hardcoded strings. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 204 +----------------------------- tests/virshtestdata/domain-id.in | 18 +++ tests/virshtestdata/domain-id.out | 73 +++++++++++ 3 files changed, 92 insertions(+), 203 deletions(-) create mode 100644 tests/virshtestdata/domain-id.in create mode 100644 tests/virshtestdata/domain-id.out diff --git a/tests/virshtest.c b/tests/virshtest.c index cdd5468bc1..53c9042330 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -18,59 +18,10 @@ main(void) #else -# define DOM_FC4_UUID "ef861801-45b9-11cb-88e3-afbfe5370493" -# define DOM_FC5_UUID "08721f99-3d1d-4aec-96eb-97803297bb36" -# define SECURITY_LABEL "libvirt-test (enforcing)" -# define FC4_MESSAGES "tainted: network configuration using opaque shell s= cripts" -# define FC5_MESSAGES "tainted: running with undesirable elevated privileg= es\n\ - tainted: network configuration using opaque shell scripts\= n\ - tainted: use of host cdrom passthrough\n\ - tainted: custom device tree blob used\n\ - tainted: use of deprecated configuration settings\n\ - deprecated configuration: CPU model Deprecated-Test" # define GET_BLKIO_PARAMETER "/dev/hda,700" # define SET_BLKIO_PARAMETER "/dev/hda,1000" # define EQUAL "=3D" -static const char *dominfo_fc4 =3D "\ -Id: 2\n\ -Name: fc4\n\ -UUID: " DOM_FC4_UUID "\n\ -OS Type: linux\n\ -State: running\n\ -CPU(s): 1\n\ -Max memory: 261072 KiB\n\ -Used memory: 131072 KiB\n\ -Persistent: yes\n\ -Autostart: disable\n\ -Managed save: no\n\ -Security model: testSecurity\n\ -Security DOI: \n\ -Security label: " SECURITY_LABEL "\n\ -Messages: " FC4_MESSAGES "\n\ -\n"; -static const char *domuuid_fc4 =3D DOM_FC4_UUID "\n\n"; -static const char *domid_fc4 =3D "2\n\n"; -static const char *domname_fc4 =3D "fc4\n\n"; -static const char *domstate_fc4 =3D "running\n\n"; -static const char *dominfo_fc5 =3D "\ -Id: 3\n\ -Name: fc5\n\ -UUID: " DOM_FC5_UUID "\n\ -OS Type: linux\n\ -State: running\n\ -CPU(s): 4\n\ -Max memory: 2097152 KiB\n\ -Used memory: 2097152 KiB\n\ -Persistent: yes\n\ -Autostart: disable\n\ -Managed save: no\n\ -Security model: testSecurity\n\ -Security DOI: \n\ -Security label: " SECURITY_LABEL "\n\ -Messages: " FC5_MESSAGES "\n\ -\n"; - static const char *get_blkio_parameters =3D "\ weight : 800\n\ device_weight : " GET_BLKIO_PARAMETER "\n\ @@ -159,104 +110,6 @@ static char *custom_uri; "--connect", \ custom_uri -static int testCompareDominfoByID(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", "2", NULL }; - const char *exp =3D dominfo_fc4; - return testCompareOutputLit((const char *) data, exp, "\nCPU time:", a= rgv); -} - -static int testCompareDominfoByUUID(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", DOM_FC4_UUID, = NULL }; - const char *exp =3D dominfo_fc4; - return testCompareOutputLit((const char *) data, exp, "\nCPU time:", a= rgv); -} - -static int testCompareDominfoByName(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", "fc4", NULL }; - const char *exp =3D dominfo_fc4; - return testCompareOutputLit((const char *) data, exp, "\nCPU time:", a= rgv); -} - -static int testCompareTaintedDominfoByName(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "dominfo", "fc5", NULL }; - const char *exp =3D dominfo_fc5; - return testCompareOutputLit((const char *) data, exp, "\nCPU time:", a= rgv); -} - -static int testCompareDomuuidByID(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domuuid", "2", NULL }; - const char *exp =3D domuuid_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomuuidByName(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domuuid", "fc4", NULL }; - const char *exp =3D domuuid_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomidByName(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domid", "fc4", NULL }; - const char *exp =3D domid_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomidByUUID(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domid", DOM_FC4_UUID, NU= LL }; - const char *exp =3D domid_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomnameByID(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domname", "2", NULL }; - const char *exp =3D domname_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomnameByUUID(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domname", DOM_FC4_UUID, = NULL }; - const char *exp =3D domname_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomstateByID(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domstate", "2", NULL }; - const char *exp =3D domstate_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomstateByUUID(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domstate", DOM_FC4_UUID,= NULL }; - const char *exp =3D domstate_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomstateByName(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domstate", "fc4", NULL }; - const char *exp =3D domstate_fc4; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareDomControlInfoByName(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domcontrol", "fc4", NULL= }; - const char *exp =3D "ok\n\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - static int testCompareGetBlkioParameters(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "blkiotune", "fv0", NULL = }; @@ -404,62 +257,6 @@ mymain(void) custom_uri =3D g_strdup_printf("test://%s/../examples/xml/test/testnod= e.xml", abs_srcdir); - if (virTestRun("virsh dominfo (by id)", - testCompareDominfoByID, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh dominfo (by uuid)", - testCompareDominfoByUUID, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh dominfo (by name)", - testCompareDominfoByName, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh dominfo (by name, more tainted messages)", - testCompareTaintedDominfoByName, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domid (by name)", - testCompareDomidByName, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domid (by uuid)", - testCompareDomidByUUID, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domuuid (by id)", - testCompareDomuuidByID, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domuuid (by name)", - testCompareDomuuidByName, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domname (by id)", - testCompareDomnameByID, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domname (by uuid)", - testCompareDomnameByUUID, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domstate (by id)", - testCompareDomstateByID, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domstate (by uuid)", - testCompareDomstateByUUID, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domstate (by name)", - testCompareDomstateByName, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh domcontrol (by name)", - testCompareDomControlInfoByName, NULL) !=3D 0) - ret =3D -1; - if (virTestRun("virsh blkiotune (get parameters)", testCompareGetBlkioParameters, NULL) !=3D 0) ret =3D -1; @@ -506,6 +303,7 @@ mymain(void) DO_TEST_SCRIPT("info-default", NULL, VIRSH_DEFAULT); DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM); + DO_TEST_SCRIPT("domain-id", "\nCPU time:", VIRSH_CUSTOM); # define DO_TEST_FULL(testname_, filter, ...) \ do { \ diff --git a/tests/virshtestdata/domain-id.in b/tests/virshtestdata/domain-= id.in new file mode 100644 index 0000000000..6605baa090 --- /dev/null +++ b/tests/virshtestdata/domain-id.in @@ -0,0 +1,18 @@ +dominfo ef861801-45b9-11cb-88e3-afbfe5370493 +dominfo fc4 +dominfo fc5 + +domid fc4 +domid ef861801-45b9-11cb-88e3-afbfe5370493 + +domuuid 2 +domuuid fc4 + +domname 2 +domname ef861801-45b9-11cb-88e3-afbfe5370493 + +domstate 2 +domstate ef861801-45b9-11cb-88e3-afbfe5370493 +domstate fc4 + +domcontrol fc4 diff --git a/tests/virshtestdata/domain-id.out b/tests/virshtestdata/domain= -id.out new file mode 100644 index 0000000000..8e6174fd21 --- /dev/null +++ b/tests/virshtestdata/domain-id.out @@ -0,0 +1,73 @@ +Id: 2 +Name: fc4 +UUID: ef861801-45b9-11cb-88e3-afbfe5370493 +OS Type: linux +State: running +CPU(s): 1 +Max memory: 261072 KiB +Used memory: 131072 KiB +Persistent: yes +Autostart: disable +Managed save: no +Security model: testSecurity +Security DOI: =20 +Security label: libvirt-test (enforcing) +Messages: tainted: network configuration using opaque shell scripts + +Id: 2 +Name: fc4 +UUID: ef861801-45b9-11cb-88e3-afbfe5370493 +OS Type: linux +State: running +CPU(s): 1 +Max memory: 261072 KiB +Used memory: 131072 KiB +Persistent: yes +Autostart: disable +Managed save: no +Security model: testSecurity +Security DOI: =20 +Security label: libvirt-test (enforcing) +Messages: tainted: network configuration using opaque shell scripts + +Id: 3 +Name: fc5 +UUID: 08721f99-3d1d-4aec-96eb-97803297bb36 +OS Type: linux +State: running +CPU(s): 4 +Max memory: 2097152 KiB +Used memory: 2097152 KiB +Persistent: yes +Autostart: disable +Managed save: no +Security model: testSecurity +Security DOI: =20 +Security label: libvirt-test (enforcing) +Messages: tainted: running with undesirable elevated privileges + tainted: network configuration using opaque shell scripts + tainted: use of host cdrom passthrough + tainted: custom device tree blob used + tainted: use of deprecated configuration settings + deprecated configuration: CPU model Deprecated-Test + +2 + +2 + +ef861801-45b9-11cb-88e3-afbfe5370493 + +ef861801-45b9-11cb-88e3-afbfe5370493 + +fc4 + +fc4 + +running + +running + +running + +ok + --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711195406723594.2763545802322; Sat, 23 Mar 2024 05:03:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 827E71879; Sat, 23 Mar 2024 08:03:25 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4A6C02295; Sat, 23 Mar 2024 07:38:36 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 467C621C2; Sat, 23 Mar 2024 07:38:30 -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 B8DB41D1C for ; Sat, 23 Mar 2024 07:32:54 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 94B8D223CB; Fri, 22 Mar 2024 13:56:34 -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 DF4FA223D0 for ; Fri, 22 Mar 2024 13:56:33 -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-313-kKL4i4v8N2GNVV5aUNSeGg-1; Fri, 22 Mar 2024 13:56:31 -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 87A4A1865427 for ; Fri, 22 Mar 2024 17:56:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0278F492BDA for ; Fri, 22 Mar 2024 17:56:30 +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: kKL4i4v8N2GNVV5aUNSeGg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 13/35] virshtest: Adapt 'blkiotune' tests to DO_TEST_SCRIPT Date: Fri, 22 Mar 2024 18:55:51 +0100 Message-ID: <3e43541aefcebc5f3c224cc657106642999e0aed.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: FM3P3QBUVNA5JJWM6G42Z3MOCZ4A2XYB X-Message-ID-Hash: FM3P3QBUVNA5JJWM6G42Z3MOCZ4A2XYB 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: 1711195408732100001 The query and update can be tested in one run and validated against files rather than hardcoded strings. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 56 +------------------------------ tests/virshtestdata/blkiotune.in | 3 ++ tests/virshtestdata/blkiotune.out | 15 +++++++++ 3 files changed, 19 insertions(+), 55 deletions(-) create mode 100644 tests/virshtestdata/blkiotune.in create mode 100644 tests/virshtestdata/blkiotune.out diff --git a/tests/virshtest.c b/tests/virshtest.c index 53c9042330..6c2d4cfc67 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -18,29 +18,8 @@ main(void) #else -# define GET_BLKIO_PARAMETER "/dev/hda,700" -# define SET_BLKIO_PARAMETER "/dev/hda,1000" # define EQUAL "=3D" -static const char *get_blkio_parameters =3D "\ -weight : 800\n\ -device_weight : " GET_BLKIO_PARAMETER "\n\ -device_read_iops_sec: " GET_BLKIO_PARAMETER "\n\ -device_write_iops_sec: " GET_BLKIO_PARAMETER "\n\ -device_read_bytes_sec: " GET_BLKIO_PARAMETER "\n\ -device_write_bytes_sec: " GET_BLKIO_PARAMETER "\n\ -\n"; - -static const char *set_blkio_parameters =3D "\ -\n\ -weight : 500\n\ -device_weight : " SET_BLKIO_PARAMETER "\n\ -device_read_iops_sec: " SET_BLKIO_PARAMETER "\n\ -device_write_iops_sec: " SET_BLKIO_PARAMETER "\n\ -device_read_bytes_sec: " SET_BLKIO_PARAMETER "\n\ -device_write_bytes_sec: " SET_BLKIO_PARAMETER "\n\ -\n"; - static void testFilterLine(char *buffer, const char *toRemove) { @@ -110,32 +89,6 @@ static char *custom_uri; "--connect", \ custom_uri -static int testCompareGetBlkioParameters(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "blkiotune", "fv0", NULL = }; - const char *exp =3D get_blkio_parameters; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testCompareSetBlkioParameters(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "blkiotune fv0\ - --weight 500\ - --device-weights\ - " SET_BLKIO_PARAMETER "\ - --device-read-iops-sec\ - " SET_BLKIO_PARAMETER "\ - --device-write-iops-sec\ - " SET_BLKIO_PARAMETER "\ - --device-read-bytes-sec\ - " SET_BLKIO_PARAMETER "\ - --device-write-bytes-sec\ - " SET_BLKIO_PARAMETER ";\ - blkiotune fv0", NULL }; - const char *exp =3D set_blkio_parameters; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - static int testIOThreadAdd(const void *data) { const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadinfo --domain fc= 4;\ @@ -257,14 +210,6 @@ mymain(void) custom_uri =3D g_strdup_printf("test://%s/../examples/xml/test/testnod= e.xml", abs_srcdir); - if (virTestRun("virsh blkiotune (get parameters)", - testCompareGetBlkioParameters, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh blkiotune (set parameters)", - testCompareSetBlkioParameters, NULL) !=3D 0) - ret =3D -1; - if (virTestRun("virsh iothreadadd", testIOThreadAdd, NULL) !=3D 0) ret =3D -1; @@ -304,6 +249,7 @@ mymain(void) DO_TEST_SCRIPT("info-default", NULL, VIRSH_DEFAULT); DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM); DO_TEST_SCRIPT("domain-id", "\nCPU time:", VIRSH_CUSTOM); + DO_TEST_SCRIPT("blkiotune", NULL, VIRSH_CUSTOM); # define DO_TEST_FULL(testname_, filter, ...) \ do { \ diff --git a/tests/virshtestdata/blkiotune.in b/tests/virshtestdata/blkiotu= ne.in new file mode 100644 index 0000000000..db1ebb119f --- /dev/null +++ b/tests/virshtestdata/blkiotune.in @@ -0,0 +1,3 @@ +blkiotune fv0 +blkiotune fv0 --weight 500 --device-weights /dev/hda,1000 --device-read-io= ps-sec /dev/hda,1000 --device-write-iops-sec /dev/hda,1000 --device-read-by= tes-sec /dev/hda,1000 --device-write-bytes-sec /dev/hda,1000 +blkiotune fv0 diff --git a/tests/virshtestdata/blkiotune.out b/tests/virshtestdata/blkiot= une.out new file mode 100644 index 0000000000..fa267e17c7 --- /dev/null +++ b/tests/virshtestdata/blkiotune.out @@ -0,0 +1,15 @@ +weight : 800 +device_weight : /dev/hda,700 +device_read_iops_sec: /dev/hda,700 +device_write_iops_sec: /dev/hda,700 +device_read_bytes_sec: /dev/hda,700 +device_write_bytes_sec: /dev/hda,700 + + +weight : 500 +device_weight : /dev/hda,1000 +device_read_iops_sec: /dev/hda,1000 +device_write_iops_sec: /dev/hda,1000 +device_read_bytes_sec: /dev/hda,1000 +device_write_bytes_sec: /dev/hda,1000 + --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711194476193223.53710838046823; Sat, 23 Mar 2024 04:47:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0235323B8; Sat, 23 Mar 2024 07:47:54 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1CC741B4B; Sat, 23 Mar 2024 07:34:38 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2F38C1F2F; Sat, 23 Mar 2024 07:34:32 -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 762781B83 for ; Sat, 23 Mar 2024 07:32:52 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id B6BB3223D0; Fri, 22 Mar 2024 13:56:35 -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 344E4223CF for ; Fri, 22 Mar 2024 13:56:35 -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-195-cFxw-2Z_Ppq_c27WUGOPLQ-1; Fri, 22 Mar 2024 13:56:32 -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 701331865428 for ; Fri, 22 Mar 2024 17:56:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD522492BDA for ; Fri, 22 Mar 2024 17:56:31 +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: cFxw-2Z_Ppq_c27WUGOPLQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 14/35] virshtest: Adapt 'iothread' tests to DO_TEST_SCRIPT Date: Fri, 22 Mar 2024 18:55:52 +0100 Message-ID: <02b707534a07b085d35b42674bb84e008843474c.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: 6GB2XLZDCGA66CNPVED6XGDOXICJEMGX X-Message-ID-Hash: 6GB2XLZDCGA66CNPVED6XGDOXICJEMGX 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: 1711194478294100001 Adapt the tests to be invoked in one run. Note that multiple fake VMs were used for the distinct tests so that they don't influence each other. This is the final coversion of tests to run in batch mode which halved the runtime of 'virshtest' on my machine (1.11s vs 2.33s). Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 112 +----------------------------- tests/virshtestdata/iothreads.in | 14 ++++ tests/virshtestdata/iothreads.out | 51 ++++++++++++++ 3 files changed, 66 insertions(+), 111 deletions(-) create mode 100644 tests/virshtestdata/iothreads.in create mode 100644 tests/virshtestdata/iothreads.out diff --git a/tests/virshtest.c b/tests/virshtest.c index 6c2d4cfc67..02bfb363c4 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -18,8 +18,6 @@ main(void) #else -# define EQUAL "=3D" - static void testFilterLine(char *buffer, const char *toRemove) { @@ -89,99 +87,6 @@ static char *custom_uri; "--connect", \ custom_uri -static int testIOThreadAdd(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadinfo --domain fc= 4;\ - iothreadadd --domain fc4 --id 6;\ - iothreadinfo --domain fc4", NULL}; - const char *exp =3D "\ - IOThread ID CPU Affinity\n\ ------------------------------\n\ - 2 0\n\ - 4 0\n\ -\n\ -\n\ - IOThread ID CPU Affinity\n\ ------------------------------\n\ - 2 0\n\ - 4 0\n\ - 6 0\n\ -\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testIOThreadDel(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "iothreadinfo --domain fc= 4;\ - iothreaddel --domain fc4 --id 2;\ - iothreadinfo --domain fc4", NULL}; - const char *exp =3D "\ - IOThread ID CPU Affinity\n\ ------------------------------\n\ - 2 0\n\ - 4 0\n\ -\n\ -\n\ - IOThread ID CPU Affinity\n\ ------------------------------\n\ - 4 0\n\ -\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testIOThreadSet(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, "domstats --domain fc4;\ - iothreadset --domain fc4\ - --id 2 --poll-max-ns 100\ - --poll-shrink 10 --poll-grow 10;\ - domstats --domain fc4", NULL}; - const char *exp =3D "\ -Domain: 'fc4'\n\ - state.state" EQUAL "1\n\ - state.reason" EQUAL "0\n\ - iothread.count" EQUAL "2\n\ - iothread.2.poll-max-ns" EQUAL "32768\n\ - iothread.2.poll-grow" EQUAL "0\n\ - iothread.2.poll-shrink" EQUAL "0\n\ - iothread.4.poll-max-ns" EQUAL "32768\n\ - iothread.4.poll-grow" EQUAL "0\n\ - iothread.4.poll-shrink" EQUAL "0\n\n\ -\n\ -Domain: 'fc4'\n\ - state.state" EQUAL "1\n\ - state.reason" EQUAL "0\n\ - iothread.count" EQUAL "2\n\ - iothread.2.poll-max-ns" EQUAL "100\n\ - iothread.2.poll-grow" EQUAL "10\n\ - iothread.2.poll-shrink" EQUAL "10\n\ - iothread.4.poll-max-ns" EQUAL "32768\n\ - iothread.4.poll-grow" EQUAL "0\n\ - iothread.4.poll-shrink" EQUAL "0\n\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - -static int testIOThreadPin(const void *data) -{ - const char *const argv[] =3D { VIRSH_CUSTOM, - "iothreadadd --domain fc5 --id 2;\ - iothreadinfo --domain fc5;\ - iothreadpin --domain fc5 --iothread 2\ - --cpulist 0;\ - iothreadinfo --domain fc5", NULL}; - const char *exp =3D "\n\ - IOThread ID CPU Affinity\n\ ------------------------------\n\ - 2 0-3\n\ -\n\ -\n\ - IOThread ID CPU Affinity\n\ ------------------------------\n\ - 2 0\n\ -\n"; - return testCompareOutputLit((const char *) data, exp, NULL, argv); -} - struct testInfo { const char *testname; /* used to generate output filename */ const char *filter; @@ -210,22 +115,6 @@ mymain(void) custom_uri =3D g_strdup_printf("test://%s/../examples/xml/test/testnod= e.xml", abs_srcdir); - if (virTestRun("virsh iothreadadd", - testIOThreadAdd, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh iothreaddel", - testIOThreadDel, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh iothreadset", - testIOThreadSet, NULL) !=3D 0) - ret =3D -1; - - if (virTestRun("virsh iothreadpin", - testIOThreadPin, NULL) !=3D 0) - ret =3D -1; - # define DO_TEST_SCRIPT(testname_, testfilter, ...) \ { \ const char *testname =3D testname_; \ @@ -250,6 +139,7 @@ mymain(void) DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM); DO_TEST_SCRIPT("domain-id", "\nCPU time:", VIRSH_CUSTOM); DO_TEST_SCRIPT("blkiotune", NULL, VIRSH_CUSTOM); + DO_TEST_SCRIPT("iothreads", NULL, VIRSH_CUSTOM); # define DO_TEST_FULL(testname_, filter, ...) \ do { \ diff --git a/tests/virshtestdata/iothreads.in b/tests/virshtestdata/iothrea= ds.in new file mode 100644 index 0000000000..25ebcb5cda --- /dev/null +++ b/tests/virshtestdata/iothreads.in @@ -0,0 +1,14 @@ +iothreadinfo --domain fc4 +iothreadadd --domain fc4 --id 6 +iothreadinfo --domain fc4 +iothreaddel --domain fc4 --id 2 +iothreadinfo --domain fc4 + +domstats --domain fc4 +iothreadset --domain fc4 --id 6 --poll-max-ns 100 --poll-shrink 10 --poll-= grow 10 +domstats --domain fc4 + +iothreadadd --domain fc5 --id 2 +iothreadinfo --domain fc5 +iothreadpin --domain fc5 --iothread 2 --cpulist 0 +iothreadinfo --domain fc5 diff --git a/tests/virshtestdata/iothreads.out b/tests/virshtestdata/iothre= ads.out new file mode 100644 index 0000000000..1e38733bcf --- /dev/null +++ b/tests/virshtestdata/iothreads.out @@ -0,0 +1,51 @@ + IOThread ID CPU Affinity +----------------------------- + 2 0 + 4 0 + + + IOThread ID CPU Affinity +----------------------------- + 2 0 + 4 0 + 6 0 + + + IOThread ID CPU Affinity +----------------------------- + 4 0 + 6 0 + +Domain: 'fc4' + state.state=3D1 + state.reason=3D0 + iothread.count=3D2 + iothread.4.poll-max-ns=3D32768 + iothread.4.poll-grow=3D0 + iothread.4.poll-shrink=3D0 + iothread.6.poll-max-ns=3D32768 + iothread.6.poll-grow=3D0 + iothread.6.poll-shrink=3D0 + + +Domain: 'fc4' + state.state=3D1 + state.reason=3D0 + iothread.count=3D2 + iothread.4.poll-max-ns=3D32768 + iothread.4.poll-grow=3D0 + iothread.4.poll-shrink=3D0 + iothread.6.poll-max-ns=3D100 + iothread.6.poll-grow=3D10 + iothread.6.poll-shrink=3D10 + + + IOThread ID CPU Affinity +----------------------------- + 2 0-3 + + + IOThread ID CPU Affinity +----------------------------- + 2 0 + --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 17111956586681010.1503860562783; Sat, 23 Mar 2024 05:07:38 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7F6261EBD; Sat, 23 Mar 2024 08:07:37 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E8E5A228A; Sat, 23 Mar 2024 07:39:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B47A21D43; Sat, 23 Mar 2024 07:39:30 -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 1A4AA1D43 for ; Sat, 23 Mar 2024 07:32:55 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 74D9C223D5; Fri, 22 Mar 2024 13:56:36 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 058F2223D4 for ; Fri, 22 Mar 2024 13:56:36 -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-444-kQlHqeWrMQmjgmw2g0JWjw-1; Fri, 22 Mar 2024 13:56:33 -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 9A63080F7E4 for ; Fri, 22 Mar 2024 17:56:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5256492BDA for ; Fri, 22 Mar 2024 17:56:32 +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: kQlHqeWrMQmjgmw2g0JWjw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 15/35] virshtest: Drop support for testing against hardcoded strings Date: Fri, 22 Mar 2024 18:55:53 +0100 Message-ID: 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: GO7ONKEDK7EXYEODLBA4WNDTFT4AYTR2 X-Message-ID-Hash: GO7ONKEDK7EXYEODLBA4WNDTFT4AYTR2 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: 1711195659245100001 Now that all tests were converted, this is no longer needed. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virshtest.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/virshtest.c b/tests/virshtest.c index 02bfb363c4..926f919d8d 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -36,7 +36,6 @@ static void testFilterLine(char *buffer, static int testCompareOutputLit(const char *expectFile, - const char *expectData, const char *filter, const char *const argv[]) { @@ -64,15 +63,8 @@ testCompareOutputLit(const char *expectFile, if (filter) testFilterLine(actual, filter); - if (expectData) { - if (virTestCompareToString(expectData, actual) < 0) - return -1; - } - - if (expectFile) { - if (virTestCompareToFileFull(actual, expectFile, false) < 0) - return -1; - } + if (virTestCompareToFileFull(actual, expectFile, false) < 0) + return -1; return 0; } @@ -103,7 +95,7 @@ static int testCompare(const void *data) abs_srcdir, info->testname); } - return testCompareOutputLit(outfile, NULL, info->filter, info->argv); + return testCompareOutputLit(outfile, info->filter, info->argv); } --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 Reviewed-by: J=C3=A1n Tomko --- 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 From nobody Sat May 11 20:13:42 2024 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 1711194761812756.0537128930191; Sat, 23 Mar 2024 04:52:41 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B4CC51D12; Sat, 23 Mar 2024 07:52:40 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5D6291BCD; Sat, 23 Mar 2024 07:35:46 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 94A091BC1; Sat, 23 Mar 2024 07:35:40 -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 1DEC31BF5 for ; Sat, 23 Mar 2024 07:32:53 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 6F605223D7; Fri, 22 Mar 2024 13:56:39 -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 B135F223D4 for ; Fri, 22 Mar 2024 13:56:38 -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-613-fJ_Evnx4MbGdWImkjhMHwA-1; Fri, 22 Mar 2024 13:56:36 -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 D355A29AB426 for ; Fri, 22 Mar 2024 17:56:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AAF8492BDB for ; Fri, 22 Mar 2024 17:56:35 +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: fJ_Evnx4MbGdWImkjhMHwA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 17/35] virshtest: Adapt 'snapshot-create-as' arg handling tests from 'virsh-optparse' Date: Fri, 22 Mar 2024 18:55:55 +0100 Message-ID: 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: R4YYR4DBZRIWIKJEJYVUO55IE7AXPH2S X-Message-ID-Hash: R4YYR4DBZRIWIKJEJYVUO55IE7AXPH2S 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: 1711194762887100001 Move the argument parsing tests excercising 'virsh snapshot-create-as' from 'virsh-optparse' to 'virshtest'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virsh-optparse | 60 -------------- tests/virshtest.c | 1 + tests/virshtestdata/snapshot-create-args.in | 9 +++ tests/virshtestdata/snapshot-create-args.out | 82 ++++++++++++++++++++ 4 files changed, 92 insertions(+), 60 deletions(-) create mode 100644 tests/virshtestdata/snapshot-create-args.in create mode 100644 tests/virshtestdata/snapshot-create-args.out diff --git a/tests/virsh-optparse b/tests/virsh-optparse index 77e754d73a..10fdf7727e 100755 --- a/tests/virsh-optparse +++ b/tests/virsh-optparse @@ -32,66 +32,6 @@ fail=3D0 test_url=3Dtest:///default -# Another complex parsing example -cat <<\EOF > exp-out || framework_failure - - 1<2 - - - - - - - - - -EOF -$VIRSH -q -c $test_url snapshot-create-as --print-xml test \ - --diskspec 'vda,file=3Da&b,,c,snapshot=3Dexternal' --description '1<2' \ - --diskspec vdb --memspec file=3Dd,,e >out 2>>err || fail=3D1 -compare exp-out out || fail=3D1 - -cat <<\EOF > exp-out || framework_failure - - name - vda - - - - - -EOF -$VIRSH -q -c $test_url snapshot-create-as --print-xml test name vda vdb \ - >out 2>>err || fail=3D1 -compare exp-out out || fail=3D1 - -cat <<\EOF > exp-out || framework_failure - - name - desc - - - - - - -EOF -for args in \ - 'test name desc vda vdb' \ - 'test name desc --diskspec vda vdb' \ - 'test name desc --diskspec vda --diskspec vdb' \ - 'test name desc vda vdb' \ - 'test --diskspec vda name --diskspec vdb desc' \ - '--description desc --name name --domain test vda vdb' \ - '--description desc --diskspec vda --name name --domain test vdb' \ -; do - $VIRSH -q -c $test_url snapshot-create-as --print-xml $args \ - >out 2>>err || fail=3D1 - compare exp-out out || fail=3D1 -done - -test -s err && fail=3D1 - # Test a required argv cat <<\EOF > exp-err || framework_failure error: this function is not supported by the connection driver: virDomainQ= emuMonitorCommand diff --git a/tests/virshtest.c b/tests/virshtest.c index 1baa402648..453b1d7a9e 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -200,6 +200,7 @@ mymain(void) /* comprehensive coverage of argument assignment */ DO_TEST_SCRIPT("argument-assignment", NULL, VIRSH_DEFAULT, "-k0", "-d0= "); + DO_TEST_SCRIPT("snapshot-create-args", NULL, VIRSH_DEFAULT, "-q"); VIR_FREE(custom_uri); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/virshtestdata/snapshot-create-args.in b/tests/virshtestd= ata/snapshot-create-args.in new file mode 100644 index 0000000000..195b7d62f2 --- /dev/null +++ b/tests/virshtestdata/snapshot-create-args.in @@ -0,0 +1,9 @@ +snapshot-create-as --print-xml test name desc vda vdb +snapshot-create-as --print-xml test name desc --diskspec vda vdb +snapshot-create-as --print-xml test name desc --diskspec vda --diskspec vdb +snapshot-create-as --print-xml test name desc vda vdb +snapshot-create-as --print-xml test --diskspec vda name --diskspec vdb desc +snapshot-create-as --print-xml --description desc --name name --domain tes= t vda vdb +snapshot-create-as --print-xml --description desc --diskspec vda --name na= me --domain test vdb +snapshot-create-as --print-xml test name vda vdb +snapshot-create-as --print-xml test --diskspec vda,file=3Da&b,,c,snapshot= =3Dexternal --description 1<2 --diskspec vdb --memspec file=3Dd,,e diff --git a/tests/virshtestdata/snapshot-create-args.out b/tests/virshtest= data/snapshot-create-args.out new file mode 100644 index 0000000000..1a87b97dab --- /dev/null +++ b/tests/virshtestdata/snapshot-create-args.out @@ -0,0 +1,82 @@ + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + desc + + + + + + + + name + vda + + + + + + + 1<2 + + + + + + + + + --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 171119595929251.10098882748707; Sat, 23 Mar 2024 05:12:39 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 061C6181A; Sat, 23 Mar 2024 08:12:37 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7EBED1DB1; Sat, 23 Mar 2024 07:42:25 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 621551CE1; Sat, 23 Mar 2024 07:42:18 -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 A17211D9B for ; Sat, 23 Mar 2024 07:32:55 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 2F7D3223DE; Fri, 22 Mar 2024 13:56:40 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 7AF74223D9 for ; Fri, 22 Mar 2024 13:56:39 -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-542-Uw6Yat6jOVWbhcONzr60Kg-1; Fri, 22 Mar 2024 13:56:37 -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 CE5621865428 for ; Fri, 22 Mar 2024 17:56:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49B5B492BD0 for ; Fri, 22 Mar 2024 17:56:36 +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: Uw6Yat6jOVWbhcONzr60Kg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 18/35] virshtest: Adapt numeric option arg handling tests from 'virsh-optparse' Date: Fri, 22 Mar 2024 18:55:56 +0100 Message-ID: <34b4c01b953f0cde8d0d8a3427f3ecc84a1dd74a.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: HIAMIC7HMR5F2FETIAANULVD6BX6W5N7 X-Message-ID-Hash: HIAMIC7HMR5F2FETIAANULVD6BX6W5N7 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: 1711195960294100001 Move the argument parsing tests excercising various numeric options (except 'virsh event') from 'virsh-optparse' to 'virshtest'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virsh-optparse | 105 ------------------------ tests/virshtest.c | 1 + tests/virshtestdata/numeric-parsing.in | 43 ++++++++++ tests/virshtestdata/numeric-parsing.out | 12 +++ 4 files changed, 56 insertions(+), 105 deletions(-) create mode 100644 tests/virshtestdata/numeric-parsing.in create mode 100644 tests/virshtestdata/numeric-parsing.out diff --git a/tests/virsh-optparse b/tests/virsh-optparse index 10fdf7727e..e9dccdd027 100755 --- a/tests/virsh-optparse +++ b/tests/virsh-optparse @@ -32,111 +32,6 @@ fail=3D0 test_url=3Dtest:///default -# Test a required argv -cat <<\EOF > exp-err || framework_failure -error: this function is not supported by the connection driver: virDomainQ= emuMonitorCommand -EOF -$VIRSH -q -c $test_url qemu-monitor-command test a >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -### Test a regular numeric option - -# Non-numeric value -cat <<\EOF > exp-err || framework_failure -error: Numeric value 'abc' for option is malformed or out of range -EOF -$VIRSH -q -c $test_url cpu-stats test --start abc >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value with invalid suffix -cat <<\EOF > exp-err || framework_failure -error: Numeric value '42WB' for option is malformed or out of range -EOF -$VIRSH -q -c $test_url cpu-stats test --start 42WB >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value with valid suffix. Suffixes are not supported for -# regular numeric options, so this value is rejected -cat <<\EOF > exp-err || framework_failure -error: Numeric value '42MB' for option is malformed or out of range -EOF -$VIRSH -q -c $test_url cpu-stats test --start 42MB >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value bigger than INT_MAX -cat <<\EOF > exp-err || framework_failure -error: Numeric value '2147483648' for option is malformed or out o= f range -EOF -$VIRSH -q -c $test_url cpu-stats test --start 2147483648 >out 2>err && fai= l=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Negative numeric value. The value is not valid for the command -# we're testing, but it has been parsed correctly -cat <<\EOF > exp-err || framework_failure -error: Invalid value for start CPU -EOF -$VIRSH -q -c $test_url cpu-stats test --start -1 >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -### Test a scaled numeric option - -# Non-numeric value -cat <<\EOF > exp-err || framework_failure -error: Scaled numeric value 'abc' for option is malformed or out of= range -EOF -$VIRSH -q -c $test_url setmaxmem test abc >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value with invalid suffix -cat <<\EOF > exp-err || framework_failure -error: Scaled numeric value '42WB' for option is malformed or out o= f range -error: invalid argument: unknown suffix 'WB' -EOF -$VIRSH -q -c $test_url setmaxmem test 42WB >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value with valid suffix -$VIRSH -q -c $test_url setmaxmem test 42MB --config >out 2>err || fail=3D1 -test -s out && fail=3D1 -test -s err && fail=3D1 - -# Numeric value bigger than INT_MAX. No failure here because -# scaled numeric values are unsigned long long -$VIRSH -q -c $test_url setmaxmem test 2147483648 --config >out 2>err || fa= il=3D1 -test -s out && fail=3D1 -test -s err && fail=3D1 - -# Negative numeric value -cat <<\EOF > exp-err || framework_failure -error: Scaled numeric value '-1' for option is malformed or out of = range -EOF -$VIRSH -q -c $test_url setmaxmem test -1 >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Zero. The value is not valid for the command we're testing, but -# it has been parsed correctly -cat <<\EOF > exp-err || framework_failure -error: Unable to change MaxMemorySize -error: memory in virDomainSetMemoryFlags must not be zero -EOF -$VIRSH -q -c $test_url setmaxmem test 0 >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value -$VIRSH -q -c $test_url setmaxmem test 42 --config >out 2>err || fail=3D1 -test -s out && fail=3D1 -test -s err && fail=3D1 - ### Test the option (numeric option converted to ms) # Non-numeric value diff --git a/tests/virshtest.c b/tests/virshtest.c index 453b1d7a9e..37634a68a2 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -201,6 +201,7 @@ mymain(void) /* comprehensive coverage of argument assignment */ DO_TEST_SCRIPT("argument-assignment", NULL, VIRSH_DEFAULT, "-k0", "-d0= "); DO_TEST_SCRIPT("snapshot-create-args", NULL, VIRSH_DEFAULT, "-q"); + DO_TEST_SCRIPT("numeric-parsing", NULL, VIRSH_DEFAULT, "-q"); VIR_FREE(custom_uri); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/virshtestdata/numeric-parsing.in b/tests/virshtestdata/n= umeric-parsing.in new file mode 100644 index 0000000000..d099236af5 --- /dev/null +++ b/tests/virshtestdata/numeric-parsing.in @@ -0,0 +1,43 @@ +echo Test a regular numeric option + +echo Non-numeric value +cpu-stats test --start abc + +echo Numeric value with invalid suffix +cpu-stats test --start 42WB + +echo Numeric value with valid suffix. Suffixes are not supported for +echo regular numeric options, so this value is rejected +cpu-stats test --start 42MB + +echo Numeric value bigger than INT_MAX +cpu-stats test --start 2147483648 + +echo Negative numeric value. The value is not valid for the command +echo we are testing, but it has been parsed correctly +cpu-stats test --start -1 + +echo Test a scaled numeric option + +echo Non-numeric value +setmaxmem test abc + +echo Numeric value with invalid suffix +setmaxmem test 42WB + +echo Numeric value with valid suffix +setmaxmem test 42MB --config + +echo Numeric value bigger than INT_MAX. No failure here because +echo scaled numeric values are unsigned long long +setmaxmem test 2147483648 --config + +echo Negative numeric value +setmaxmem test -1 + +echo Zero. The value is not valid for the command were testing, but +echo it has been parsed correctly +setmaxmem test 0 + +echo Numeric value +setmaxmem test 42 --config diff --git a/tests/virshtestdata/numeric-parsing.out b/tests/virshtestdata/= numeric-parsing.out new file mode 100644 index 0000000000..4a0be84ac1 --- /dev/null +++ b/tests/virshtestdata/numeric-parsing.out @@ -0,0 +1,12 @@ +Test a regular numeric optionNon-numeric valueerror: Numeric value 'abc' f= or option is malformed or out of range +Numeric value with invalid suffixerror: Numeric value '42WB' for o= ption is malformed or out of range +Numeric value with valid suffix. Suffixes are not supported forregular num= eric options, so this value is rejectederror: Numeric value '42MB' for option is malformed or out of range +Numeric value bigger than INT_MAXerror: Numeric value '2147483648' for option is malformed or out of range +Negative numeric value. The value is not valid for the commandwe are testi= ng, but it has been parsed correctlyerror: Invalid value for start CPU +Test a scaled numeric optionNon-numeric valueerror: Scaled numeric value '= abc' for option is malformed or out of range +Numeric value with invalid suffixerror: Scaled numeric value '42WB' for option is malformed or out of range +error: invalid argument: unknown suffix 'WB' +Numeric value with valid suffixNumeric value bigger than INT_MAX. No failu= re here becausescaled numeric values are unsigned long longNegative numeric= valueerror: Scaled numeric value '-1' for option is malformed or ou= t of range +Zero. The value is not valid for the command were testing, butit has been = parsed correctlyerror: Unable to change MaxMemorySize +error: memory in virDomainSetMemoryFlags must not be zero +Numeric value --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org From nobody Sat May 11 20:13:42 2024 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 1711194336343337.9585003334628; Sat, 23 Mar 2024 04:45:36 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 178901B82; Sat, 23 Mar 2024 07:45:35 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 75BF01E1B; Sat, 23 Mar 2024 07:34:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DDD2D1B3C; Sat, 23 Mar 2024 07:33:55 -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 3A69E1B5A for ; Sat, 23 Mar 2024 07:32:52 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id B98D1223DA; Fri, 22 Mar 2024 13:56:40 -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 0686A223DC for ; Fri, 22 Mar 2024 13:56: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-395-vzncFCnjNrC0IP4vfwoVKQ-1; Fri, 22 Mar 2024 13:56:38 -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 B996784B164 for ; Fri, 22 Mar 2024 17:56:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 307B2492BD0 for ; Fri, 22 Mar 2024 17:56:36 +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: vzncFCnjNrC0IP4vfwoVKQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 19/35] virshtest: Adapt 'event' option arg handling tests from 'virsh-optparse' Date: Fri, 22 Mar 2024 18:55:57 +0100 Message-ID: <9dd9f699c30f62998e561425a04912b724356155.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: FOWDRJN4IRLX5XPSDOSQ5SDDGTQYLGJO X-Message-ID-Hash: FOWDRJN4IRLX5XPSDOSQ5SDDGTQYLGJO 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: 1711194337860100001 Move the argument parsing tests excercising 'virsh event' options from 'virsh-optparse' to 'virshtest'. As the test invokes 'virsh event' with a timeout and thus waits for one second pointlessly the patch also adds infrastructure to mark individual cases as expensive and is skipped normally. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/meson.build | 1 - tests/virsh-optparse | 98 ------------------- tests/virshtest.c | 16 ++- tests/virshtestdata/numeric-parsing-event.in | 26 +++++ tests/virshtestdata/numeric-parsing-event.out | 10 ++ 5 files changed, 49 insertions(+), 102 deletions(-) delete mode 100755 tests/virsh-optparse create mode 100644 tests/virshtestdata/numeric-parsing-event.in create mode 100644 tests/virshtestdata/numeric-parsing-event.out diff --git a/tests/meson.build b/tests/meson.build index 3fcfa6b1e0..849a513f33 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -695,7 +695,6 @@ if conf.has('WITH_LIBVIRTD') 'virsh-cpuset', 'virsh-define-dev-segfault', 'virsh-int-overflow', - 'virsh-optparse', 'virsh-output', 'virsh-read-bufsiz', 'virsh-read-non-seekable', diff --git a/tests/virsh-optparse b/tests/virsh-optparse deleted file mode 100755 index e9dccdd027..0000000000 --- a/tests/virsh-optparse +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -# Ensure that virsh option parsing doesn't regress - -# Copyright (C) 2011-2012, 2014 Red Hat, Inc. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. - -# This program 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 General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see -# . - -. "$(dirname $0)/test-lib.sh" - -test_expensive - -VIRSH=3D$abs_top_builddir/tools/virsh - -if test "$VERBOSE" =3D yes; then - set -x - $VIRSH --version -fi - -fail=3D0 - -test_url=3Dtest:///default - -### Test the option (numeric option converted to ms) - -# Non-numeric value -cat <<\EOF > exp-err || framework_failure -error: Numeric value 'abc' for option is malformed or out of ran= ge -EOF -$VIRSH -q -c $test_url event --all --timeout abc >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value that's too big to be converted to ms and still -# fit inside an int -cat <<\EOF > exp-err || framework_failure -error: Numeric value '2147484' for option is malformed or out of= range -EOF -$VIRSH -q -c $test_url event --all --timeout 2147484 >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value with invalid suffix -cat <<\EOF > exp-err || framework_failure -error: Numeric value '42WB' for option is malformed or out of ra= nge -EOF -$VIRSH -q -c $test_url event --all --timeout 42WB >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value with valid suffix. Suffixes are not supported for -# the option, so this value is rejected -cat <<\EOF > exp-err || framework_failure -error: Numeric value '42MB' for option is malformed or out of ra= nge -EOF -$VIRSH -q -c $test_url event --all --timeout 42MB >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Negative value -cat <<\EOF > exp-err || framework_failure -error: Numeric value '-1' for option is malformed or out of range -EOF -$VIRSH -q -c $test_url event --all --timeout -1 >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Zero. This is not a valid timeout, but the value is parsed -# correctly -cat <<\EOF > exp-err || framework_failure -error: Numeric value '0' for option is malformed or out of range -EOF -$VIRSH -q -c $test_url event --all --timeout 0 >out 2>err && fail=3D1 -test -s out && fail=3D1 -compare exp-err err || fail=3D1 - -# Numeric value. No events will be received and the command will -# fail after a second, but the value has been parsed correctly -cat <<\EOF > exp-out || framework_failure -event loop timed out -events received: 0 -EOF -$VIRSH -q -c $test_url event --all --timeout 1 >out 2>err && fail=3D1 -test -s err && fail=3D1 -compare exp-out out || fail=3D1 - -(exit $fail); exit $fail diff --git a/tests/virshtest.c b/tests/virshtest.c index 37634a68a2..ca0a73651a 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -83,6 +83,7 @@ struct testInfo { const char *testname; /* used to generate output filename */ const char *filter; const char *const *argv; + bool expensive; }; static int testCompare(const void *data) @@ -90,6 +91,9 @@ static int testCompare(const void *data) const struct testInfo *info =3D data; g_autofree char *outfile =3D NULL; + if (info->expensive && virTestGetExpensive() =3D=3D 0) + return EXIT_AM_SKIP; + if (info->testname) { outfile =3D g_strdup_printf("%s/virshtestdata/%s.out", abs_srcdir, info->testname); @@ -107,14 +111,14 @@ mymain(void) custom_uri =3D g_strdup_printf("test://%s/../examples/xml/test/testnod= e.xml", abs_srcdir); -# define DO_TEST_SCRIPT(testname_, testfilter, ...) \ +# define DO_TEST_SCRIPT_FULL(testname_, expensive, testfilter, ...) \ { \ const char *testname =3D testname_; \ g_autofree char *infile =3D g_strdup_printf("%s/virshtestdata/%s.i= n", \ abs_srcdir, testname); \ const char *myargv[] =3D { __VA_ARGS__, NULL, NULL }; \ const char **tmp =3D myargv; \ - const struct testInfo info =3D { testname, testfilter, myargv }; \ + const struct testInfo info =3D { testname, testfilter, myargv, exp= ensive }; \ g_autofree char *scriptarg =3D NULL; \ if (virFileReadAll(infile, 256 * 1024, &scriptarg) < 0) { \ fprintf(stderr, "\nfailed to load '%s'\n", infile); \ @@ -127,6 +131,9 @@ mymain(void) ret =3D -1; \ } while (0); +# define DO_TEST_SCRIPT(testname_, testfilter, ...) \ + DO_TEST_SCRIPT_FULL(testname_, false, testfilter, __VA_ARGS__); + DO_TEST_SCRIPT("info-default", NULL, VIRSH_DEFAULT); DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM); DO_TEST_SCRIPT("domain-id", "\nCPU time:", VIRSH_CUSTOM); @@ -137,7 +144,7 @@ mymain(void) do { \ const char *testname =3D testname_; \ const char *myargv[] =3D { __VA_ARGS__, NULL }; \ - const struct testInfo info =3D { testname, NULL, myargv }; \ + const struct testInfo info =3D { testname, NULL, myargv, false }; \ if (virTestRun(testname, testCompare, &info) < 0) \ ret =3D -1; \ } while (0) @@ -202,6 +209,9 @@ mymain(void) DO_TEST_SCRIPT("argument-assignment", NULL, VIRSH_DEFAULT, "-k0", "-d0= "); DO_TEST_SCRIPT("snapshot-create-args", NULL, VIRSH_DEFAULT, "-q"); DO_TEST_SCRIPT("numeric-parsing", NULL, VIRSH_DEFAULT, "-q"); + /* The 'numeric-parsing-event' invokes virsh event with a 1 second tim= eout, + * thus is marked expensive */ + DO_TEST_SCRIPT_FULL("numeric-parsing-event", true, NULL, VIRSH_DEFAULT= , "-q"); VIR_FREE(custom_uri); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/virshtestdata/numeric-parsing-event.in b/tests/virshtest= data/numeric-parsing-event.in new file mode 100644 index 0000000000..44565df3e2 --- /dev/null +++ b/tests/virshtestdata/numeric-parsing-event.in @@ -0,0 +1,26 @@ +echo Test the option (numeric option converted to ms) + +echo Non-numeric value +event --all --timeout abc + +echo Numeric value that is too big to be converted to ms and still +echo fit inside an int +event --all --timeout 2147484 + +echo Numeric value with invalid suffix +event --all --timeout 42WB + +echo Numeric value with valid suffix. Suffixes are not supported for +echo the option, so this value is rejected +event --all --timeout 42MB + +echo Negative value +event --all --timeout -1 + +echo Zero. This is not a valid timeout, but the value is parsed +echo correctly +event --all --timeout 0 + +echo Numeric value. No events will be received and the command will +echo fail after a second, but the value has been parsed correctly +event --all --timeout 1 diff --git a/tests/virshtestdata/numeric-parsing-event.out b/tests/virshtes= tdata/numeric-parsing-event.out new file mode 100644 index 0000000000..3d3fcbe5fc --- /dev/null +++ b/tests/virshtestdata/numeric-parsing-event.out @@ -0,0 +1,10 @@ +Test the option (numeric option converted to ms)Non-numeric valu= eerror: Numeric value 'abc' for option is malformed or out of ran= ge +Numeric value that is too big to be converted to ms and stillfit inside an= interror: Numeric value '2147484' for option is malformed or out= of range +Numeric value with invalid suffixerror: Numeric value '42WB' for = option is malformed or out of range +Numeric value with valid suffix. Suffixes are not supported forthe option, so this value is rejectederror: Numeric value '42MB' for option is malformed or out of range +Negative valueerror: Numeric value '-1' for option is malformed = or out of range +Zero. This is not a valid timeout, but the value is parsedcorrectlyerror: = Numeric value '0' for option is malformed or out of range +Numeric value. No events will be received and the command willfail after a= second, but the value has been parsed correctlyevent loop timed out +events received: 0 + +## 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 From nobody Sat May 11 20:13:42 2024 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 1711194193715787.2396860185393; Sat, 23 Mar 2024 04:43:13 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6DEC41953; Sat, 23 Mar 2024 07:43:12 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4B1BE1DF6; Sat, 23 Mar 2024 07:33:24 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 810E819DA; Sat, 23 Mar 2024 07:33:11 -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 A2C391AA2 for ; Sat, 23 Mar 2024 07:32:51 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id D3CF7223DD; Fri, 22 Mar 2024 13:56:43 -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 E2C28223D9 for ; Fri, 22 Mar 2024 13:56:41 -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-465-OjIISP_JMOuMGit3Qi7YJw-1; Fri, 22 Mar 2024 13:56:39 -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 C053E8007B5 for ; Fri, 22 Mar 2024 17:56:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17B39492BD0 for ; Fri, 22 Mar 2024 17:56: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,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: OjIISP_JMOuMGit3Qi7YJw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 20/35] virshtest: Reimplement 'virsh-output' test Date: Fri, 22 Mar 2024 18:55:58 +0100 Message-ID: <0ec585115ee61b4c3f5af22eb54b9ccf116d96f2.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: WTSRDXA5NEP6DPCPTKOXQZ6FVQV5UCQB X-Message-ID-Hash: WTSRDXA5NEP6DPCPTKOXQZ6FVQV5UCQB 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: 1711194195620100001 Adapt the 'tests/virsh-output-commands' file from 'virsh-output' test as a source. Apart from expanding the bash function to each command, I've also had to drop the negative tests for argument population, as a command parsing error aborts the execution of the script right away rather than just reporting the error. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/meson.build | 1 - tests/virsh-output | 29 -- tests/virsh-output-commands | 94 ------ tests/virsh-output.out | 496 ---------------------------- tests/virshtest.c | 1 + tests/virshtestdata/attach-disk.in | 79 +++++ tests/virshtestdata/attach-disk.out | 343 +++++++++++++++++++ 7 files changed, 423 insertions(+), 620 deletions(-) delete mode 100755 tests/virsh-output delete mode 100755 tests/virsh-output-commands delete mode 100644 tests/virsh-output.out create mode 100755 tests/virshtestdata/attach-disk.in create mode 100644 tests/virshtestdata/attach-disk.out diff --git a/tests/meson.build b/tests/meson.build index 849a513f33..b70fe7732e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -695,7 +695,6 @@ if conf.has('WITH_LIBVIRTD') 'virsh-cpuset', 'virsh-define-dev-segfault', 'virsh-int-overflow', - 'virsh-output', 'virsh-read-bufsiz', 'virsh-read-non-seekable', 'virsh-schedinfo', diff --git a/tests/virsh-output b/tests/virsh-output deleted file mode 100755 index aa2d386c39..0000000000 --- a/tests/virsh-output +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -. "$(dirname $0)/test-lib.sh" - -test_expensive - -if [ ! -x /bin/bash ]; then - echo skipping test - no bash - exit 77 -fi - -mock_xdg_ || framework_failure - -export LIBVIRT_DEFAULT_URI=3D'test:///default' -ln -s $abs_top_builddir/tools/virsh virsh - -$abs_top_srcdir/tests/virsh-output-commands > out 2>&1 - -echo end >> out - -if compare $abs_top_srcdir/tests/virsh-output.out out; then - exit 0 -else - if [ "x$VIR_TEST_REGENERATE_OUTPUT" =3D "x1" ]; then - cp out $abs_top_srcdir/tests/virsh-output.out - fi - - exit 1 -fi diff --git a/tests/virsh-output-commands b/tests/virsh-output-commands deleted file mode 100755 index d8e73fc1ac..0000000000 --- a/tests/virsh-output-commands +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash - -attach_disk() -{ - ./virsh attach-disk --print-xml --domain testdom $@ --source /nonexist= ent/file -} - -set -x - -./virsh attach-disk -./virsh attach-disk --print-xml --domain testdom $@ --source "" -./virsh attach-disk --print-xml --domain testdom $@ --source "" --sourcety= pe file -./virsh attach-disk --print-xml --domain testdom $@ --source "" --sourcety= pe blah -attach_disk --target hda -attach_disk --target hda --sourcetype file -attach_disk --target hda --sourcetype block -attach_disk --target hda --sourcetype nothing -attach_disk --target hda --sourcetype file --type disk -attach_disk --target hda --sourcetype block --type disk -attach_disk --target hda --sourcetype file --type cdrom -attach_disk --target hda --sourcetype block --type cdrom -attach_disk --target hda --sourcetype file --type blah -attach_disk --target hda --sourcetype block --type blah -attach_disk --target hda --sourcetype file --type disk --driver testdriver -attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 -attach_disk --target hda --sourcetype file --type disk --subdriver raw -attach_disk --target hda --sourcetype file --type disk --cache none -attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 -= -cache none -attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 -= -serial TEST_SERIAL -attach_disk --target hda --sourcetype file --type disk --mode readonly -attach_disk --target hda --sourcetype file --type disk --mode shareable -attach_disk --target hda --sourcetype file --type disk --mode whatever -attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 -= -alias testalias -attach_disk --target hda --sourcetype file --type disk --rawio -attach_disk --target hda --sourcetype file --type disk --multifunction -attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 -= -alias testalias --iothread 3 --mode readonly --cache none --driver qemu - -attach_disk --target hda --sourcetype file --type disk --address ide:1.2.3 -attach_disk --target hda --sourcetype file --type disk --address ide:1.2.4 -attach_disk --target hda --sourcetype file --type disk --address ide:1:2:5 -attach_disk --target sda --sourcetype file --type disk --address ide:1.2.3 -attach_disk --target vda --sourcetype file --type disk --address ide:1.2.3 - -attach_disk --target sda --sourcetype file --type disk --address usb:12.34 -attach_disk --target sda --sourcetype file --type disk --address usb:12.3 -attach_disk --target sda --sourcetype file --type disk --address usb:12:34 -attach_disk --target vda --sourcetype file --type disk --address usb:12.34 -attach_disk --target hda --sourcetype file --type disk --address usb:12.34 - -attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.3 -attach_disk --target sda --sourcetype file --type disk --address scsi:1.2.4 -attach_disk --target sda --sourcetype file --type disk --address scsi:1:2:5 -attach_disk --target hda --sourcetype file --type disk --address scsi:1.2.3 -attach_disk --target vda --sourcetype file --type disk --address scsi:1.2.3 - -attach_disk --target sda --sourcetype file --type disk --address sata:1.2.3 -attach_disk --target sda --sourcetype file --type disk --address sata:1.2.4 -attach_disk --target sda --sourcetype file --type disk --address sata:1:2:5 -attach_disk --target hda --sourcetype file --type disk --address sata:1.2.3 -attach_disk --target vda --sourcetype file --type disk --address sata:1.2.3 - -attach_disk --target vda --sourcetype file --type disk --address pci:12.34= .56.78 -attach_disk --target vda --sourcetype file --type disk --address pci:12:34= :56:78 -attach_disk --target vda --sourcetype file --type disk --address pci:12.34= .56.aa -attach_disk --target hda --sourcetype file --type disk --address pci:12.34= .56.aa -attach_disk --target sda --sourcetype file --type disk --address pci:12.34= .56.aa - -attach_disk --target vda --sourcetype file --type disk --address pci:12.34= .56.78 --multifunction -attach_disk --target vda --sourcetype file --type disk --address pci:12:34= :56:78 --multifunction -attach_disk --target vda --sourcetype file --type disk --address pci:12.34= .56.aa --multifunction - -attach_disk --target vda --sourcetype file --type disk --address ccw:12.34= .56 -attach_disk --target vda --sourcetype file --type disk --address ccw:12:34= :56 -attach_disk --target vda --sourcetype file --type disk --address ccw:12.34= .56 -attach_disk --target hda --sourcetype file --type disk --address ccw:12.34= .56 -attach_disk --target sda --sourcetype file --type disk --address ccw:12.34= .56 - -attach_disk --target vda --sourcetype file --type disk --address test:12.3= 4.56 -attach_disk --target vda --sourcetype file --type disk --address test:12:3= 4:56 -attach_disk --target vda --sourcetype file --type disk --address test:12.3= 4.56 - -./virsh attach-disk --print-xml --domain testdom $@ --source "" --source-p= rotocol AAA -./virsh attach-disk --print-xml --domain testdom $@ --source "" --source-p= rotocol AAA -attach_disk --target hda --source-protocol AAA --sourcetype file -attach_disk --target hda --sourcetype network -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-name hostname -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-name hostname:port -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-name hostname: -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-name :port -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-name : -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-name hostname:port --source-host-transport trnsp -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-transport trnsp -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-transport trnsp --source-host-socket /nonexistent/socket -attach_disk --target hda --sourcetype network --source-protocol TEST --sou= rce-host-socket /nonexistent/socket diff --git a/tests/virsh-output.out b/tests/virsh-output.out deleted file mode 100644 index d8ef641c2a..0000000000 --- a/tests/virsh-output.out +++ /dev/null @@ -1,496 +0,0 @@ -+ ./virsh attach-disk -error: command 'attach-disk' requires option -error: command 'attach-disk' requires option -error: command 'attach-disk' requires option -+ ./virsh attach-disk --print-xml --domain testdom --source '' -error: command 'attach-disk' requires option -+ ./virsh attach-disk --print-xml --domain testdom --source '' --sourcetyp= e file -error: command 'attach-disk' requires option -+ ./virsh attach-disk --print-xml --domain testdom --source '' --sourcetyp= e blah -error: command 'attach-disk' requires option -+ attach_disk --target hda -+ ./virsh attach-disk --print-xml --domain testdom --target hda --source /= nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype file -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype block -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe block --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype nothing -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe nothing --source /nonexistent/file -error: Unknown source type: 'nothing' - -+ attach_disk --target hda --sourcetype file --type disk -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype block --type disk -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe block --type disk --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype file --type cdrom -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type cdrom --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype block --type cdrom -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe block --type cdrom --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype file --type blah -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type blah --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype block --type blah -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe block --type blah --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype file --type disk --driver testdriv= er -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --driver testdriver --source /nonexistent/file - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2 -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --subdriver qcow2 --source /nonexistent/file - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --subdriver raw -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --subdriver raw --source /nonexistent/file - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --cache none -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --cache none --source /nonexistent/file - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2= --cache none -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --subdriver qcow2 --cache none --source /nonexistent/fi= le - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2= --serial TEST_SERIAL -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --subdriver qcow2 --serial TEST_SERIAL --source /nonexi= stent/file - - - - - TEST_SERIAL - - -+ attach_disk --target hda --sourcetype file --type disk --mode readonly -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --mode readonly --source /nonexistent/file - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --mode shareable -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --mode shareable --source /nonexistent/file - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --mode whatever -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --mode whatever --source /nonexistent/file -error: No support for whatever in command 'attach-disk' - -+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2= --alias testalias -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --subdriver qcow2 --alias testalias --source /nonexiste= nt/file - - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --rawio -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --rawio --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype file --type disk --multifunction -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --multifunction --source /nonexistent/file - - - - - -+ attach_disk --target hda --sourcetype file --type disk --subdriver qcow2= --alias testalias --iothread 3 --mode readonly --cache none --driver qemu -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --subdriver qcow2 --alias testalias --iothread 3 --mode= readonly --cache none --driver qemu --source /nonexistent/file - - - - - - - - -+ attach_disk --target hda --sourcetype file --type disk --address ide:1.2= .3 -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --address ide:1.2.3 --source /nonexistent/file - - - -
- - -+ attach_disk --target hda --sourcetype file --type disk --address ide:1.2= .4 -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --address ide:1.2.4 --source /nonexistent/file - - - -
- - -+ attach_disk --target hda --sourcetype file --type disk --address ide:1:2= :5 -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --address ide:1:2:5 --source /nonexistent/file - - - -
- - -+ attach_disk --target sda --sourcetype file --type disk --address ide:1.2= .3 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address ide:1.2.3 --source /nonexistent/file -error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. - -+ attach_disk --target vda --sourcetype file --type disk --address ide:1.2= .3 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address ide:1.2.3 --source /nonexistent/file -error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. - -+ attach_disk --target sda --sourcetype file --type disk --address usb:12.= 34 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address usb:12.34 --source /nonexistent/file - - - -
- - -+ attach_disk --target sda --sourcetype file --type disk --address usb:12.3 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address usb:12.3 --source /nonexistent/file - - - -
- - -+ attach_disk --target sda --sourcetype file --type disk --address usb:12:= 34 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address usb:12:34 --source /nonexistent/file - - - -
- - -+ attach_disk --target vda --sourcetype file --type disk --address usb:12.= 34 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address usb:12.34 --source /nonexistent/file -error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. - -+ attach_disk --target hda --sourcetype file --type disk --address usb:12.= 34 -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --address usb:12.34 --source /nonexistent/file -error: expecting an ide:00.00.00 address. - -+ attach_disk --target sda --sourcetype file --type disk --address scsi:1.= 2.3 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address scsi:1.2.3 --source /nonexistent/file - - - -
- - -+ attach_disk --target sda --sourcetype file --type disk --address scsi:1.= 2.4 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address scsi:1.2.4 --source /nonexistent/file - - - -
- - -+ attach_disk --target sda --sourcetype file --type disk --address scsi:1:= 2:5 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address scsi:1:2:5 --source /nonexistent/file - - - -
- - -+ attach_disk --target hda --sourcetype file --type disk --address scsi:1.= 2.3 -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --address scsi:1.2.3 --source /nonexistent/file -error: expecting an ide:00.00.00 address. - -+ attach_disk --target vda --sourcetype file --type disk --address scsi:1.= 2.3 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address scsi:1.2.3 --source /nonexistent/file -error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. - -+ attach_disk --target sda --sourcetype file --type disk --address sata:1.= 2.3 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address sata:1.2.3 --source /nonexistent/file - - - -
- - -+ attach_disk --target sda --sourcetype file --type disk --address sata:1.= 2.4 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address sata:1.2.4 --source /nonexistent/file - - - -
- - -+ attach_disk --target sda --sourcetype file --type disk --address sata:1:= 2:5 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address sata:1:2:5 --source /nonexistent/file - - - -
- - -+ attach_disk --target hda --sourcetype file --type disk --address sata:1.= 2.3 -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --address sata:1.2.3 --source /nonexistent/file -error: expecting an ide:00.00.00 address. - -+ attach_disk --target vda --sourcetype file --type disk --address sata:1.= 2.3 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address sata:1.2.3 --source /nonexistent/file -error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. - -+ attach_disk --target vda --sourcetype file --type disk --address pci:12.= 34.56.78 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address pci:12.34.56.78 --source /nonexistent/file - - - -
- - -+ attach_disk --target vda --sourcetype file --type disk --address pci:12:= 34:56:78 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address pci:12:34:56:78 --source /nonexistent/file - - - -
- - -+ attach_disk --target vda --sourcetype file --type disk --address pci:12.= 34.56.aa -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address pci:12.34.56.aa --source /nonexistent/file - - - -
- - -+ attach_disk --target hda --sourcetype file --type disk --address pci:12.= 34.56.aa -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --address pci:12.34.56.aa --source /nonexistent/file -error: expecting an ide:00.00.00 address. - -+ attach_disk --target sda --sourcetype file --type disk --address pci:12.= 34.56.aa -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address pci:12.34.56.aa --source /nonexistent/file -error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. - -+ attach_disk --target vda --sourcetype file --type disk --address pci:12.= 34.56.78 --multifunction -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address pci:12.34.56.78 --multifunction --source /non= existent/file - - - -
- - -+ attach_disk --target vda --sourcetype file --type disk --address pci:12:= 34:56:78 --multifunction -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address pci:12:34:56:78 --multifunction --source /non= existent/file - - - -
- - -+ attach_disk --target vda --sourcetype file --type disk --address pci:12.= 34.56.aa --multifunction -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address pci:12.34.56.aa --multifunction --source /non= existent/file - - - -
- - -+ attach_disk --target vda --sourcetype file --type disk --address ccw:12.= 34.56 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address ccw:12.34.56 --source /nonexistent/file - - - -
- - -+ attach_disk --target vda --sourcetype file --type disk --address ccw:12:= 34:56 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address ccw:12:34:56 --source /nonexistent/file - - - -
- - -+ attach_disk --target vda --sourcetype file --type disk --address ccw:12.= 34.56 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address ccw:12.34.56 --source /nonexistent/file - - - -
- - -+ attach_disk --target hda --sourcetype file --type disk --address ccw:12.= 34.56 -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe file --type disk --address ccw:12.34.56 --source /nonexistent/file -error: expecting an ide:00.00.00 address. - -+ attach_disk --target sda --sourcetype file --type disk --address ccw:12.= 34.56 -+ ./virsh attach-disk --print-xml --domain testdom --target sda --sourcety= pe file --type disk --address ccw:12.34.56 --source /nonexistent/file -error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. - -+ attach_disk --target vda --sourcetype file --type disk --address test:12= .34.56 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address test:12.34.56 --source /nonexistent/file -error: Invalid address. - -+ attach_disk --target vda --sourcetype file --type disk --address test:12= :34:56 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address test:12:34:56 --source /nonexistent/file -error: Invalid address. - -+ attach_disk --target vda --sourcetype file --type disk --address test:12= .34.56 -+ ./virsh attach-disk --print-xml --domain testdom --target vda --sourcety= pe file --type disk --address test:12.34.56 --source /nonexistent/file -error: Invalid address. - -+ ./virsh attach-disk --print-xml --domain testdom --source '' --source-pr= otocol AAA -error: command 'attach-disk' requires option -+ ./virsh attach-disk --print-xml --domain testdom --source '' --source-pr= otocol AAA -error: command 'attach-disk' requires option -+ attach_disk --target hda --source-protocol AAA --sourcetype file -+ ./virsh attach-disk --print-xml --domain testdom --target hda --source-p= rotocol AAA --sourcetype file --source /nonexistent/file -error: --source-protocol option requires --sourcetype network - -+ attach_disk --target hda --sourcetype network -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source /nonexistent/file -error: --source-protocol option requires --sourcetype network - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-name hostname -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-name hostname --source /non= existent/file - - - - - - - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-name hostname:port -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-name hostname:port --source= /nonexistent/file - - - - - - - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-name hostname: -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-name hostname: --source /no= nexistent/file - - - - - - - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-name :port -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-name :port --source /nonexi= stent/file - - - - - - - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-name : -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-name : --source /nonexisten= t/file - - - - - - - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-name hostname:port --source-host-transport trnsp -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-name hostname:port --source= -host-transport trnsp --source /nonexistent/file - - - - - - - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-transport trnsp -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-transport trnsp --source /n= onexistent/file - - - - - - - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-transport trnsp --source-host-socket /nonexistent/socket -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-transport trnsp --source-ho= st-socket /nonexistent/socket --source /nonexistent/file - - - - - - - -+ attach_disk --target hda --sourcetype network --source-protocol TEST --s= ource-host-socket /nonexistent/socket -+ ./virsh attach-disk --print-xml --domain testdom --target hda --sourcety= pe network --source-protocol TEST --source-host-socket /nonexistent/socket = --source /nonexistent/file -error: Option --source-host-transport is required by option --source-host-= socket - -end diff --git a/tests/virshtest.c b/tests/virshtest.c index ca0a73651a..78f6148733 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -212,6 +212,7 @@ mymain(void) /* The 'numeric-parsing-event' invokes virsh event with a 1 second tim= eout, * thus is marked expensive */ DO_TEST_SCRIPT_FULL("numeric-parsing-event", true, NULL, VIRSH_DEFAULT= , "-q"); + DO_TEST_SCRIPT("attach-disk", NULL, VIRSH_DEFAULT); VIR_FREE(custom_uri); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/virshtestdata/attach-disk.in b/tests/virshtestdata/attac= h-disk.in new file mode 100755 index 0000000000..f46b12f6dc --- /dev/null +++ b/tests/virshtestdata/attach-disk.in @@ -0,0 +1,79 @@ +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype block +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype nothing +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype block --type disk +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type cdrom +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype block --type cdrom +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type blah +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype block --type blah +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --driver testdriver +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --subdriver qcow2 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --subdriver raw +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --cache none +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --subdriver qcow2 --cache none +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --subdriver qcow2 --serial TEST_SERIAL +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --mode readonly +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --mode shareable +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --mode whatever +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --subdriver qcow2 --alias testalias +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --rawio +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --multifunction +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --subdriver qcow2 --alias testalias --= iothread 3 --mode readonly --cache none --driver qemu + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --address ide:1.2.3 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --address ide:1.2.4 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --address ide:1:2:5 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address ide:1.2.3 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address ide:1.2.3 + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address usb:12.34 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address usb:12.3 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address usb:12:34 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address usb:12.34 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --address usb:12.34 + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address scsi:1.2.3 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address scsi:1.2.4 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address scsi:1:2:5 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --address scsi:1.2.3 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address scsi:1.2.3 + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address sata:1.2.3 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address sata:1.2.4 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address sata:1:2:5 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --address sata:1.2.3 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address sata:1.2.3 + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address pci:12.34.56.78 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address pci:12:34:56:78 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address pci:12.34.56.aa +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --address pci:12.34.56.aa +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address pci:12.34.56.aa + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address pci:12.34.56.78 --multifunct= ion +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address pci:12:34:56:78 --multifunct= ion +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address pci:12.34.56.aa --multifunct= ion + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address ccw:12.34.56 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address ccw:12:34:56 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address ccw:12.34.56 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype file --type disk --address ccw:12.34.56 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et sda --sourcetype file --type disk --address ccw:12.34.56 + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address test:12.34.56 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address test:12:34:56 +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et vda --sourcetype file --type disk --address test:12.34.56 + +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --source-protocol AAA --sourcetype file +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-name hostn= ame +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-name hostn= ame:port +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-name hostn= ame: +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-name :port +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-name : +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-name hostn= ame:port --source-host-transport trnsp +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-transport = trnsp +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-transport = trnsp --source-host-socket /nonexistent/socket +attach-disk --print-xml --domain testdom --source /nonexistent/file --targ= et hda --sourcetype network --source-protocol TEST --source-host-socket /no= nexistent/socket diff --git a/tests/virshtestdata/attach-disk.out b/tests/virshtestdata/atta= ch-disk.out new file mode 100644 index 0000000000..4f7fe7d8e0 --- /dev/null +++ b/tests/virshtestdata/attach-disk.out @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + +error: Unknown source type: 'nothing' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TEST_SERIAL + + + + + + + + + + + + + + +error: No support for whatever in command 'attach-disk' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + +error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. + +error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. + + + + +
+ + + + + +
+ + + + + +
+ + +error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. + +error: expecting an ide:00.00.00 address. + + + + +
+ + + + + +
+ + + + + +
+ + +error: expecting an ide:00.00.00 address. + +error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. + + + + +
+ + + + + +
+ + + + + +
+ + +error: expecting an ide:00.00.00 address. + +error: expecting a pci:0000.00.00.00 or ccw:00.0.0000 address. + + + + +
+ + + + + +
+ + + + + +
+ + +error: expecting an ide:00.00.00 address. + +error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + +error: expecting an ide:00.00.00 address. + +error: expecting a scsi:00.00.00 or usb:00.00 or sata:00.00.00 address. + +error: Invalid address. + +error: Invalid address. + +error: Invalid address. + +error: --source-protocol option requires --sourcetype network + +error: --source-protocol option requires --sourcetype network + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +error: Option --source-host-transport is required by option --source-host-= socket + + +## 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 From nobody Sat May 11 20:13:42 2024 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 17111948940621002.1433548756717; Sat, 23 Mar 2024 04:54:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id EE73C17A2; Sat, 23 Mar 2024 07:54:52 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 95147217B; Sat, 23 Mar 2024 07:36:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1AA0921C6; Sat, 23 Mar 2024 07:36:01 -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 52C601C0D for ; Sat, 23 Mar 2024 07:32:53 -0400 (EDT) Received: by mx1.osci.io (Postfix, from userid 994) id 6F7DB223E4; Fri, 22 Mar 2024 13:56:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 6EA60223DD for ; Fri, 22 Mar 2024 13:56:42 -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-622-1Mrz7HISOL-ecBxdV_HhdA-1; Fri, 22 Mar 2024 13:56:39 -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 A7055101D223 for ; Fri, 22 Mar 2024 17:56:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20635492BDA for ; Fri, 22 Mar 2024 17:56:38 +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: 1Mrz7HISOL-ecBxdV_HhdA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 21/35] qemuxmlconftest: Adapt XMLs from 'virsh-cpuset' and 'virsh-define-dev-segfault' cases Date: Fri, 22 Mar 2024 18:55:59 +0100 Message-ID: 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: IP7F2W6CTWGAKAWPMSH7742PYSWZF2DX X-Message-ID-Hash: IP7F2W6CTWGAKAWPMSH7742PYSWZF2DX 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: 1711194895277100001 Rather than using 'virsh define' for the tests use the XML (or idea what the XML is testing) and use them as 'qemuxmlconftest' cases. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/meson.build | 2 - .../console-compat-crash.x86_64-latest.args | 46 +++++++++++++ .../console-compat-crash.x86_64-latest.xml | 65 +++++++++++++++++++ .../console-compat-crash.xml} | 36 +--------- .../cpuset-invalid.x86_64-latest.err | 1 + tests/qemuxmlconfdata/cpuset-invalid.xml | 12 ++++ tests/qemuxmlconftest.c | 2 + tests/virsh-cpuset | 46 ------------- 8 files changed, 129 insertions(+), 81 deletions(-) create mode 100644 tests/qemuxmlconfdata/console-compat-crash.x86_64-lates= t.args create mode 100644 tests/qemuxmlconfdata/console-compat-crash.x86_64-lates= t.xml rename tests/{virsh-define-dev-segfault =3D> qemuxmlconfdata/console-compa= t-crash.xml} (59%) mode change 100755 =3D> 100644 create mode 100644 tests/qemuxmlconfdata/cpuset-invalid.x86_64-latest.err create mode 100644 tests/qemuxmlconfdata/cpuset-invalid.xml delete mode 100755 tests/virsh-cpuset diff --git a/tests/meson.build b/tests/meson.build index b70fe7732e..35e8bd53bb 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -692,8 +692,6 @@ if conf.has('WITH_LIBVIRTD') 'libvirtd-pool', 'virsh-auth', 'virsh-checkpoint', - 'virsh-cpuset', - 'virsh-define-dev-segfault', 'virsh-int-overflow', 'virsh-read-bufsiz', 'virsh-read-non-seekable', diff --git a/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.args = b/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.args new file mode 100644 index 0000000000..3738d252a4 --- /dev/null +++ b/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.args @@ -0,0 +1,46 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-D \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-D/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-D/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-D/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DD,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-D/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,pcspk-= audiodev=3Daudio1,acpi=3Don \ +-accel kvm \ +-cpu qemu64 \ +-m size=3D262144k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":268435456}'= \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-chardev pty,id=3Dcharserial0 \ +-device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","in= dex":0}' \ +-chardev pty,id=3Dcharserial1 \ +-device '{"driver":"isa-serial","chardev":"charserial1","id":"serial1","in= dex":1}' \ +-chardev pty,id=3Dcharserial2 \ +-device '{"driver":"isa-serial","chardev":"charserial2","id":"serial2","in= dex":2}' \ +-chardev pty,id=3Dcharparallel0 \ +-device '{"driver":"isa-parallel","chardev":"charparallel0","id":"parallel= 0"}' \ +-chardev pty,id=3Dcharparallel1 \ +-device '{"driver":"isa-parallel","chardev":"charparallel1","id":"parallel= 1"}' \ +-chardev pty,id=3Dcharparallel2 \ +-device '{"driver":"isa-parallel","chardev":"charparallel2","id":"parallel= 2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"ES1370","id":"sound1","audiodev":"audio1","bus":"pci.0= ","addr":"0x2"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.xml b= /tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.xml new file mode 100644 index 0000000000..106d97b62f --- /dev/null +++ b/tests/qemuxmlconfdata/console-compat-crash.x86_64-latest.xml @@ -0,0 +1,65 @@ + + D + aaa3ae22-fed2-bfbd-ac02-3bea3bcfad82 + 262144 + 262144 + 1 + + hvm + + + + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +