From 5fd0653a3925add461fdb82ed10bc2f72cd5920f Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 20 Mar 2024 16:27:18 +0100 Subject: [PATCH] virshtest: Adapt some 'escaping' tests via DO_TEST_SCRIPT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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án 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 + * ; . ' \" / ? = \n < > &\n", "echo", "a", "A", "0", "+", "*", ";", ".", "'", "\"", "/", "?", "=", " ", "\n", "<", ">", "&"); @@ -619,25 +620,6 @@ mymain(void) DO_TEST(15, "a A 0 + * ; . ' " / ? = \n < > &\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", diff --git a/tests/virshtestdata/echo-escaping.in b/tests/virshtestdata/echo-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 + * . \' / ? = < > & +echo --xml a A 0 + * . \' / ? = < > & +echo --shell a A 0 + * . \' / ? = < > & +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/echo-escaping.out new file mode 100644 index 0000000000..ff3e0a98b3 --- /dev/null +++ b/tests/virshtestdata/echo-escaping.out @@ -0,0 +1,11 @@ +a A 0 + * . ' / ? = < > & +a A 0 + * . ' / ? = < > & +a A 0 + '*' . ''\''' / '?' = '<' '>' '&' + + + + + +'' + +''