-
Notifications
You must be signed in to change notification settings - Fork 162
[CHERRY-PICK] Unit Test Unexpected Exception #756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
VivianNK
merged 8 commits into
microsoft:release/202311
from
VivianNK:personal/vnowkakeane/cherry_unittestdebug
Mar 1, 2024
Merged
[CHERRY-PICK] Unit Test Unexpected Exception #756
VivianNK
merged 8 commits into
microsoft:release/202311
from
VivianNK:personal/vnowkakeane/cherry_unittestdebug
Mar 1, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4683 When VS20xx host-based unit tests are built with debug libraries a name collision occurs with the DebugLib.h internal macro _DEBUG(). Rename this internal macro to _DEBUGLIB_DEBUG() to address the name collision. Cc: Liming Gao <[email protected]> Cc: Zhiguang Liu <[email protected]> Signed-off-by: Michael D Kinney <[email protected]> Reviewed-by: Leif Lindholm <[email protected]>
… builds REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4683 Add /MT to MSFT CC_FLAGS to always use release libraries when building host-based unit tests so any exceptions generated during host-based test execution generate an error message in stderr instead of a popup window. Use /MTd when -D UNIT_TESTING_DEBUG is to use debug libraries when building host-based unit tests so any exceptions generated during host-based test execution generate a popup window with option to attach a debugger. Cc: Michael Kubacki <[email protected]> Cc: Sean Brogan <[email protected]> Signed-off-by: Michael D Kinney <[email protected]> Reviewed-by: Michael Kubacki <[email protected]>
…ing and gcov REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4683 Update MSFT CC_FLAGS for host-based unit tests to use /EHs instead of /EHsc to support building C functions with SEH (Structured Exception Handling) enabled. This is required to build UnitTestDebugAssertLibHost.inf. Update GCC CC_FLAGS for host-based unit tests to use -fexceptions to support catching exceptions. Update GoogleTestLib.h to include Throws() APIs that enable unit tests to use EXPECT_THAT() to check for expected ASSERT() conditions for a specific ASSERT() expression. Update GCC CC_FLAGS to add --coverage for host-based builds for all GCC tool chains. Cc: Michael Kubacki <[email protected]> Cc: Sean Brogan <[email protected]> Signed-off-by: Michael D Kinney <[email protected]> Reviewed-by: Michael Kubacki <[email protected]>
…dle() no ASSERT() REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4683 Update GetActiveFrameworkHandle() to remove ASSERT() and require caller to check for NULL. This allows GetActiveFrameworkHandle() to be used to determine if the current host-based test environment is framework/cmocka or gtest. In the framework/cmocka host-based environment GetActiveFrameworkHandle() returns non-NULL. In the gtest host-based environment GetActiveFrameworkHandle() returns NULL. Cc: Michael Kubacki <[email protected]> Cc: Sean Brogan <[email protected]> Signed-off-by: Michael D Kinney <[email protected]> Reviewed-by: Michael Kubacki <[email protected]>
…Test support REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4683 Add an C++ implementation of UnitTestDebugAssert() API for host-based environments. GoogleTest based environments throw a C++ exception of type std::runtime_error when an ASSERT() is triggered with a description that contains the filename, line number, and the expression that triggered the ASSERT(). Cc: Michael Kubacki <[email protected]> Cc: Sean Brogan <[email protected]> Signed-off-by: Michael D Kinney <[email protected]> Reviewed-by: Michael Kubacki <[email protected]>
…HROW() 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 <[email protected]> Cc: Sean Brogan <[email protected]> Signed-off-by: Michael D Kinney <[email protected]> Reviewed-by: Michael Kubacki <[email protected]>
…s fail 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 <[email protected]> Cc: Sean Brogan <[email protected]> Signed-off-by: Michael D Kinney <[email protected]> Reviewed-by: Michael Kubacki <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## release/202311 #756 +/- ##
==================================================
- Coverage 1.24% 1.23% -0.01%
==================================================
Files 1301 1301
Lines 332064 332064
Branches 5127 6683 +1556
==================================================
- Hits 4126 4117 -9
+ Misses 327891 327871 -20
- Partials 47 76 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
makubacki
approved these changes
Mar 1, 2024
kuqin12
approved these changes
Mar 1, 2024
apop5
approved these changes
Mar 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Cherry pick from: tianocore/edk2#5345
flow, or firmware?
validation improvement, ...
in build or boot behavior?
a function in a new library class in a pre-existing module, ...
outside direct code modifications (and comments)?
on an a separate Web page, ...
How This Was Tested
Local builds and CI tests ran.
Integration Instructions
N/A