[PATCH 13/35] virshtest: Adapt 'blkiotune' tests to DO_TEST_SCRIPT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The query and update can be tested in one run and validated against
files rather than hardcoded strings.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 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 "="

-static const char *get_blkio_parameters = "\
-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 = "\
-\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[] = { VIRSH_CUSTOM, "blkiotune", "fv0", NULL };
-    const char *exp = get_blkio_parameters;
-    return testCompareOutputLit((const char *) data, exp, NULL, argv);
-}
-
-static int testCompareSetBlkioParameters(const void *data)
-{
-    const char *const argv[] = { 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 = set_blkio_parameters;
-    return testCompareOutputLit((const char *) data, exp, NULL, argv);
-}
-
 static int testIOThreadAdd(const void *data)
 {
     const char *const argv[] = { VIRSH_CUSTOM, "iothreadinfo --domain fc4;\
@@ -257,14 +210,6 @@ mymain(void)
     custom_uri = g_strdup_printf("test://%s/../examples/xml/test/testnode.xml",
                                  abs_srcdir);

-    if (virTestRun("virsh blkiotune (get parameters)",
-                   testCompareGetBlkioParameters, NULL) != 0)
-        ret = -1;
-
-    if (virTestRun("virsh blkiotune (set parameters)",
-                   testCompareSetBlkioParameters, NULL) != 0)
-        ret = -1;
-
     if (virTestRun("virsh iothreadadd",
                    testIOThreadAdd, NULL) != 0)
         ret = -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/blkiotune.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-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
+blkiotune fv0
diff --git a/tests/virshtestdata/blkiotune.out b/tests/virshtestdata/blkiotune.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
+
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux