[libvirt] [PATCH v2 2/2] tests: Adding test case for 'domrename' command inside virshtest.

Julio Faracco posted 2 patches 7 years, 4 months ago
There is a newer version of this series
[libvirt] [PATCH v2 2/2] tests: Adding test case for 'domrename' command inside virshtest.
Posted by Julio Faracco 7 years, 4 months ago
This commit adds a domrename test case inside the 'virshtest' test for
test driver.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 tests/virshtest.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 67453bd..f1cd5df 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -40,6 +40,7 @@ static const char *domuuid_fc4 = DOM_UUID "\n\n";
 static const char *domid_fc4 = "2\n\n";
 static const char *domname_fc4 = "fc4\n\n";
 static const char *domstate_fc4 = "running\n\n";
+static const char *domrename_fc4 = "Domain successfully renamed\n\n";
 
 static int testFilterLine(char *buffer,
                           const char *toRemove)
@@ -237,6 +238,14 @@ static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED)
   return testCompareOutputLit(exp, NULL, argv);
 }
 
+static int testCompareDomrenameByName(const void *data ATTRIBUTE_UNUSED)
+{
+  const char *const argv[] = { VIRSH_CUSTOM, "domrename", "fc4",
+                                                          "fc4new", NULL };
+  const char *exp = domrename_fc4;
+  return testCompareOutputLit(exp, NULL, argv);
+}
+
 struct testInfo {
     const char *const *argv;
     const char *result;
@@ -322,6 +331,10 @@ mymain(void)
                    testCompareDomstateByName, NULL) != 0)
         ret = -1;
 
+    if (virTestRun("virsh domrename (by name)",
+                   testCompareDomrenameByName, NULL) != 0)
+        ret = -1;
+
     /* It's a bit awkward listing result before argument, but that's a
      * limitation of C99 vararg macros.  */
 # define DO_TEST(i, result, ...) \
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/2] tests: Adding test case for 'domrename' command inside virshtest.
Posted by Peter Krempa 7 years, 4 months ago
On Mon, Jan 08, 2018 at 01:03:00 -0200, Julio Faracco wrote:
> This commit adds a domrename test case inside the 'virshtest' test for
> test driver.
> 
> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  tests/virshtest.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/tests/virshtest.c b/tests/virshtest.c
> index 67453bd..f1cd5df 100644
> --- a/tests/virshtest.c
> +++ b/tests/virshtest.c
> @@ -40,6 +40,7 @@ static const char *domuuid_fc4 = DOM_UUID "\n\n";
>  static const char *domid_fc4 = "2\n\n";
>  static const char *domname_fc4 = "fc4\n\n";
>  static const char *domstate_fc4 = "running\n\n";
> +static const char *domrename_fc4 = "Domain successfully renamed\n\n";
>  
>  static int testFilterLine(char *buffer,
>                            const char *toRemove)
> @@ -237,6 +238,14 @@ static int testCompareDomstateByName(const void *data ATTRIBUTE_UNUSED)
>    return testCompareOutputLit(exp, NULL, argv);
>  }
>  
> +static int testCompareDomrenameByName(const void *data ATTRIBUTE_UNUSED)
> +{
> +  const char *const argv[] = { VIRSH_CUSTOM, "domrename", "fc4",
> +                                                          "fc4new", NULL };
> +  const char *exp = domrename_fc4;
> +  return testCompareOutputLit(exp, NULL, argv);

This is not checking that the VM was actually renamed, only that the
success message was reported, which is pretty useless.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list