Re: [PATCH v2 7/9] vircgroupmock: rewrite cgroup fopen mocking

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

 



On Thu, Sep 20, 2018 at 10:54:36AM +0200, Pavel Hrdina wrote:
Move all the cgroup data into separate files out of vircgroupmock.c
and rework the fopen function to load data from files.  This will
make it easier to add more test cases.

Reviewed-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
tests/vircgroupdata/all-in-one.cgroups     |   7 ++
tests/vircgroupdata/all-in-one.mounts      |   2 +-
tests/vircgroupdata/all-in-one.parsed      |  12 +-
tests/vircgroupdata/all-in-one.self.cgroup |   1 +
tests/vircgroupdata/logind.cgroups         |  10 ++
tests/vircgroupdata/logind.mounts          |   2 +
tests/vircgroupdata/logind.self.cgroup     |   1 +
tests/vircgroupdata/systemd.cgroups        |   8 ++
tests/vircgroupdata/systemd.mounts         |  11 ++
tests/vircgroupdata/systemd.self.cgroup    |   6 +
tests/vircgroupmock.c                      | 133 ++++-----------------
tests/vircgrouptest.c                      |  10 +-
12 files changed, 79 insertions(+), 124 deletions(-)
create mode 100644 tests/vircgroupdata/all-in-one.cgroups
create mode 100644 tests/vircgroupdata/all-in-one.self.cgroup
create mode 100644 tests/vircgroupdata/logind.cgroups
create mode 100644 tests/vircgroupdata/logind.mounts
create mode 100644 tests/vircgroupdata/logind.self.cgroup
create mode 100644 tests/vircgroupdata/systemd.cgroups
create mode 100644 tests/vircgroupdata/systemd.mounts
create mode 100644 tests/vircgroupdata/systemd.self.cgroup

diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index 6ab67dca78..d23ce2155b 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -889,6 +889,7 @@ mymain(void)
    DETECT_MOUNTS("no-cgroups");
    DETECT_MOUNTS("kubevirt");

+    setenv("VIR_CGROUP_MOCK_FILENAME", "systemd", 1);
    if (virTestRun("New cgroup for self", testCgroupNewForSelf, NULL) < 0)
        ret = -1;

@@ -924,20 +925,21 @@ mymain(void)

    if (virTestRun("virCgroupGetPercpuStats works", testCgroupGetPercpuStats, NULL) < 0)
        ret = -1;
+    unsetenv("VIR_CGROUP_MOCK_FILENAME");

-    setenv("VIR_CGROUP_MOCK_MODE", "allinone", 1);
+    setenv("VIR_CGROUP_MOCK_FILENAME", "all-in-one", 1);
    if (virTestRun("New cgroup for self (allinone)", testCgroupNewForSelfAllInOne, NULL) < 0)
        ret = -1;
    if (virTestRun("Cgroup available", testCgroupAvailable, (void*)0x1) < 0)
        ret = -1;
-    unsetenv("VIR_CGROUP_MOCK_MODE");
+    unsetenv("VIR_CGROUP_MOCK_FILENAME");

-    setenv("VIR_CGROUP_MOCK_MODE", "logind", 1);
+    setenv("VIR_CGROUP_MOCK_FILENAME", "logind", 1);
    if (virTestRun("New cgroup for self (logind)", testCgroupNewForSelfLogind, NULL) < 0)
        ret = -1;
    if (virTestRun("Cgroup available", testCgroupAvailable, (void*)0x0) < 0)
        ret = -1;
-    unsetenv("VIR_CGROUP_MOCK_MODE");
+    unsetenv("VIR_CGROUP_MOCK_FILENAME");


I don't see the need to rename the variable, especially since it
contains only a part of the filename.

Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: Digital signature

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

  Powered by Linux