[PATCH v2 3/3] tests: Test BlkioParameters related functions for test driver

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

 



Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx>
---
 examples/xml/test/testdomfv0.xml     | 11 ++++++
 examples/xml/test/testnodeinline.xml | 11 ++++++
 tests/virshtest.c                    | 55 ++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+)

diff --git a/examples/xml/test/testdomfv0.xml b/examples/xml/test/testdomfv0.xml
index fc209cce29..e60b5d69b7 100644
--- a/examples/xml/test/testdomfv0.xml
+++ b/examples/xml/test/testdomfv0.xml
@@ -38,4 +38,15 @@
     </disk>
     <graphics type='vnc' port='5904'/>
   </devices>
+  <blkiotune>
+    <weight>800</weight>
+    <device>
+      <path>/dev/hda</path>
+      <weight>700</weight>
+      <read_bytes_sec>700</read_bytes_sec>
+      <write_bytes_sec>700</write_bytes_sec>
+      <read_iops_sec>700</read_iops_sec>
+      <write_iops_sec>700</write_iops_sec>
+    </device>
+  </blkiotune>
 </domain>
diff --git a/examples/xml/test/testnodeinline.xml b/examples/xml/test/testnodeinline.xml
index 60970145a0..9165d9302d 100644
--- a/examples/xml/test/testnodeinline.xml
+++ b/examples/xml/test/testnodeinline.xml
@@ -48,6 +48,17 @@
       </disk>
       <graphics type="vnc" port="5904"/>
     </devices>
+    <blkiotune>
+      <weight>800</weight>
+      <device>
+        <path>/dev/hda</path>
+        <weight>700</weight>
+        <read_bytes_sec>700</read_bytes_sec>
+        <write_bytes_sec>700</write_bytes_sec>
+        <read_iops_sec>700</read_iops_sec>
+        <write_iops_sec>700</write_iops_sec>
+      </device>
+    </blkiotune>
   </domain>
   <domain type="test">
     <name>fc4</name>
diff --git a/tests/virshtest.c b/tests/virshtest.c
index 751e8ffc49..87da1f5889 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -30,6 +30,8 @@ main(void)
                 tainted: custom device tree blob used\n\
                 tainted: use of deprecated configuration settings\n\
                 deprecated configuration: CPU model Deprecated-Test"
+# define GET_BLKIO_PARAMETER "/dev/hda,700"
+# define SET_BLKIO_PARAMETER "/dev/hda,1000"
 
 static const char *dominfo_fc4 = "\
 Id:             2\n\
@@ -70,6 +72,25 @@ Security label: " SECURITY_LABEL "\n\
 Messages:       " FC5_MESSAGES "\n\
 \n";
 
+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 int testFilterLine(char *buffer,
                           const char *toRemove)
 {
@@ -291,6 +312,32 @@ static int testCompareDomControlInfoByName(const void *data G_GNUC_UNUSED)
     return testCompareOutputLit(exp, NULL, argv);
 }
 
+static int testCompareGetBlkioParameters(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "blkiotune", "fv0", NULL };
+    const char *exp = get_blkio_parameters;
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testCompareSetBlkioParameters(const void *data G_GNUC_UNUSED)
+{
+    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(exp, NULL, argv);
+}
+
 struct testInfo {
     const char *const *argv;
     const char *result;
@@ -383,6 +430,14 @@ mymain(void)
                    testCompareDomControlInfoByName, NULL) != 0)
         ret = -1;
 
+    if (virTestRun("virsh blkiotune (get parameters)",
+                   testCompareGetBlkioParameters, NULL) != 0)
+        ret = -1;
+
+    if (virTestRun("virsh blkiotune (set parameters)",
+                   testCompareSetBlkioParameters, 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.33.0




[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