summaryrefslogtreecommitdiff
path: root/UnitTestFrameworkPkg/Test/GoogleTest
AgeCommit message (Collapse)AuthorFilesLines
2026-07-31UnitTestFrameworkPkg: SampleGoogleTestGenerateException: Support AArch64Kun Qin2-11/+23
The SampleGoogleTestGenerateException GoogleTest sample previously generated a CPU exception by performing an integer divide by zero. That mechanism is X86-specific: the AArch64 architecture defines SDIV/UDIV by zero to return zero rather than raising a synchronous abort, so the sample produced no exception when built and run on AArch64 hosts and the test failed due to the test assert instead of triggering an exception through the framework. This change replaces the divide-by-zero with a NULL pointer write performed through a small volatile helper, which is expected to work on all host systems. The MSVC '/wd4723' build option is no longer needed because it was added to silence the divide-by-zero compile-time warning. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-07-31UnitTestFrameworkPkg: SampleGoogleTest: No divide-by-zero test for AArch64Kun Qin3-23/+43
AArch64 does not have divide-by-zero exception. This change modifies the corresponding test to work with AArch64. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
2026-03-22UnitTestFrameworkPkg/Test/GoogleTest/Sample: Add 0 testsMichael D Kinney1-0/+132
Add tests that check a local variable against 0 for values of type UINT8, UINT16, UINT32, UINT64, UINTN, UINT32 bitfields, and UINT64 bitfields. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-09-19UnitTestFrameworkPkg/SampleGoogleTest: Add missing override keywordMichael D Kinney2-2/+2
Add missing override keyword to c++ classes. Found by the clang++ compiler. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-01-21UnitTestFrameworkPkg/MemoryAllocationLibPosix: Add allocate below addressMichael D Kinney1-0/+210
Add HostMemoryAllocationBelowAddressLib class and implementation that uses OS specific services to perform pool and page allocations below a specified address in a host based unit test application execution environment. This library class is only required for mocking buffers that are assumed to be below a specific address by code under test. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2025-01-21UnitTestFrameworkPkg: Add failing unit tests cases for sanitizerMichael D Kinney1-0/+139
Add GoogleTest and Framework based unit tests that are expected to fail and be caught by Address Sanitizer. These unit tests verify that an address sanitizer is enabled and detecting the following conditions. It also provide examples of the expected output when an Address Sanitizer detected these types of issues. * double free * buffer overflow * buffer underflow * null ptr * invalid address * divide by zero Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
2024-02-14UnitTestFrameworkPkg: Add DSC and host tests that always failMichael D Kinney4-0/+463
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4683 Add sample unit tests that always fail or generate unexpected exceptions along with a new DSC file to build the unit tests that always fail or generate unexpected exceptions. This can be used to verify the log information on failures is accurate and provides the correct information to determine the source of the unit test failure. Divide by zero is used to generate unexpected exceptions. The compiler warnings for divide by zero are disables for the unit tests that generate divide by zero exceptions on purpose. These tests are not added to CI because CI would always fail. The UnitTestFrameworkPkg.ci.yaml file is updated to ignore the INF files for host-based testing that always fail. Cc: Michael Kubacki <mikuback@linux.microsoft.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-02-14UnitTestFrameworkPkg/SampleGoogleTest: Use EXPECT_ANY_THROW()Michael D Kinney1-5/+31
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4683 Update GoogleTest samples to use EXPECT_ANY_THROW() instead of ASSERT_DEATH(). ASSERT_DEATH() is a very slow method to detect an expected ASSERT() condition. Throwing an exception from ASSERT() and using EXPECT_ANY_THROW() is several orders of magnitude faster. Update GoogleTest sample with example of using EXPECT_THROW() and EXPECT_THAT() to check for more specific ASSERT() conditions that allow unit test cases to test functions that contain more than one ASSERT() statement and verify that the expected ASSERT() is the one that was actually triggered. Update library mappings so target-based unit tests use UnitTestDebugAssertLib.inf and host-based unit tests use UnitTestDebugAssertLibHost.inf Cc: Michael Kubacki <mikuback@linux.microsoft.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
2023-10-27UnitTestFrameworkPkg: Apply uncrustify formatting to relevant filesVivian Nowka-Keane1-31/+47
Apply uncrustify formatting to GoogleTest cpp and header files. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Michael Kubacki <mikuback@linux.microsoft.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Signed-off-by: Vivian Nowka-Keane <vnowkakeane@linux.microsoft.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
2022-11-11UnitTestFrameworkPkg: Add googletest submodule and GoogleTestLibMichael D Kinney2-0/+298
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134 Add submodule for googletest and add GoogleTestLib that is required for GoogleTest based unit tests. Add GoogleTest documentation to Readme.md along with a port of the sample unit test to the GoogleTest style. A few typos in Readme.md are also fixed. Cc: Michael Kubacki <mikuback@linux.microsoft.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <quic_llindhol@quicinc.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com> Acked-by: Leif Lindholm <quic_llindhol@quicinc.com>