2014-09-02 17:52:40 +02:00
|
|
|
Index: libvirt-1.2.8/tests/vircgrouptest.c
|
2014-03-03 05:22:57 +01:00
|
|
|
===================================================================
|
2014-09-02 17:52:40 +02:00
|
|
|
--- libvirt-1.2.8.orig/tests/vircgrouptest.c
|
|
|
|
+++ libvirt-1.2.8/tests/vircgrouptest.c
|
2014-03-03 05:22:57 +01:00
|
|
|
@@ -33,7 +33,6 @@
|
|
|
|
# include "virlog.h"
|
|
|
|
# include "virfile.h"
|
|
|
|
# include "testutilslxc.h"
|
|
|
|
-# include "nodeinfo.h"
|
|
|
|
|
|
|
|
# define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
2014-04-02 14:48:46 +02:00
|
|
|
@@ -533,68 +532,6 @@ static int testCgroupAvailable(const voi
|
2014-03-03 05:22:57 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
|
|
|
|
-{
|
|
|
|
- virCgroupPtr cgroup = NULL;
|
|
|
|
- size_t i;
|
|
|
|
- int rv, ret = -1;
|
|
|
|
- virTypedParameter params[2];
|
|
|
|
-
|
|
|
|
- // TODO: mock nodeGetCPUCount() as well & check 2nd cpu, too
|
|
|
|
- unsigned long long expected[] = {
|
|
|
|
- 1413142688153030ULL
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- if ((rv = virCgroupNewPartition("/virtualmachines", true,
|
|
|
|
- (1 << VIR_CGROUP_CONTROLLER_CPU) |
|
|
|
|
- (1 << VIR_CGROUP_CONTROLLER_CPUACCT),
|
|
|
|
- &cgroup)) < 0) {
|
|
|
|
- fprintf(stderr, "Could not create /virtualmachines cgroup: %d\n", -rv);
|
|
|
|
- goto cleanup;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (nodeGetCPUCount() < 1) {
|
|
|
|
- fprintf(stderr, "Unexpected: nodeGetCPUCount() yields: %d\n", nodeGetCPUCount());
|
|
|
|
- goto cleanup;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ((rv = virCgroupGetPercpuStats(cgroup,
|
|
|
|
- params,
|
2014-05-06 20:02:27 +02:00
|
|
|
- 2, 0, 1, 0)) < 0) {
|
2014-03-03 05:22:57 +01:00
|
|
|
- fprintf(stderr, "Failed call to virCgroupGetPercpuStats for /virtualmachines cgroup: %d\n", -rv);
|
|
|
|
- goto cleanup;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for (i = 0; i < ARRAY_CARDINALITY(expected); i++) {
|
|
|
|
- if (!STREQ(params[i].field, VIR_DOMAIN_CPU_STATS_CPUTIME)) {
|
|
|
|
- fprintf(stderr,
|
|
|
|
- "Wrong parameter name value from virCgroupGetPercpuStats (is: %s)\n",
|
|
|
|
- params[i].field);
|
|
|
|
- goto cleanup;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (params[i].type != VIR_TYPED_PARAM_ULLONG) {
|
|
|
|
- fprintf(stderr,
|
|
|
|
- "Wrong parameter value type from virCgroupGetPercpuStats (is: %d)\n",
|
|
|
|
- params[i].type);
|
|
|
|
- goto cleanup;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (params[i].value.ul != expected[i]) {
|
|
|
|
- fprintf(stderr,
|
|
|
|
- "Wrong value from virCgroupGetMemoryUsage (expected %llu)\n",
|
|
|
|
- params[i].value.ul);
|
|
|
|
- goto cleanup;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ret = 0;
|
|
|
|
-
|
2014-04-02 14:48:46 +02:00
|
|
|
- cleanup:
|
2014-03-03 05:22:57 +01:00
|
|
|
- virCgroupFree(&cgroup);
|
|
|
|
- return ret;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static int testCgroupGetMemoryUsage(const void *args ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
virCgroupPtr cgroup = NULL;
|
2014-04-02 14:48:46 +02:00
|
|
|
@@ -800,9 +737,6 @@ mymain(void)
|
2014-03-03 05:22:57 +01:00
|
|
|
if (virtTestRun("virCgroupGetMemoryUsage works", testCgroupGetMemoryUsage, NULL) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
- if (virtTestRun("virCgroupGetPercpuStats works", testCgroupGetPercpuStats, NULL) < 0)
|
|
|
|
- ret = -1;
|
|
|
|
-
|
|
|
|
setenv("VIR_CGROUP_MOCK_MODE", "allinone", 1);
|
|
|
|
if (virtTestRun("New cgroup for self (allinone)", testCgroupNewForSelfAllInOne, NULL) < 0)
|
|
|
|
ret = -1;
|