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 413DDD8080C for ; Wed, 2 Apr 2025 16:47:40 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Io6IcqbyrFR/jKR6Fr69Mk1jfHaiZ5pyhFgdxuUntBs=; c=relaxed/simple; d=groups.io; h=Subject:To:From:User-Agent:MIME-Version:Date:References:In-Reply-To:Message-ID:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240830; t=1743612459; v=1; x=1743871658; b=UaZuMHfYTRJUf/1jp6AOxAVVB0PLbdWJ7Ba1cNSokQerj6QVaIphfTz0r95/04jdA5Danlth 4nNECuJW8ARmT9PbO4ZvehpN+Lhn1ai5DNxkKfpVa4QJ/cs8oEGqJv5kJ5dMZQf5ZA6alk0+8bC oqXFmlwVYtp99ykoUWI1jilKyLtAScZAemScaXhaUllz3j1TsGD++5ehE+J6zjpdnDtt9eQCvpT EVaXmkWZ9DYNeQZ9u/hSLQZWnov44dFxao7r/KJmj3a7SMV/+dMotKtHW0LbSb4mR8rlXUxwzSh aH8DME4FbCtRYpHtHxpZkHp/y8gaa8rxIWlJY5sjvQf0g== X-Received: by 127.0.0.2 with SMTP id FTOBYY7687511xX3DyrVSPQD; Wed, 02 Apr 2025 09:47:38 -0700 Subject: Re: [edk2-devel] ACPI table generator unit test To: "Sophia Wang" , devel@edk2.groups.io From: "Paul Fagerburg via groups.io" X-Originating-Location: Longmont, Colorado, US (161.97.234.121) X-Originating-Platform: Linux Chrome 134 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Wed, 02 Apr 2025 09:47:38 -0700 References: In-Reply-To: Message-ID: <6352.1743111843323531312@groups.io> 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 Reply-To: devel@edk2.groups.io,pfagerburg@google.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: cJVwfFfMUMfppWQp5Aj78knlx7686176AA= Content-Type: multipart/alternative; boundary="E09sXchQ05M8lGuyxiiG" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b=UaZuMHfY; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=groups.io --E09sXchQ05M8lGuyxiiG Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable How does someone write unit tests for functions that are declared ` STATIC = ( https://github.com/tianocore/edk2/blob/3907f8a0bab35c90a0d4ee0352a6fdec04= b35bd2/BaseTools/Source/C/Include/Common/BaseTypes.h#L26 ) `? Clearly there= are some functions where the answer is "you don't, leave it alone, there's= a good reason we didn't export it." But in cases where there is a lot of l= ogic in a static function, it's a really good idea to test that. In the pas= t, I've seen something like ``` #ifdef UNIT_TEST #define STATIC #else #define STATIC static #endif ``` to enable unit tests to call static functions. Would something like this be= acceptable upstream? -paul -=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 (#121238): https://edk2.groups.io/g/devel/message/121238 Mute This Topic: https://groups.io/mt/111930977/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- --E09sXchQ05M8lGuyxiiG Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
How does someone write unit tests for functions that are declared `STATIC`? Clearly there are some functions where= the answer is "you don't, leave it alone, there's a good reason we didn't = export it." But in cases where there is a lot of logic in a static function= , it's a really good idea to test that. In the past, I've seen something li= ke
 
```
#ifdef UNIT_TEST
#define STATIC
#else
#define STATIC st= atic
#endif
```
 
to enable unit tests to call static functions. Would something like th= is be acceptable upstream?
 
-paul
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#121238) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--E09sXchQ05M8lGuyxiiG--