virshtest: Adapt some 'escaping' tests via DO_TEST_SCRIPT

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 <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2024-03-20 16:27:18 +01:00
parent f3d205ad44
commit 5fd0653a39
3 changed files with 23 additions and 19 deletions

View File

@ -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 + * ; . ' \" / ? = \n < > &\n",
"echo", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", "?",
"=", " ", "\n", "<", ">", "&");
@ -619,25 +620,6 @@ mymain(void)
DO_TEST(15, "a A 0 + * ; . &apos; &quot; / ? = \n &lt; &gt; &amp;\n",
"echo", "--xml", "a", "A", "0", "+", "*", ";", ".", "'", "\"",
"/", "?", "=", " ", "\n", "<", ">", "&");
DO_TEST(16, "a A 0 + '*' ';' . ''\\''' '\"' / '?' = ' ' '\n' '<' '>' '&'\n",
"echo", "--shell", "a", "A", "0", "+", "*", ";", ".", "\'",
"\"", "/", "?", "=", " ", "\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",

View File

@ -0,0 +1,11 @@
echo a A 0 + * . \' / ? = < > &
echo --xml a A 0 + * . \' / ? = < > &
echo --shell a A 0 + * . \' / ? = < > &
echo ""
echo --shell
echo --xml
echo --shell
echo ''
echo --shell ""
echo --xml ''
echo --shell ""''

View File

@ -0,0 +1,11 @@
a A 0 + * . ' / ? = < > &
a A 0 + * . &apos; / ? = &lt; &gt; &amp;
a A 0 + '*' . ''\''' / '?' = '<' '>' '&'
''
''