Re: [PATCHv3 08/10] Add unit test for virCgroupGetMemoryUsage.

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

 



On 03.02.2014 18:44, Thorsten Behrens wrote:
---
  tests/vircgrouptest.c | 35 +++++++++++++++++++++++++++++++++++
  1 file changed, 35 insertions(+)

diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index a29cdd2..6826442 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -532,6 +532,38 @@ static int testCgroupAvailable(const void *args)
      return 0;
  }

+static int testCgroupGetMemoryUsage(const void *args ATTRIBUTE_UNUSED)
+{
+    virCgroupPtr cgroup = NULL;
+    int rv, ret = -1;
+    unsigned long kb;
+
+    if ((rv = virCgroupNewPartition("/virtualmachines", true,
+                                    (1 << VIR_CGROUP_CONTROLLER_MEMORY),
+                                    &cgroup)) < 0) {
+        fprintf(stderr, "Could not create /virtualmachines cgroup: %d\n", -rv);
+        goto cleanup;
+    }
+
+    if ((rv = virCgroupGetMemoryUsage(cgroup, &kb)) < 0) {
+        fprintf(stderr, "Could not retrieve GetMemoryUsage for /virtualmachines cgroup: %d\n", -rv);
+        goto cleanup;
+    }
+
+    if (kb != 1421212UL) {
+        fprintf(stderr,
+                "Wrong value from virCgroupGetMemoryUsage (expected %ld)\n",
+                1421212UL);
+        goto cleanup;
+    }
+
+    ret = 0;
+
+cleanup:
+    virCgroupFree(&cgroup);
+    return ret;
+}
+
  static int testCgroupGetBlkioIoServiced(const void *args ATTRIBUTE_UNUSED)
  {
      virCgroupPtr cgroup = NULL;
@@ -704,6 +736,9 @@ mymain(void)
      if (virtTestRun("virCgroupGetBlkioIoDeviceServiced works", testCgroupGetBlkioIoDeviceServiced, NULL) < 0)
          ret = -1;

+    if (virtTestRun("virCgroupGetMemoryUsage works", testCgroupGetMemoryUsage, NULL) < 0)
+        ret = -1;
+
      setenv("VIR_CGROUP_MOCK_MODE", "allinone", 1);
      if (virtTestRun("New cgroup for self (allinone)", testCgroupNewForSelfAllInOne, NULL) < 0)
          ret = -1;


ACK

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]