7 Commits

Author SHA1 Message Date
Michael D Kinney
715a8dc067 SecurityPkg/Library/SecureBootVariableLib/UnitTest: Cmocka use issues
Fix mocked versions of GetVariable() and SetVariable().
* VendorGuid parameter use expect_memory() not expect_value()
* MockSetVariable() use check_expected() for Attributes parameter
* MockSetVariable() use check_expected_ptr() for Data parameter
* Calls to MockGetVariable() use (UINTN) cast for will_return()
  of pointer to data buffer returned.

Issues found with Linux GCC NOOPT IA32 builds of unit tests.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2026-01-21 09:15:06 +00:00
Michael D Kinney
8635ea07be SecurityPkg/Library/SecureBootVariableLib/UnitTest: Fix CLANG
Fix uninitialized variable error in unit tests detected by
clang by zeroing local variable structure before use in unit
test cases.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-12-23 01:57:45 +00:00
Doug Flick
eefd4fdb78 SecurityPkg: Update SecureBootVariableLibUnitTest
Updates SecureBootVariableLibUnitTest to use a valid
EFI_SIGNATURE_LIST and EFI_SIGNATURE_DATA

Signed-off-by: Doug Flick <dougflick@microsoft.com>
2025-04-17 05:37:37 +00:00
Rebecca Cran
dd0b33e3e5 SecurityPkg: Update code to be more C11 compliant by using __func__
__FUNCTION__ is a pre-standard extension that gcc and Visual C++ among
others support, while __func__ was standardized in C99.

Since it's more standard, replace __FUNCTION__ with __func__ throughout
SecurityPkg.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2023-04-10 14:19:57 +00:00
Michael D Kinney
0657e74116 SecurityPkg/Library/SecureBootVariableLib: Fix VS20xx 4122 errors
The unit test code for the SecureBootVariableLib is initializing
local variable structures in their declaration from other local
variables that are also initialized in their declaration.  ANSI C
does not allow this and error 4122 is generated on VS20xx compilers.

The test cases are updated to initialize the local structure
fields in C statements instead of their local variable declaration.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2023-04-10 05:59:02 +00:00
Chris Johnson
c28c16e7c4 SecurityPkg: Add gmock example
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4389

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Chris Johnson <chris.n.johnson@intel.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Oliver Smith-Denny <osde@linux.microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2023-04-10 05:59:02 +00:00
kuqin
dbc4e3675f SecurityPkg: SecureBootVariableLib: Added unit tests
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3911

This change added unit test and enabled it from pipeline for the updated
SecureBootVariableLib.

The unit test covers all implemented interfaces and certain corner cases.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Min Xu <min.m.xu@intel.com>

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Acked-by: Michael Kubacki <michael.kubacki@microsoft.com>
2022-07-07 01:07:00 +00:00