From nobody Tue Apr 23 22:17:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1578593101; cv=none; d=zohomail.com; s=zohoarc; b=ejZbPG0W8208yYBywIWVvj/SBO/YKufBap/+yZNUarYs0y3b5d2po7cEYNGVZ1ONUgF5tfQ75MBOJJivrBbrpV6Ndu4ohwtTnTFFkbqG+h/sTPX+9Fs+xU733XrhIb6AlIMiJpzvqvUnO8W7t8HUF3zOwOpPTrR5THIdFD6Nqgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578593101; 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; bh=2E7pioN94/HWSIySQ2wjL+ylQRufXhxi2XdMPJl5QnE=; b=f4JLgeJzjp8qKWkWp/M5FCIjxJHVC3ilvOuJEkiFfK9LRby+8Ht2anYFDmutE7gHDtNl809/5AbWmSoOKFmHlKunHSfRM/npABEuli/t2OzbU/TVF5LhwDHnPqsjuogabxCsmB9PSrZSdKjePL+Wpfmwxyvv/dA1bJfXJo7rRUA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1578593101211643.4703651584286; Thu, 9 Jan 2020 10:05:01 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-OJsbnTMxPBmEhH8i1GfInA-1; Thu, 09 Jan 2020 13:04:58 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E29F8800D54; Thu, 9 Jan 2020 18:04:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8BBC5D9C9; Thu, 9 Jan 2020 18:04:49 +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 B535B503C7; Thu, 9 Jan 2020 18:04:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 009I4jus017620 for ; Thu, 9 Jan 2020 13:04:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 739BB5C3FA; Thu, 9 Jan 2020 18:04:45 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (dhcp-46.gsslab.fab.redhat.com [10.33.9.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8A2F5C54A; Thu, 9 Jan 2020 18:04:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578593100; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2E7pioN94/HWSIySQ2wjL+ylQRufXhxi2XdMPJl5QnE=; b=GHUoaAs61nkOg35MhenaAX1JEff7HNlzvk7JvYMT4YbjJg19D1naZr2YfGocAVWGIh1alL kh8In6gnAxFLB6a03Z3ej9wG4wyEABb21Jt5wfdiSoYtbDbb2XKhtLL1FdxgSFNZ7D+aiJ wSpw4Fe9wF7m+IJurxrG7mk09vvWbQY= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 9 Jan 2020 18:04:39 +0000 Message-Id: <20200109180439.2665929-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tests: avoid re-execing test once for each mock 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: OJsbnTMxPBmEhH8i1GfInA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) When debugging tests under GDB there is a significant time delay each time an execve is done as GDB scans shared libraries once again. For tests which use many mock libraries, we have been invoking execve many times which makes the GDB experience horrible. This changes our framework to activate the full set of mock libraries in one single execve. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- tests/qemucapsprobe.c | 8 +++++++- tests/testutils.c | 29 ++++++++++++++++++++++++----- tests/testutils.h | 10 +++------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c index 6837f2a0f6..c7e8f3309d 100644 --- a/tests/qemucapsprobe.c +++ b/tests/qemucapsprobe.c @@ -46,8 +46,14 @@ main(int argc, char **argv) { virThread thread; virQEMUCapsPtr caps; + const char *mock =3D VIR_TEST_MOCK("qemucapsprobe"); =20 - VIR_TEST_PRELOAD(VIR_TEST_MOCK("qemucapsprobe")); + if (!virFileIsExecutable(mock)) { + perror(mock); + return EXIT_FAILURE; + } + + VIR_TEST_PRELOAD(mock); =20 if (argc !=3D 2) { fprintf(stderr, "%s QEMU_binary\n", argv[0]); diff --git a/tests/testutils.c b/tests/testutils.c index 6f0ef2b2f1..b490609e36 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -856,15 +856,34 @@ int virTestMain(int argc, virLogOutputPtr *outputs =3D NULL; g_autofree char *baseprogname =3D NULL; const char *progname; - - if (getenv("VIR_TEST_FILE_ACCESS")) - VIR_TEST_PRELOAD(VIR_TEST_MOCK("virtest")); + g_autofree const char **preloads =3D NULL; + size_t npreloads =3D 0; + g_autofree char *mock =3D NULL; + + if (getenv("VIR_TEST_FILE_ACCESS")) { + preloads =3D g_renew(const char *, preloads, npreloads + 2); + preloads[npreloads++] =3D VIR_TEST_MOCK("virtest"); + preloads[npreloads] =3D NULL; + } =20 va_start(ap, func); - while ((lib =3D va_arg(ap, const char *))) - VIR_TEST_PRELOAD(lib); + while ((lib =3D va_arg(ap, const char *))) { + if (!virFileIsExecutable(lib)) { + perror(lib); + return EXIT_FAILURE; + } + + preloads =3D g_renew(const char *, preloads, npreloads + 2); + preloads[npreloads++] =3D lib; + preloads[npreloads] =3D NULL; + } va_end(ap); =20 + if (preloads) { + mock =3D g_strjoinv(":", (char **)preloads); + VIR_TEST_PRELOAD(mock); + } + progname =3D baseprogname =3D g_path_get_basename(argv[0]); if (STRPREFIX(progname, "lt-")) progname +=3D 3; diff --git a/tests/testutils.h b/tests/testutils.h index 8a7ea38f43..2944c25e8b 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -127,19 +127,15 @@ int virTestMain(int argc, # define MOCK_EXT ".so" #endif =20 -#define VIR_TEST_PRELOAD(lib) \ +#define VIR_TEST_PRELOAD(libs) \ do { \ const char *preload =3D getenv(PRELOAD_VAR); \ if (preload =3D=3D NULL || strstr(preload, lib) =3D=3D NULL) { \ char *newenv; \ - if (!virFileIsExecutable(lib)) { \ - perror(lib); \ - return EXIT_FAILURE; \ - } \ if (!preload) { \ - newenv =3D (char *) lib; \ + newenv =3D (char *) libs; \ } else { \ - newenv =3D g_strdup_printf("%s:%s", lib, preload); \ + newenv =3D g_strdup_printf("%s:%s", libs, preload); \ } \ g_setenv(PRELOAD_VAR, newenv, TRUE); \ FORCE_FLAT_NAMESPACE \ --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list