From nobody Fri May 3 09:46:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1677689700; cv=none; d=zohomail.com; s=zohoarc; b=ALKBq7OyVpREgY1AAhi/nQgqZ4lAc1ORpB5VsFxFZ1QX/l9nB3DIMcHK0dO7xN6luVRpJQdBPWRW6Qb8Igk4wdizY0b1G8X+nE1bYf45QabLwASjLdmWJXRnBGxrwmV5Vr8LP51Yf2Z0y4yBeNR7shDSBW7tHKbefMhG6P++KzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677689700; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M9BQpaAh50QjhJbcxvppAIe1Qzp4GmKka2kJZn57TKg=; b=hA//zHzeRMeIzC1fhj/CIx14CdY54NlCD65dPh5Wr/kXTMxqknkfpmE4lDfEP73JUg0O+UcN2ksfJVcFx69Qv8m2ryMlTaA/LmilJEg3gns2Y4mlXSQYm4qVuU7Jtiz7U3pFg2OTI0r7T08ZnUhkzUly4qcFnFVy+dhkYkUXmjo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1677689700958364.68815752756086; Wed, 1 Mar 2023 08:55:00 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-ZygH-AMnO5mQmDWQRhuNkQ-1; Wed, 01 Mar 2023 11:54:54 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC1E185CD16; Wed, 1 Mar 2023 16:54:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADBE82166B40; Wed, 1 Mar 2023 16:54:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5E74919472D2; Wed, 1 Mar 2023 16:54:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 850E61946589 for ; Wed, 1 Mar 2023 16:54:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 43386492C3C; Wed, 1 Mar 2023 16:54:49 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.144]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CDC4E492C14 for ; Wed, 1 Mar 2023 16:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677689699; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=M9BQpaAh50QjhJbcxvppAIe1Qzp4GmKka2kJZn57TKg=; b=aw7CUJiFwT8TUlWvbUz2n6zx3c7Dqld1tf7jyAPFOrC+Venfz3tbpAqevzbAkOGPE3olKv 8aDtR9eJKHhAclI/tIugYMeJxf+iDyunJIWdalev4xn27jz9g96/dxkcV8CdsdmIZlAYzd i1qzwinBdWjc1e0D2eV1mBv/6Hhahoc= X-MC-Unique: ZygH-AMnO5mQmDWQRhuNkQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] tests: Introduce helpers for fakerootdir handling Date: Wed, 1 Mar 2023 17:54:43 +0100 Message-Id: <20230301165446.598069-2-abologna@redhat.com> In-Reply-To: <20230301165446.598069-1-abologna@redhat.com> References: <20230301165446.598069-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677689702789100007 Content-Type: text/plain; charset="utf-8"; x-default="true" We have this logic open-coded all over the test suite. Provide proper helpers implementing it. Signed-off-by: Andrea Bolognani Reviewed-by: Laine Stump --- tests/testutils.c | 26 ++++++++++++++++++++++++++ tests/testutils.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/tests/testutils.c b/tests/testutils.c index 8fe624f029..fe7677ebfb 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -766,6 +766,32 @@ virTestSetEnvPath(void) return 0; } =20 +#define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" + +char* +virTestFakeRootDirInit(void) +{ + g_autofree char *fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); + + if (!g_mkdtemp(fakerootdir)) { + fprintf(stderr, "Cannot create fakerootdir"); + return NULL; + } + + g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); + + return g_steal_pointer(&fakerootdir); +} + +void +virTestFakeRootDirCleanup(char *fakerootdir) +{ + g_unsetenv("LIBVIRT_FAKE_ROOT_DIR"); + + if (!g_getenv("LIBVIRT_SKIP_CLEANUP")) + virFileDeleteTree(fakerootdir); +} + int virTestMain(int argc, char **argv, int (*func)(void), diff --git a/tests/testutils.h b/tests/testutils.h index 869b58bd1e..cf8a346dff 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -101,6 +101,9 @@ void virTestQuiesceLibvirtErrors(bool always); void virTestCounterReset(const char *prefix); const char *virTestCounterNext(void); =20 +char *virTestFakeRootDirInit(void); +void virTestFakeRootDirCleanup(char *fakerootdir); + /** * The @func shall return EXIT_FAILURE or EXIT_SUCCESS or * EXIT_AM_SKIP or EXIT_AM_HARDFAIL. --=20 2.39.2 From nobody Fri May 3 09:46:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1677689700; cv=none; d=zohomail.com; s=zohoarc; b=X0Jt8X9J56np1q8FGgMfWRjJz4Tbx3YZcTELN+SFbuV1ogx4mN+pt+jzQPLji9toxOmHnhYfw0ApF2CdYiZXlH2RIurga0jT9TRIgPpyg+wYw96dTvjxTeHjl80J1WnGCcGnjdyA0CYgxtJcyxAwCoeXSutZ+iqwu4jPom4OWQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677689700; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ewpaaBc3x/BPFA6Mo+Gyzrkfp1mxxMULJk9MTRY14K4=; b=YP57SvKc0utVMcGaeWNV196o/BQq6LXzHRJOPfpcmHGZmnJmxOZlbvc58smS865jUbMUdIHuIK3uSWwMXXRRzA7ZwgBJjUpJ2/5bIase0tRSnBSm4WHaDELzfY9NOUMqWoFN1/Wd3a4m4aBw+R/rDtUjDMVfXv570sasXh2tdJE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1677689700687582.6796980313201; Wed, 1 Mar 2023 08:55:00 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-57-t-p4IpxDMd6HYVN_8oc7zg-1; Wed, 01 Mar 2023 11:54:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5D9D38173CD; Wed, 1 Mar 2023 16:54:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C07B02166B26; Wed, 1 Mar 2023 16:54:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A9EF61946A46; Wed, 1 Mar 2023 16:54:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3B7EA1946A66 for ; Wed, 1 Mar 2023 16:54:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1EDCC492C1B; Wed, 1 Mar 2023 16:54:50 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.144]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 875B6492C3F for ; Wed, 1 Mar 2023 16:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677689699; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ewpaaBc3x/BPFA6Mo+Gyzrkfp1mxxMULJk9MTRY14K4=; b=UlYoGbFYr/mHxd78jCsb/cukV0agvC00HIqtIGKuOBnrJZHpOVyxXrVYUe5LpSrvWxOjJO xLQG6OUoO5GN0c0iMAVi9gKmwUqn2l6wp4Tn7gQI8Xrq20gZmwV2bUdfgLPAyXyGOgRcWP z4+xK3d5AEBm0GzOJ7OrLW+4k59FsIw= X-MC-Unique: t-p4IpxDMd6HYVN_8oc7zg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] tests: Adopt fakerootdir helpers Date: Wed, 1 Mar 2023 17:54:44 +0100 Message-Id: <20230301165446.598069-3-abologna@redhat.com> In-Reply-To: <20230301165446.598069-1-abologna@redhat.com> References: <20230301165446.598069-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677689702854100008 Content-Type: text/plain; charset="utf-8"; x-default="true" Most replacements are completely straightforward but vircgrouptest requires slightly different handling because, instead of initializing a single fakerootdir at the start of the test program and cleaning it up at the end, it creates multiple different ones one after the other. Signed-off-by: Andrea Bolognani Reviewed-by: Laine Stump --- tests/qemuhotplugtest.c | 14 +++----------- tests/qemumemlocktest.c | 15 +++------------ tests/qemustatusxml2xmltest.c | 15 +++------------ tests/qemuxml2argvtest.c | 15 +++------------ tests/qemuxml2xmltest.c | 16 +++------------- tests/scsihosttest.c | 13 +++---------- tests/vircgrouptest.c | 18 ++++-------------- tests/virhostdevtest.c | 17 ++++------------- tests/virpcitest.c | 15 +++------------ 9 files changed, 29 insertions(+), 109 deletions(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 215837fc8f..429928aa7f 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -656,8 +656,6 @@ testQemuHotplugCpuIndividual(const void *opaque) return ret; } =20 -#define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - =20 static int mymain(void) @@ -669,15 +667,10 @@ mymain(void) g_autofree char *fakerootdir =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; =20 - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - fprintf(stderr, "Cannot create fakerootdir"); - abort(); + if (!(fakerootdir =3D virTestFakeRootDirInit())) { + return EXIT_FAILURE; } =20 - g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); - if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; =20 @@ -1004,8 +997,7 @@ mymain(void) DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "16-22", true, true,= true); DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "17", true, true, tr= ue); =20 - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); =20 qemuTestDriverFree(&driver); virObjectUnref(data.vm); diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index b303f70e9d..184d8ede19 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -42,8 +42,6 @@ testCompareMemLock(const void *data) return virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitByt= es(def, false)); } =20 -# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - static int mymain(void) { @@ -51,14 +49,8 @@ mymain(void) g_autofree char *fakerootdir =3D NULL; g_autoptr(virQEMUCaps) qemuCaps =3D NULL; =20 - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - fprintf(stderr, "Cannot create fakerootdir"); - abort(); - } - - g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; =20 if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; @@ -137,8 +129,7 @@ mymain(void) DO_TEST("pseries-locked+hostdev", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED); =20 cleanup: - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); =20 qemuTestDriverFree(&driver); =20 diff --git a/tests/qemustatusxml2xmltest.c b/tests/qemustatusxml2xmltest.c index db82a1a980..a29aa723e6 100644 --- a/tests/qemustatusxml2xmltest.c +++ b/tests/qemustatusxml2xmltest.c @@ -70,8 +70,6 @@ testInfoSetStatusPaths(struct testQemuInfo *info) } =20 =20 -#define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - static int mymain(void) { @@ -87,14 +85,8 @@ mymain(void) if (!capslatest) return EXIT_FAILURE; =20 - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - fprintf(stderr, "Cannot create fakerootdir"); - abort(); - } - - g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; =20 if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; @@ -142,8 +134,7 @@ mymain(void) DO_TEST_STATUS("backup-pull"); =20 cleanup: - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); =20 qemuTestDriverFree(&driver); =20 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5a33c336c8..39d1888427 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -796,8 +796,6 @@ testInfoSetPaths(struct testQemuInfo *info, abs_srcdir, info->name, suffix ? suf= fix : ""); } =20 -# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - static int mymain(void) { @@ -813,14 +811,8 @@ mymain(void) if (!capslatest) return EXIT_FAILURE; =20 - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - fprintf(stderr, "Cannot create fakerootdir"); - abort(); - } - - g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; =20 /* Set the timezone because we are mocking the time() function. * If we don't do that, then localtime() may return unpredictable @@ -2992,8 +2984,7 @@ mymain(void) =20 DO_TEST_CAPS_LATEST("crypto-builtin"); =20 - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); =20 VIR_FREE(driver.config->nbdTLSx509certdir); qemuTestDriverFree(&driver); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 2d2d800523..3ae2e65a43 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -113,8 +113,6 @@ testInfoSetPaths(struct testQemuInfo *info, } =20 =20 -#define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - static int mymain(void) { @@ -131,15 +129,8 @@ mymain(void) if (!capslatest) return EXIT_FAILURE; =20 - - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - fprintf(stderr, "Cannot create fakerootdir"); - abort(); - } - - g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; =20 /* Required for tpm-emulator tests */ @@ -1308,8 +1299,7 @@ mymain(void) DO_TEST_CAPS_LATEST("crypto-builtin"); =20 cleanup: - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); =20 qemuTestDriverFree(&driver); virFileWrapperClearPrefixes(); diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index 28ad59f39d..37d2b86c0a 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -227,8 +227,6 @@ testVirFindSCSIHostByPCI(const void *data G_GNUC_UNUSED) return ret; } =20 -# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - static int mymain(void) { @@ -236,12 +234,8 @@ mymain(void) g_autofree char *fakerootdir =3D NULL; g_autofree char *fakesysfsdir =3D NULL; =20 - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - fprintf(stderr, "Cannot create fakerootdir"); - goto cleanup; - } + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; =20 fakesysfsdir =3D g_strdup_printf("%s/sys", fakerootdir); =20 @@ -268,8 +262,7 @@ mymain(void) ret =3D 0; =20 cleanup: - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); VIR_FREE(scsihost_class_path); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 848a9c7bb0..0e7645af7a 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -956,22 +956,14 @@ static int testCgroupGetBlkioIoDeviceServiced(const v= oid *args G_GNUC_UNUSED) return 0; } =20 -# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - static char * initFakeFS(const char *mode, const char *filename) { char *fakerootdir; =20 - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - fprintf(stderr, "Cannot create fakerootdir"); + if (!(fakerootdir =3D virTestFakeRootDirInit())) abort(); - } - - g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); =20 if (mode) g_setenv("VIR_CGROUP_MOCK_MODE", mode, TRUE); @@ -985,13 +977,11 @@ initFakeFS(const char *mode, static void cleanupFakeFS(char *fakerootdir) { - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); - - VIR_FREE(fakerootdir); - g_unsetenv("LIBVIRT_FAKE_ROOT_DIR"); g_unsetenv("VIR_CGROUP_MOCK_MODE"); g_unsetenv("VIR_CGROUP_MOCK_FILENAME"); + + virTestFakeRootDirCleanup(fakerootdir); + VIR_FREE(fakerootdir); } =20 static int diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index 1aed0d2b6d..c64940458f 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -584,22 +584,14 @@ testNVMeDiskRoundtrip(const void *opaque G_GNUC_UNUSE= D) } =20 =20 -# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - static int mymain(void) { int ret =3D 0; g_autofree char *fakerootdir =3D NULL; =20 - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - fprintf(stderr, "Cannot create fakerootdir"); - abort(); - } - - g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; =20 # define DO_TEST(fnc) \ do { \ @@ -609,7 +601,7 @@ mymain(void) =20 if (myInit() < 0) { fprintf(stderr, "Init data structures failed."); - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); return EXIT_FAILURE; } =20 @@ -622,8 +614,7 @@ mymain(void) =20 myCleanup(); =20 - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 4c0f0b91c3..5ddf4de0bd 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -363,22 +363,14 @@ testVirPCIDeviceGetVPD(const void *opaque) return 0; } =20 -# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX" - static int mymain(void) { int ret =3D 0; g_autofree char *fakerootdir =3D NULL; =20 - fakerootdir =3D g_strdup(FAKEROOTDIRTEMPLATE); - - if (!g_mkdtemp(fakerootdir)) { - VIR_TEST_DEBUG("Cannot create fakerootdir"); - abort(); - } - - g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE); + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; =20 # define DO_TEST(fnc) \ do { \ @@ -446,8 +438,7 @@ mymain(void) =20 DO_TEST_PCI(testVirPCIDeviceGetVPD, 0, 0x03, 0, 0); =20 - if (getenv("LIBVIRT_SKIP_CLEANUP") =3D=3D NULL) - virFileDeleteTree(fakerootdir); + virTestFakeRootDirCleanup(fakerootdir); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.39.2 From nobody Fri May 3 09:46:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1677689699; cv=none; d=zohomail.com; s=zohoarc; b=UDbWlrL3fS0l6hsFxdgYYJLsbleGITBnV7jTLFwQzNOWD4I9ao9urxYac2IJddo0/lsOCFLg5ka7Yx5Jt5FJ2DYIIGP4wZg69Jq33LnhPyFqO5DojhE0Zf6wtlkGPU35qR1R0oZI24pLegGbtCc9Pn4+YZ4sg/cnNFMl0M8DuSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677689699; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XbFwsOn+UqnhMRJ1lqtH0iP5cGeUF9Y0rzSStgb7pX4=; b=ZbfHEFXa0fyAOLt8ju4rAtzGV1stzCzYbECPCGiF4utg6EGoHNCAD1Rm1Aaho+OFVuKIr9VbJcaAOMG6OpUW77uc3Ur0YY05o2vmc9WV93t0eWw6A9pNnkLOdbK+UiTEKQUVGXNkE9fkAUoOCCcOrIAyYMvVRfouL985c79H9AU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1677689699327229.14416791486394; Wed, 1 Mar 2023 08:54:59 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-464-mh-p9VbpOrutsZyzWaKMtA-1; Wed, 01 Mar 2023 11:54:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71C3781F46A; Wed, 1 Mar 2023 16:54:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D1EB18EC1; Wed, 1 Mar 2023 16:54:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 52D2019465B9; Wed, 1 Mar 2023 16:54:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 083E71946589 for ; Wed, 1 Mar 2023 16:54:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EE87E492C18; Wed, 1 Mar 2023 16:54:50 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.144]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63A0A492C14 for ; Wed, 1 Mar 2023 16:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677689698; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XbFwsOn+UqnhMRJ1lqtH0iP5cGeUF9Y0rzSStgb7pX4=; b=RFAlxf17wxFii6nMkooPwYgVZXaHl/DfbcZyvRAcyDsHwrUWe8wJdIFxUZRvMgGPRaI84t 1Q5IFeG1FzwDmRLTZLOM1suMDeJqeXjt2B78z9pu+tq7ll7pZGX7X7vNj63heriArT/eCf euIKt3f2qUf1E4JnR4L00NcypGTvIm0= X-MC-Unique: mh-p9VbpOrutsZyzWaKMtA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] tests: Move fakerootdir handling to common logic Date: Wed, 1 Mar 2023 17:54:45 +0100 Message-Id: <20230301165446.598069-4-abologna@redhat.com> In-Reply-To: <20230301165446.598069-1-abologna@redhat.com> References: <20230301165446.598069-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677689700825100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Instead of having each test manually initialize and cleanup its own fakerootdir, do that as part of the common test initialization logic in virTestMain(). In most cases we can simply drop the relevant code from the test program, but scsihosttest uses the value of fakerootdir as a starting point to build another path, so we need to do things slightly differently. In order to keep things working, we retrieve the value from the LIBVIRT_FAKE_ROOT_DIR environment variable, same as all the mock libraries are already doing. Signed-off-by: Andrea Bolognani Reviewed-by: Laine Stump --- tests/qemuhotplugtest.c | 7 ------- tests/qemumemlocktest.c | 6 ------ tests/qemustatusxml2xmltest.c | 6 ------ tests/qemuxml2argvtest.c | 6 ------ tests/qemuxml2xmltest.c | 6 ------ tests/scsihosttest.c | 5 ++--- tests/testutils.c | 6 ++++++ tests/virhostdevtest.c | 7 ------- tests/virpcitest.c | 6 ------ 9 files changed, 8 insertions(+), 47 deletions(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 429928aa7f..2e8ac05e5e 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -664,13 +664,8 @@ mymain(void) int ret =3D 0; struct qemuHotplugTestData data =3D {0}; struct testQemuHotplugCpuParams cpudata; - g_autofree char *fakerootdir =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; =20 - if (!(fakerootdir =3D virTestFakeRootDirInit())) { - return EXIT_FAILURE; - } - if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; =20 @@ -997,8 +992,6 @@ mymain(void) DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "16-22", true, true,= true); DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "17", true, true, tr= ue); =20 - virTestFakeRootDirCleanup(fakerootdir); - qemuTestDriverFree(&driver); virObjectUnref(data.vm); return (ret =3D=3D 0) ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index 184d8ede19..a03ed20a45 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -46,12 +46,8 @@ static int mymain(void) { int ret =3D 0; - g_autofree char *fakerootdir =3D NULL; g_autoptr(virQEMUCaps) qemuCaps =3D NULL; =20 - if (!(fakerootdir =3D virTestFakeRootDirInit())) - return EXIT_FAILURE; - if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; =20 @@ -129,8 +125,6 @@ mymain(void) DO_TEST("pseries-locked+hostdev", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED); =20 cleanup: - virTestFakeRootDirCleanup(fakerootdir); - qemuTestDriverFree(&driver); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/qemustatusxml2xmltest.c b/tests/qemustatusxml2xmltest.c index a29aa723e6..7587c4c34f 100644 --- a/tests/qemustatusxml2xmltest.c +++ b/tests/qemustatusxml2xmltest.c @@ -74,7 +74,6 @@ static int mymain(void) { int ret =3D 0; - g_autofree char *fakerootdir =3D NULL; g_autoptr(GHashTable) capslatest =3D testQemuGetLatestCaps(); g_autoptr(GHashTable) capscache =3D virHashNew(virObjectUnref); g_autoptr(virConnect) conn =3D NULL; @@ -85,9 +84,6 @@ mymain(void) if (!capslatest) return EXIT_FAILURE; =20 - if (!(fakerootdir =3D virTestFakeRootDirInit())) - return EXIT_FAILURE; - if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; =20 @@ -134,8 +130,6 @@ mymain(void) DO_TEST_STATUS("backup-pull"); =20 cleanup: - virTestFakeRootDirCleanup(fakerootdir); - qemuTestDriverFree(&driver); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 39d1888427..ad4d6aa4d2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -800,7 +800,6 @@ static int mymain(void) { int ret =3D 0; - g_autofree char *fakerootdir =3D NULL; g_autoptr(GHashTable) capslatest =3D testQemuGetLatestCaps(); g_autoptr(GHashTable) qapiSchemaCache =3D virHashNew((GDestroyNotify) = g_hash_table_unref); g_autoptr(GHashTable) capscache =3D virHashNew(virObjectUnref); @@ -811,9 +810,6 @@ mymain(void) if (!capslatest) return EXIT_FAILURE; =20 - if (!(fakerootdir =3D virTestFakeRootDirInit())) - return EXIT_FAILURE; - /* Set the timezone because we are mocking the time() function. * If we don't do that, then localtime() may return unpredictable * results. In order to detect things that just work by a blind @@ -2984,8 +2980,6 @@ mymain(void) =20 DO_TEST_CAPS_LATEST("crypto-builtin"); =20 - virTestFakeRootDirCleanup(fakerootdir); - VIR_FREE(driver.config->nbdTLSx509certdir); qemuTestDriverFree(&driver); virFileWrapperClearPrefixes(); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 3ae2e65a43..88e152b65c 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -117,7 +117,6 @@ static int mymain(void) { int ret =3D 0; - g_autofree char *fakerootdir =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; g_autoptr(GHashTable) capslatest =3D testQemuGetLatestCaps(); g_autoptr(GHashTable) capscache =3D virHashNew(virObjectUnref); @@ -129,9 +128,6 @@ mymain(void) if (!capslatest) return EXIT_FAILURE; =20 - if (!(fakerootdir =3D virTestFakeRootDirInit())) - return EXIT_FAILURE; - /* Required for tpm-emulator tests */ virFileWrapperAddPrefix(SYSCONFDIR "/qemu/firmware", @@ -1299,8 +1295,6 @@ mymain(void) DO_TEST_CAPS_LATEST("crypto-builtin"); =20 cleanup: - virTestFakeRootDirCleanup(fakerootdir); - qemuTestDriverFree(&driver); virFileWrapperClearPrefixes(); =20 diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index 37d2b86c0a..7f2dcb68a2 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -231,10 +231,10 @@ static int mymain(void) { int ret =3D -1; - g_autofree char *fakerootdir =3D NULL; + const char *fakerootdir =3D NULL; g_autofree char *fakesysfsdir =3D NULL; =20 - if (!(fakerootdir =3D virTestFakeRootDirInit())) + if (!(fakerootdir =3D g_getenv("LIBVIRT_FAKE_ROOT_DIR"))) return EXIT_FAILURE; =20 fakesysfsdir =3D g_strdup_printf("%s/sys", fakerootdir); @@ -262,7 +262,6 @@ mymain(void) ret =3D 0; =20 cleanup: - virTestFakeRootDirCleanup(fakerootdir); VIR_FREE(scsihost_class_path); return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/testutils.c b/tests/testutils.c index fe7677ebfb..e717895fbf 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -808,6 +808,7 @@ int virTestMain(int argc, g_autofree const char **preloads =3D NULL; size_t npreloads =3D 0; g_autofree char *mock =3D NULL; + g_autofree char *fakerootdir =3D NULL; =20 if (getenv("VIR_TEST_FILE_ACCESS")) { preloads =3D g_renew(const char *, preloads, npreloads + 2); @@ -888,6 +889,9 @@ int virTestMain(int argc, =20 failedTests =3D virBitmapNew(1); =20 + if (!(fakerootdir =3D virTestFakeRootDirInit())) + return EXIT_FAILURE; + ret =3D (func)(); =20 virResetLastError(); @@ -897,6 +901,8 @@ int virTestMain(int argc, fprintf(stderr, " %-3zu %s\n", testCounter, ret =3D=3D 0 ? "OK" : = "FAIL"); } =20 + virTestFakeRootDirCleanup(fakerootdir); + switch (ret) { case EXIT_FAILURE: case EXIT_SUCCESS: diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index c64940458f..ee0d1c1e6b 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -588,10 +588,6 @@ static int mymain(void) { int ret =3D 0; - g_autofree char *fakerootdir =3D NULL; - - if (!(fakerootdir =3D virTestFakeRootDirInit())) - return EXIT_FAILURE; =20 # define DO_TEST(fnc) \ do { \ @@ -601,7 +597,6 @@ mymain(void) =20 if (myInit() < 0) { fprintf(stderr, "Init data structures failed."); - virTestFakeRootDirCleanup(fakerootdir); return EXIT_FAILURE; } =20 @@ -614,8 +609,6 @@ mymain(void) =20 myCleanup(); =20 - virTestFakeRootDirCleanup(fakerootdir); - return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 5ddf4de0bd..769175d7c4 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -367,10 +367,6 @@ static int mymain(void) { int ret =3D 0; - g_autofree char *fakerootdir =3D NULL; - - if (!(fakerootdir =3D virTestFakeRootDirInit())) - return EXIT_FAILURE; =20 # define DO_TEST(fnc) \ do { \ @@ -438,8 +434,6 @@ mymain(void) =20 DO_TEST_PCI(testVirPCIDeviceGetVPD, 0, 0x03, 0, 0); =20 - virTestFakeRootDirCleanup(fakerootdir); - return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 --=20 2.39.2 From nobody Fri May 3 09:46:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1677689700; cv=none; d=zohomail.com; s=zohoarc; b=OkkUGkrehdE0Hlu1dILUQ1jve0mOEMmuNVGSIs42vM6XFUTkdeO3CXf5ZfudJ142zfJJN6h886kCPjCuJuc0/VuFKJufrCJGHRlrIjVvJhw5yW+uKHcF6aHAyjvU95Scjv+hZgfqbmf8y7KVgZyxUgUrL3jNJgfWRSKtnyGxPr4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677689700; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/0xWOXfFHhduRF47y7lUw2tZdOrTDOQn911mgTWLjd8=; b=UbtWjvuCAYPPgoCzw9MViYa/A1Yzv5yoiJwiEnXSjGQQ2Ccuu3LnnelvRZhf1Xvl+MThKFvAZRCsbKqrQVidT6t1uugCJ9jS4QabI/D0KtCjRKvzfgDyQn4cJ2MKSJHhNjt1LczqR2K7Da9fSNsL4D56UMXESpToRp0D8ZixeT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1677689700001835.6569197625782; Wed, 1 Mar 2023 08:55:00 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-84-duETgftIOMazSFN6orDXGw-1; Wed, 01 Mar 2023 11:54:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C96185D066; Wed, 1 Mar 2023 16:54:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 096052166B2B; Wed, 1 Mar 2023 16:54:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E43A919465A4; Wed, 1 Mar 2023 16:54:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C212D1946A66 for ; Wed, 1 Mar 2023 16:54:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A82BC492C14; Wed, 1 Mar 2023 16:54:51 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.144]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E223492C18 for ; Wed, 1 Mar 2023 16:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677689699; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/0xWOXfFHhduRF47y7lUw2tZdOrTDOQn911mgTWLjd8=; b=FRHkySoD4ASPKZROyeY9WFXsP4J5x3C+QzLKe0M7RzLKCrlN8C410yx27bFUxoiDcHHYR4 BHEDtS0Ca3liEtSfm6SPIYS9RpHVxPGXsbXqVfVqcEqHDNTAk3afHjgfflkxZdHmf3jAiQ +YDtYopW6pUEkeMZk5XEO3cuY/mADVc= X-MC-Unique: duETgftIOMazSFN6orDXGw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] tests: Print fakerootdir when it's preserved Date: Wed, 1 Mar 2023 17:54:46 +0100 Message-Id: <20230301165446.598069-5-abologna@redhat.com> In-Reply-To: <20230301165446.598069-1-abologna@redhat.com> References: <20230301165446.598069-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677689700766100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Setting the LIBVIRT_SKIP_CLEANUP environment variable results in the contents of fakerootdir being preserved for inspection. Be more helpful towards the developer and print out the path in this case. Signed-off-by: Andrea Bolognani Reviewed-by: Laine Stump --- tests/testutils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testutils.c b/tests/testutils.c index e717895fbf..e8cb8e6737 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -790,6 +790,8 @@ virTestFakeRootDirCleanup(char *fakerootdir) =20 if (!g_getenv("LIBVIRT_SKIP_CLEANUP")) virFileDeleteTree(fakerootdir); + else + fprintf(stderr, "Test data ready for inspection: %s\n", fakerootdi= r); } =20 int virTestMain(int argc, --=20 2.39.2