From nobody Sat Nov 23 18:02:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1724084512703404.115027350717; Mon, 19 Aug 2024 09:21:52 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 92AC2D46; Mon, 19 Aug 2024 12:21:51 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3341815D5; Mon, 19 Aug 2024 12:20:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 79A1111FB; Mon, 19 Aug 2024 12:19:55 -0400 (EDT) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B5309141F for ; Mon, 19 Aug 2024 12:19:54 -0400 (EDT) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5bec87ececeso3486144a12.0 for ; Mon, 19 Aug 2024 09:19:54 -0700 (PDT) Received: from localhost.localdomain ([37.186.51.21]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bebbde4964sm5738298a12.24.2024.08.19.09.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 09:19:52 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724084393; x=1724689193; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vNy2GFN4Th2OK5mwgWnm2u1jv9v+5LmNp0CO0ToGn/o=; b=VQgHxHR7VLqSepKSlltHkimA0Dj2FsBb7PRI470zvC50v+6tFl+B2sEoxC4FjTfrDt nzsYa1lCngAy9wnaOPL6tvTxluHX4aKzKWoXsRrr0teAJi7uLsGlfp2KHDiNGj1ll4Q2 fITuePAJd76T6YsNHrugA7iuzw/CBmEsaOsGaIVcsS6yaaq6IVIB6+4+pZjPlQQpgvGA LO+1HDdWhcG++/IkIT4l3L+PBhKRYOlMJeTrcGvl0InHz3Zk3Mz1kLA20MhDm1du/krl Zwpd1HUGRcU2RBeKprd2b0eVpZFV9ncd3ZAAyzS1BcYgfLYA7wqRc4MOp9RJp/+USeIS 8gyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724084393; x=1724689193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vNy2GFN4Th2OK5mwgWnm2u1jv9v+5LmNp0CO0ToGn/o=; b=Fd40zDKuIjkRr9y/4idOnrIz2uItHEy+OUtdlZLUKm3Kd/YEszVy1xFkHqragNfsBh 6bjBBt/cvn9Jo/KUJB3vKU/KbW6bQi2uzisPEu07qndRqwusvpEuNf8dg1Tr9P/Y8Lm4 lrdaNg0MKbVE14mygWbeQhP9NvkHHVbDgrlYPg+BoRM82e2nh4g6mQNCdvNEsrxBeDn9 Atvw0EUrcu+fz9pyrpEig/wi8r2oRweIbAAHPGiDW/XHargjWxwrxYfnZSf4nQJXKJZn 8Eq2bdF0e3Gsnro3CyYqPDA75i6v4ELoyAteABmWzoksVv5EbMNtnAoO2NBlmXKXNkra ZlRg== X-Gm-Message-State: AOJu0YzlBik17a/ntN9dvHF500+vHQxxHy+lwS91QXEmGiNO+sn6fQsq gREQosK7Aiya13pVmdt2pwgtb019JxiBleZql5WsKb7vpLZk/LI6dxMaaQ== X-Google-Smtp-Source: AGHT+IG+pfUzAt8yHVz8VeAKi6C+rIBaGe+fH1KbNcuRiud2C8mId9mks6Hbh/+ciBupjMi+PCedtg== X-Received: by 2002:a05:6402:35ca:b0:5bf:79f:3b6d with SMTP id 4fb4d7f45d1cf-5bf079f3e41mr1180545a12.3.1724084392906; Mon, 19 Aug 2024 09:19:52 -0700 (PDT) From: Rayhan Faizel To: devel@lists.libvirt.org Subject: [PATCH 02/14] meson: Add support for clang/LLVM coverage instrumentation Date: Mon, 19 Aug 2024 21:39:40 +0530 Message-Id: <20240819160952.351383-3-rayhan.faizel@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819160952.351383-1-rayhan.faizel@gmail.com> References: <20240819160952.351383-1-rayhan.faizel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5VLM7FD6DNJB4RZIHRFNPOBRBI5DTVSV X-Message-ID-Hash: 5VLM7FD6DNJB4RZIHRFNPOBRBI5DTVSV X-MailFrom: rayhan.faizel@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Rayhan Faizel X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1724084513549116600 Content-Type: text/plain; charset="utf-8" Clang coverage is the de-facto standard for generating coverage reports in libFuzzer based fuzzers, so add support for the same. __LLVM_PROFILE_RT_INIT_ONCE is added automatically which breaks commandhelp= er so filter the same. Note that the existing gcov support can also be used to generate coverage. Signed-off-by: Rayhan Faizel --- meson.build | 11 +++++++++++ meson_options.txt | 3 ++- tests/commandhelper.c | 8 ++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index f31485c395..904524abc6 100644 --- a/meson.build +++ b/meson.build @@ -2141,6 +2141,17 @@ if get_option('test_coverage') ] endif =20 +if get_option('test_coverage_clang') + if cc.get_id() !=3D 'clang' + error('test_coverage_clang can only be used with the Clang compiler.') + endif + + coverage_flags =3D [ + '-fprofile-instr-generate', + '-fcoverage-mapping', + ] +endif + =20 # Various definitions =20 diff --git a/meson_options.txt b/meson_options.txt index 2d440c63d8..153e325cb5 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -8,7 +8,8 @@ option('unitdir', type: 'string', value: '', description: '= directory for systemd option('sysusersdir', type: 'string', value: '', description: 'directory f= or sysusers files') # dep:tests option('expensive_tests', type: 'feature', value: 'auto', description: 'se= t the default for enabling expensive tests (long timeouts)') -option('test_coverage', type: 'boolean', value: false, description: 'turn = on code coverage instrumentation') +option('test_coverage', type: 'boolean', value: false, description: 'turn = on code coverage instrumentation (gcov)') +option('test_coverage_clang', type: 'boolean', value: false, description: = 'turn on code coverage instrumentation (clang)') option('git_werror', type: 'feature', value: 'auto', description: 'use -We= rror if building from GIT') option('rpath', type: 'feature', value: 'auto', description: 'whether to i= nclude rpath information in installed binaries and libraries') option('docdir', type: 'string', value: '', description: 'documentation in= stallation directory') diff --git a/tests/commandhelper.c b/tests/commandhelper.c index d4629d824e..6f562c3e28 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -172,9 +172,13 @@ static int printEnvironment(FILE *log) for (i =3D 0; i < length; i++) { /* Ignore the variables used to instruct the loader into * behaving differently, as they could throw the tests off. - * Also ignore __CF_USER_TEXT_ENCODING, which is set by macOS. */ + * Also ignore __CF_USER_TEXT_ENCODING, which is set by macOS. + * + * If LLVM coverage is enabled, __LLVM_PROFILE_RT_INIT_ONCE is + * automatically set, which should be ignored. */ if (!STRPREFIX(newenv[i], "LD_") && - !STRPREFIX(newenv[i], "__CF_USER_TEXT_ENCODING=3D")) { + !STRPREFIX(newenv[i], "__CF_USER_TEXT_ENCODING=3D") && + !STRPREFIX(newenv[i], "__LLVM_PROFILE_RT_INIT_ONCE=3D")) { fprintf(log, "ENV:%s\n", newenv[i]); } } --=20 2.34.1