[libvirt] [PATCH v2 7/9] vircgroupmock: rewrite cgroup fopen mocking
Ján Tomko
jtomko at redhat.com
Mon Sep 24 15:36:23 UTC 2018
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 at redhat.com>
>Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
>---
> 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 at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180924/bbb51dcb/attachment-0001.sig>
More information about the libvir-list
mailing list