From nobody Tue Feb 10 04:55:10 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 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 --- 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