From nobody Wed May 8 19:43:27 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=1563206353; cv=none; d=zoho.com; s=zohoarc; b=UiiyHZx2cLoSfR4WDnhYouI1O/j0Yw9akeTXEz2Gh9NnnmscNmaVhiYaqNVhEornohL6q4qeHW09Mv7i7VrIunhuJZKAV7NxM0WEbnKdFaTIat7sxPyqlg71C2aGsCyHExm0q+KOW+LMaVA73s60+SLRDCyFxctbOyiYma98zEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563206353; 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=6WGdzWrrp+G9ejTh8s/whku1T6fAy4rNpim3PdgwHAg=; b=HZxAqcSvvqe6Fvhxnv5Zhxj2G0zGjV2D0ibJ/ZzY33PcR1zrjX++E6B7RnMJPz0ZlTe8SZn1afi3K0n/N3cIat/Zhr3F7xy4NPRLnwwnCdjZ+YZ3Q0Qyf05ZyjgWB7zObLwqm3OKzSWBsf4ic9k/HOMmnxfXGZXlr7NX6K/rTHE= 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 15632063534540.7020848859358466; Mon, 15 Jul 2019 08:59:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB3D730C1CA9; Mon, 15 Jul 2019 15:59:10 +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 545D55D71B; Mon, 15 Jul 2019 15:59:10 +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 3BC4A18355D9; Mon, 15 Jul 2019 15:59:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6FFx628028054 for ; Mon, 15 Jul 2019 11:59:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 49A6579BE; Mon, 15 Jul 2019 15:59:06 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-60.ams2.redhat.com [10.36.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E2AE19C68; Mon, 15 Jul 2019 15:59:02 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 15 Jul 2019 16:58:58 +0100 Message-Id: <20190715155858.26178-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tests: don't assume "localhost" only resolves to 1/2 IPs 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Mon, 15 Jul 2019 15:59:12 +0000 (UTC) On Debian derived distros "localhost" can resolve to the normal "127.0.0.1" and "::1", but it can also resolve to "127.0.1.1" Rewrite the code so that it doesn't assume a fixed number of IPs. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- tests/virsystemdtest.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index cd031914ab..dd87caeebf 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -548,22 +548,21 @@ testActivation(bool useNames) size_t nsockIP; int ret =3D -1; size_t i; - const char *names2 =3D "demo-unix.socket:demo-ip.socket"; - const char *names3 =3D "demo-unix.socket:demo-ip.socket:demo-ip.socket= "; char nfdstr[INT_BUFSIZE_BOUND(size_t)]; char pidstr[INT_BUFSIZE_BOUND(pid_t)]; virSystemdActivationMap map[2]; int *fds =3D NULL; size_t nfds =3D 0; VIR_AUTOPTR(virSystemdActivation) act =3D NULL; + virBuffer names =3D VIR_BUFFER_INITIALIZER; + + virBufferAddLit(&names, "demo-unix.socket"); =20 if (testActivationCreateFDs(&sockUNIX, &sockIP, &nsockIP) < 0) return -1; =20 - if (nsockIP !=3D 1 && nsockIP !=3D 2) { - fprintf(stderr, "Got %zu IP sockets but expected only 1 or 2\n", n= sockIP); - goto cleanup; - } + for (i =3D 0; i < nsockIP; i++) + virBufferAddLit(&names, ":demo-ip.socket"); =20 snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP); snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid()); @@ -571,8 +570,11 @@ testActivation(bool useNames) setenv("LISTEN_FDS", nfdstr, 1); setenv("LISTEN_PID", pidstr, 1); =20 + if (virBufferError(&names)) + goto cleanup; + if (useNames) - setenv("LISTEN_FDNAMES", nsockIP =3D=3D 1 ? names2 : names3, 1); + setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1); else unsetenv("LISTEN_FDNAMES"); =20 @@ -627,6 +629,7 @@ testActivation(bool useNames) =20 ret =3D 0; cleanup: + virBufferFreeAndReset(&names); virObjectUnref(sockUNIX); for (i =3D 0; i < nsockIP; i++) virObjectUnref(sockIP[i]); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list