From nobody Tue May 13 17:05:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153847001235990.77710011238617; Tue, 2 Oct 2018 01:46:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E90C930B24DD; Tue, 2 Oct 2018 08:46:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56FB6108418A; Tue, 2 Oct 2018 08:46:46 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 82145181A12F; Tue, 2 Oct 2018 08:46:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w928jWfF031740 for ; Tue, 2 Oct 2018 04:45:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 932EA1062250; Tue, 2 Oct 2018 08:45:32 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14C6E106224F for ; Tue, 2 Oct 2018 08:45:31 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 2 Oct 2018 10:44:34 +0200 Message-Id: <2b3811181d8cc0ed5d97859d7ebed4b26e49d0f3.1538469654.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 50/53] vircgrouptest: add cgroup v2 tests X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 02 Oct 2018 08:46:51 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- tests/vircgrouptest.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index ead5046600..fe0cb9585a 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -567,16 +567,37 @@ static int testCgroupNewForSelfAllInOne(const void *a= rgs ATTRIBUTE_UNUSED) =20 =20 static int testCgroupNewForSelfLogind(const void *args ATTRIBUTE_UNUSED) +{ + virCgroupPtr cgroup =3D NULL; + + if (virCgroupNewSelf(&cgroup) >=3D 0) { + fprintf(stderr, "Expected to fail, only systemd cgroup available.\= n"); + virCgroupFree(&cgroup); + return -1; + } + + return 0; +} + + +static int testCgroupNewForSelfUnified(const void *args ATTRIBUTE_UNUSED) { virCgroupPtr cgroup =3D NULL; int ret =3D -1; + const char *empty[VIR_CGROUP_CONTROLLER_LAST] =3D { 0 }; + unsigned int controllers =3D + (1 << VIR_CGROUP_CONTROLLER_CPU) | + (1 << VIR_CGROUP_CONTROLLER_CPUACCT) | + (1 << VIR_CGROUP_CONTROLLER_MEMORY) | + (1 << VIR_CGROUP_CONTROLLER_BLKIO); =20 - if (virCgroupNewSelf(&cgroup) =3D=3D 0) { - fprintf(stderr, "Expected cgroup creation to fail.\n"); + if (virCgroupNewSelf(&cgroup) < 0) { + fprintf(stderr, "Cannot create cgroup for self\n"); goto cleanup; } =20 - ret =3D 0; + ret =3D validateCgroup(cgroup, "", empty, empty, empty, + "/not/really/sys/fs/cgroup", "/", controllers); cleanup: virCgroupFree(&cgroup); return ret; @@ -993,7 +1014,14 @@ mymain(void) ret =3D -1; cleanupFakeFS(fakerootdir); =20 + /* cgroup unified */ =20 + fakerootdir =3D initFakeFS("unified", "unified"); + if (virTestRun("New cgroup for self (unified)", testCgroupNewForSelfUn= ified, NULL) < 0) + ret =3D -1; + if (virTestRun("Cgroup available (unified)", testCgroupAvailable, (voi= d*)0x1) < 0) + ret =3D -1; + cleanupFakeFS(fakerootdir); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list