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

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

 



On Tue, Jul 13, 2021 at 01:42:14PM +0800, Luke Yue wrote:
Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx>
---
examples/xml/test/testdomfv0.xml     | 11 +++++++++
examples/xml/test/testnodeinline.xml | 11 +++++++++
tests/virshtest.c                    | 36 ++++++++++++++++++++++++++++
3 files changed, 58 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 0ec0f1ace6..78f3c6a671 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 c1974c46cb..43daf8b9c2 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -22,6 +22,7 @@ main(void)

# define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493"
# define SECURITY_LABEL "libvirt-test (enforcing)"
+# define BLKIO_PARAMETER "/dev/hda,700"

static const char *dominfo_fc4 = "\
Id:             2\n\
@@ -43,6 +44,14 @@ 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 *blkioparameters = "\
+weight         : 800\n\
+device_weight  : " BLKIO_PARAMETER "\n\
+device_read_iops_sec: " BLKIO_PARAMETER "\n\
+device_write_iops_sec: " BLKIO_PARAMETER "\n\
+device_read_bytes_sec: " BLKIO_PARAMETER "\n\
+device_write_bytes_sec: " BLKIO_PARAMETER "\n\
+\n";

static int testFilterLine(char *buffer,
                          const char *toRemove)
@@ -250,6 +259,25 @@ static int testCompareDomstateByName(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 = blkioparameters;
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testCompareSetBlkioParameters(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "blkiotune", "fv0",
+    "--device-weights", "/dev/hda,500",
+    "--device-read-iops-sec", "/dev/hda,1000",
+    "--device-write-iops-sec", "/dev/hda,1000",
+    "--device-read-bytes-sec", "/dev/hda,26214400",
+    "--device-write-bytes-sec", "/dev/hda,26214400", NULL };
+    const char *exp = "\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
struct testInfo {
    const char *const *argv;
    const char *result;
@@ -334,6 +362,14 @@ mymain(void)
                   testCompareDomstateByName, 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;
+

Patches are fine, but please rebase them.  I would also appreciate
testing setting some different value and then checking it was set.

    /* It's a bit awkward listing result before argument, but that's a
     * limitation of C99 vararg macros.  */
# define DO_TEST(i, result, ...) \
--
2.32.0

Attachment: signature.asc
Description: PGP signature


[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