From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 63DF8740034 for ; Mon, 14 Oct 2024 15:22:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KhUc6o9ZsKuKz0Uxo8VBAGAfdgV3vi2R70zLuXNH7RI=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:Message-ID:Date:MIME-Version:User-Agent:Subject:To:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240830; t=1728919349; v=1; x=1729178548; b=pOcGhGuQSoGi8etzog/NjEzVmUPU5YavGFk7pTUgv5Dk/VxLZfckXMOVqiMRxpjW5/aOd+qv GD+Lm1Lqe2VEb0ToDXXJsH8mL5zhCKmB6crvbWR/eFLJo183U/M6uEdyNmgyYU8YHOTREyMG2QY zk81batclW7Q6YcHpU55bsuLjKay48n3cjnET4t8fgjJsltUhpCiFO3eZrDdsUPSJBO971zcwKT tiG8GIcW1Qc9k+UkC3osIEkTQ1CNH3cpdhQdLQyPIIB7N60RY/AZTp4HgbH3qz6RZsDg5PDOlhd oJrKWRaOMFEzOXQM9WcXy8s1PhiQYQSzLcThjNvtk+Hxg== X-Received: by 127.0.0.2 with SMTP id ojf4YY7687511xahGTbG8wjT; Mon, 14 Oct 2024 08:22:28 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.57699.1728919342493799709 for ; Mon, 14 Oct 2024 08:22:22 -0700 X-Received: from [10.137.194.171] (unknown [131.107.159.43]) by linux.microsoft.com (Postfix) with ESMTPSA id 0AC2320DF4B4; Mon, 14 Oct 2024 08:22:22 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0AC2320DF4B4 Message-ID: <73f096d9-37fc-4b9c-9169-7f70268abdcf@linux.microsoft.com> Date: Mon, 14 Oct 2024 08:22:21 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [edk2-CCodingStandardsSpecification PATCH 1/1] Prefer use of `static` C keyword over EDK2 type `STATIC` To: devel@edk2.groups.io, rebecca@bsdio.com, Sean Brogan , Michael Kinney References: <20241011012040.274642-1-rebecca@bsdio.com> <2b59d0dd-3426-4741-a2a9-18275dd613b5@bsdio.com> From: "Oliver Smith-Denny" In-Reply-To: <2b59d0dd-3426-4741-a2a9-18275dd613b5@bsdio.com> Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Mon, 14 Oct 2024 08:22:22 -0700 Resent-From: osde@linux.microsoft.com Reply-To: devel@edk2.groups.io,osde@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 7ueC97FFSCuKyPYPkR6OEkvSx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=pOcGhGuQ; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io On 10/11/2024 9:47 AM, Rebecca Cran wrote: > I don't know, but I saw a message from Mike recently saying that someone= =20 > should use 'static' instead of 'STATIC' - so we need to make a clear=20 > decision one way or the other. >=20 >=20 The problem here is for GoogleTest. In CMocka, if you want to unit test a static function, regardless of STATIC vs static, you can include the C file under test in the CMocka test file. Not necessarily the most elegant solution, but it works. In GoogleTest, you often cannot directly include the C file in the GoogleTest file, because C++ complains about many Cisms, mostly our use of casting. And I definitely don't think we should update the entire codebase to support compiling under C++ :). Mike, Sean, and I had a discussion on a Project Mu PR where I undef'd STATIC while building GoogleTest modules so that static functions could be unit tested there, too. Also not the most elegant of solutions. If we switch to "static", we lose the ability to unit test static functions under GoogleTest in many cases. I don't know if GoogleTest has some other solution for this, but I don't think so. It may be we say, yep, that's the limitation of GoogleTest, add it to the UnitTestFrameworkPkg README, if you need to unit test a static function, do it in CMocka. But that seems lame, also. I do believe that unit testing static functions is critical. We should be doing interface level testing, as well, where static functions are hidden from us, but there is great value in ensuring each piece of your code is working as intended from the inside. Mike, do you have further thoughts here? Thanks, Oliver -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#120620): https://edk2.groups.io/g/devel/message/120620 Mute This Topic: https://groups.io/mt/108941574/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-