From nobody Wed May 1 05:39:08 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1562951637; cv=none; d=zoho.com; s=zohoarc; b=SenAUUrKE/c2vI+b6BwfqAuo7gM9hFyr2yuCZoQZwNKasFhydQHgrteUgIxWrxeE/LBsePQAwMLlJZ6TnIBL8DtVect2l2zdVDMaEywmyTcxqznECtvvqR3uwsOGEPc36HpP/4mrl4IRxmnnXEfO51mNUwP9xQogk6e2q/LLPtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562951637; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=yxeOAEyXek2lM4JfcyuwjppjU8ejl/fvY98McPdPvnk=; b=lvyBlIME/fZALGdnhVQ7tsMWei5Ikaan12haMmJETcyliMZQT0KnAp05RA+3ipQ1CRBh1UMaTEN/KmWdpMsQ8wW94CeJXdDhGWTfitemEX8/NfqPYylKcCHmK5FMant2mq0jiOf1bIIBnIC2SibjzEIVs8asWPbXIPOcogBd6UY= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562951637080398.5031915634585; Fri, 12 Jul 2019 10:13:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBDF430C1324; Fri, 12 Jul 2019 17:13:54 +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 40E6E5C207; Fri, 12 Jul 2019 17:13:54 +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 AA49A1833002; Fri, 12 Jul 2019 17:13:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6CHDpAM028743 for ; Fri, 12 Jul 2019 13:13:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 436425DAAC; Fri, 12 Jul 2019 17:13:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-54.ams2.redhat.com [10.36.112.54]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01FE75DE70; Fri, 12 Jul 2019 17:13:47 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 12 Jul 2019 18:13:43 +0100 Message-Id: <20190712171343.29342-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tests: skip systemd activation test if FDs 3/4/5 are open 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 12 Jul 2019 17:13:55 +0000 (UTC) With systemd activation the passed in file descriptors are required to be numbered from STDERR_FILENO + 1 onwards. The unit tests thus require FDs 3, 4 and 5 to be available. This may not be the case in all environments in which the tests run. For example on RHEL7 it was seen that a library constructor (gcrypt probably) opens /dev/urandom and leaves the file handle open. This means FD 3 is not available and the activation tests fail. The best way to deal with this would be to create a standalone helper program for the tests, but that's much more work than just skipping the tests if we notice we have the problem. Signed-off-by: Daniel P. Berrang=C3=A9 --- Pushed as a CI build fix tests/virsystemdtest.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index 586c512fca..cd031914ab 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -23,6 +23,7 @@ #if defined(WITH_DBUS) && defined(__linux__) =20 # include +# include =20 # define LIBVIRT_VIRSYSTEMDPRIV_H_ALLOW # include "virsystemdpriv.h" @@ -762,10 +763,17 @@ mymain(void) =20 if (virTestRun("Test activation empty", testActivationEmpty, NULL) < 0) ret =3D -1; - if (virTestRun("Test activation names", testActivationFDNames, NULL) <= 0) - ret =3D -1; - if (virTestRun("Test activation addrs", testActivationFDAddrs, NULL) <= 0) - ret =3D -1; + + if (fcntl(STDERR_FILENO + 1, F_GETFL) =3D=3D -1 && errno =3D=3D EBADF = && + fcntl(STDERR_FILENO + 2, F_GETFL) =3D=3D -1 && errno =3D=3D EBADF = && + fcntl(STDERR_FILENO + 3, F_GETFL) =3D=3D -1 && errno =3D=3D EBADF)= { + if (virTestRun("Test activation names", testActivationFDNames, NUL= L) < 0) + ret =3D -1; + if (virTestRun("Test activation addrs", testActivationFDAddrs, NUL= L) < 0) + ret =3D -1; + } else { + VIR_INFO("Skipping activation tests as FD 3/4/5 is open"); + } =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list