summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Test
AgeCommit message (Collapse)AuthorFilesLines
2026-07-31MdeModulePkg: Host Test: Adding AArch64 targetKun Qin1-1/+1
This change adds the AArch64 target for host based unit tests. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-07-21MdeModulePkg/GptLib: Add host-based unit tests for valid GPT behaviorRichard Lyu1-0/+5
Add the positive-path host-based tests for the shared GptLib parser (extracted as part of the parser security hardening), ensuring the tightened checks in PartitionValidGptTable(), PartitionCheckGptEntry() and PartitionRestoreGptTable() do not falsely reject well-formed GPTs. The tests run against an in-memory mock disk and cover accepted primary/backup headers, boundary but legal header/entry sizes, correct entry-status flagging on valid entries, and primary/backup restore round-trips. Signed-off-by: Richard Lyu <richard.lyu@suse.com>
2026-06-25MdeModulePkg: Follow pragma once coding conventionMichael Kubacki2-8/+2
Update recent changes in MdeModulePkg to follow the latest EDK II C Coding Standards Specification (5.3) to use '#pragma once' instead of traditional macro-based include guards in header files. https://tianocore-docs.github.io/edk2-CCodingStandardsSpecification/draft/5_source_files/53_include_files.html#53-include-files Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-06-24MdeModulePkg: MemoryBins: Add GoogleTest and READMEOliver Smith-Denny1-0/+5
This commit adds unit tests and documentation for the Memory Bin feature. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
2026-04-02MdeModulePkg: Added several mock libraries for google testPaddyDeng5-0/+116
Added several mock libraries for google test so one can make google test drives consuming those libraries: - MockTpmMeasurementLib - MockFirmwareVolumeShadowPpi Signed-off-by: Paddy Deng <PaddyDeng@ami.com>
2026-02-24MdeModulePkg: Replace include guards with #pragma onceMichael Kubacki4-16/+4
Replace traditional `#ifndef`/`#define`/`#endif` include guards with `#pragma` once. `#pragma once` is a widely supported preprocessor directive that prevents header files from being included multiple times. It is supported by all toolchains used to build edk2: GCC, Clang/LLVM, and MSVC. Compared to macro-based include guards, `#pragma once`: - Eliminates the risk of macro name collisions or copy/paste errors where two headers inadvertently use the same guard macro. - Eliminate inconsistency in the way include guard macros are named (e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.). - Reduces boilerplate (three lines replaced by one). - Avoids polluting the macro namespace with guard symbols. - Can improve build times as the preprocessor can skip re-opening the file entirely, rather than re-reading it to find the matching `#endif` ("multiple-include optimization"). - Note that some compilers may already optimize traditional include guards, by recognzining the idiomatic pattern. This change is made acknowledging that overall portability of the code will technically be reduced, as `#pragma once` is not part of the C/C++ standards. However, this is considered acceptable given: 1. edk2 already defines a subset of supported compilers in BaseTools/Conf/tools_def.template, all of which have supported `#pragma once` for over two decades. 2. There have been concerns raised to the project about inconsistent include guard naming and potential macro collisions. Approximate compiler support dates: - MSVC: Supported since Visual C++ 4.2 (1996) - GCC: Supported since 3.4 (2004) (http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html) - Clang (LLVM based): Since initial release in 2007 Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2026-01-14MdeModulePkg: Add unit tests for DxeReportStatusCodeLibJoey Vagedes1-0/+7
This commit adds a host based unit test for DxeReportStatusCodeLib that ensures that the platform cannot invert the TPL on an initial call to ReportStatusCode functionality. Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
2025-09-19MdeModulePkg/Test/Include: Fix SecurityManagement include guardMichael D Kinney1-1/+1
Fix mimatched macro name of include guard in MockSecurityManagementLib.h. This was found with unit test build using CLANGDWARF. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-08-07MdeModulePkg: added SecurityManagementLib mockAlexander Gryanko4-0/+104
Added Google Mock test support for SecurityManagementLib Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
2025-05-28MdeModulePkg: Removed Pei, Dxe, Smm and mm header filesBhavani Subramanian1-4/+0
Signed-off-by: Bhavani Subramanian <v-bhavanisu@microsoft.com>
2025-05-28MdeModulePkg: Added MockHiiLibBhavani Subramanian4-0/+444
Signed-off-by: Bhavani Subramanian <v-bhavanisu@microsoft.com>
2025-02-07Add MockVariablePolicyHelperLibKane Chen4-0/+129
Signed-off-by: Kane Chen <kane.chen@microsoft.com>
2024-08-29MdeModulePkg/Bus/Pci/NvmExpressDxe: Nvm Express Media Sanitize Protocol.Ray Robles1-0/+5
Implementation of MEDIA_SANITIZE_PROTOCOL for NIST purge/clear actions with mapping to NVM Express native commands. Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
2023-11-27MdeModulePkg: Update DumpImageRecord() in ImagePropertiesRecordLibTaylor Beebe1-0/+1
Update DumpImageRecord() to be DumpImageRecords(), and improve the debug output. The function will output at DEBUG_INFO instead, and the function will be run in DXE and SMM MAT logic when the MAT is installed at EndOfDxe on DEBUG builds. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Taylor Beebe <taylor.d.beebe@gmail.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2023-11-27MdeModulePkg: Add ImagePropertiesRecordLib Host-Based Unit TestTaylor Beebe1-0/+5
Create a host-based unit test for the ImagePropertiesRecordLib SplitTable() logic. This test has 4 cases which tests different potential image and memory map layouts. 3/4 of these tests fail with the logic in its current state to provide proof of the bugs in the current MAT logic. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Dandan Bi <dandan.bi@intel.com> Signed-off-by: Taylor Beebe <taylor.d.beebe@gmail.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2023-10-27MdeModulePkg: Apply uncrustify formatting to relevant files.Vivian Nowka-Keane2-6/+6
Apply uncrustify formatting to GoogleTest cpp files and respective header file. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Vivian Nowka-Keane <vnowkakeane@linux.microsoft.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2023-05-10MdeModulePkg: Add more PciHostBridgeLib gmock supportGua Guo4-0/+94
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4443 Add Google Mock Library for PciHostBridgeLib Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Chris Johnson <chris.n.johnson@intel.com> Signed-off-by: Gua Guo <gua.guo@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2023-04-10MdeModulePkg/Library/UefiSortLib: Add GoogleTestLib exampleChris Johnson1-0/+6
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4389 Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Chris Johnson <chris.n.johnson@intel.com> Reviewed-by: Oliver Smith-Denny <osde@linux.microsoft.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2021-08-12MdeModulePkg/UefiSortLib:Add UefiSortLib unit testWenyi Xie1-0/+6
Adding two unit test case for UefiSortLib. One is a test on sorting an array of UINT32 by using PerformQuickSort, another is a test on comparing the same buffer by using StringCompare. Add 'main' function name to ECC exception list to avoid ECC error. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2020-12-15MdeModulePkg/Variable/RuntimeDxe: Add Variable Lock Protocol Unit TestsMichael D Kinney1-0/+11
https://bugzilla.tianocore.org/show_bug.cgi?id=3111 Add host based unit tests for the multiple lock case using Variable Lock Protocol, Variable Policy Protocol, and mixes of Variable Lock Protocol and Variable Policy Protocol. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Signed-off-by: Bret Barkelew <Bret.Barkelew@microsoft.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2020-02-07MdeModulePkg: Add DxeResetSystemLib unit testMichael D Kinney1-0/+32
https://bugzilla.tianocore.org/show_bug.cgi?id=2505 * Add unit test of DxeResetSystemLib library instance that uses cmocka interfaces to mock the UEFI Runtime Services Table and its ResetSystem() service. When a unit test uses the cmocka interfaces, the unit test does not support being run from target environments. cmocka APIs: https://api.cmocka.org/index.html This example puts the unit test in a UnitTest directory below the library INF file and this location means the unit test is only designed to work this this one library instance. * Add Test/MdeModulePkgHostTest.dsc to build host based unit tests Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Acked-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>