[edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes

Michael D Kinney posted 16 patches 3 years, 9 months ago
Failed in applying to current master (apply log)
.../Python/Workspace/WorkspaceCommon.py       |    4 +-
MdePkg/Include/Library/DebugLib.h             |   28 +-
MdePkg/Include/Library/UnitTestLib.h          |   90 +
.../BaseCacheMaintenanceLibNull.c             |  225 ++
.../BaseCacheMaintenanceLibNull.inf           |   29 +
.../BaseCacheMaintenanceLibNull.uni           |   12 +
.../Library/BaseCpuLibNull/BaseCpuLibNull.c   |   37 +
.../Library/BaseCpuLibNull/BaseCpuLibNull.inf |   26 +
.../Library/BaseCpuLibNull/BaseCpuLibNull.uni |   11 +
MdePkg/Library/BaseLib/BaseLib.inf            |    4 +-
MdePkg/Library/BaseLib/Ia32/GccInline.c       | 1181 +------
.../Ia32/{GccInline.c => GccInlinePriv.c}     |  601 +---
MdePkg/Library/BaseLib/UnitTestHost.c         |  140 +
MdePkg/Library/BaseLib/UnitTestHost.h         |   66 +
.../Library/BaseLib/UnitTestHostBaseLib.inf   |  217 ++
.../Library/BaseLib/UnitTestHostBaseLib.uni   |   11 +
MdePkg/Library/BaseLib/X64/GccInline.c        | 1240 +------
.../X64/{GccInline.c => GccInlinePriv.c}      |  572 +---
MdePkg/Library/BaseLib/X86UnitTestHost.c      | 2977 +++++++++++++++++
.../BaseStackCheckLib/BaseStackCheckLib.inf   |    2 +-
MdePkg/MdePkg.dec                             |    8 +-
MdePkg/MdePkg.dsc                             |    4 +-
MdePkg/Test/MdePkgHostTest.dsc                |    5 +
.../Include/Library/UnitTestHostBaseLib.h     |  582 ++++
.../UnitTestDebugAssertLib.c                  |   49 +
.../UnitTestDebugAssertLib.inf                |   31 +
.../UnitTestDebugAssertLib.uni                |   11 +
.../Library/UnitTestLib/Assert.c              |  217 +-
.../Library/UnitTestLib/AssertCmocka.c        |   68 +
.../Library/UnitTestLib/RunTests.c            |   23 +-
.../Library/UnitTestLib/RunTestsCmocka.c      |   33 +-
.../UnitTestResultReportLib.c                 |    3 +-
.../PrivateInclude/UnitTestFrameworkTypes.h   |    1 +
.../Sample/SampleUnitTest/SampleUnitTest.c    |  510 +++
.../SampleUnitTest/SampleUnitTestDxe.inf      |    3 +
.../SampleUnitTest/SampleUnitTestHost.inf     |    3 +
.../SampleUnitTest/SampleUnitTestPei.inf      |    3 +
.../SampleUnitTest/SampleUnitTestSmm.inf      |    3 +
.../SampleUnitTestUefiShell.inf               |    3 +
.../Test/UnitTestFrameworkPkgHostTest.dsc     |    5 +-
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc |    4 +
.../UnitTestFrameworkPkgHost.dsc.inc          |   11 +-
.../UnitTestFrameworkPkgTarget.dsc.inc        |   10 +-
43 files changed, 5374 insertions(+), 3689 deletions(-)
create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.c
create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf
create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.uni
create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c
create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf
create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni
copy MdePkg/Library/BaseLib/Ia32/{GccInline.c => GccInlinePriv.c} (62%)
create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.c
create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.h
create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.uni
copy MdePkg/Library/BaseLib/X64/{GccInline.c => GccInlinePriv.c} (65%)
create mode 100644 MdePkg/Library/BaseLib/X86UnitTestHost.c
create mode 100644 MdePkg/Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.c
create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.inf
create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.uni
[edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes
Posted by Michael D Kinney 3 years, 9 months ago
Changes in V3
==============
* Add UnitTestHostBaseLib class for the global variable that allows
  host based unit tests to hook and emulate some BaseLib services

Changes in V2
==============
* Add UnitTestExpectAssertFailure() to UnitTestLib to simplify the macro
  UT_EXPECT_ASSERT_FAILURE() and provide better log messages.
* Expand UnitTestFrameworkPkg sample unit tests to cover test cases for the new
  UT_EXPECT_ASSERT_FAILURE() macro and all other UnitTestLib macros.
* Add failure type FAILURETYPE_EXPECTASSERT when the macro
  UT_EXPECT_ASSERT_FAILURE() does not detect an ASSERT().
* Move print of log messages to end of cleanup function to support log
  messages generated in a cleanup function.
* Update running of target-based tests to use SetJump()/LongJump()
  around prereq, cleanup, and unit test functions to match the behavior
  of host based tests using cmocka. This also requires all UnitTestLib
  Assert functions to generate error log message first and then call
  UnitTestFailure() where the LongJump() is made to make sure all log
  messages are added before the LongJump().

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2797
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2798
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2799
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2800
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2801
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2803
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2804
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2805
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2806

* Add Null base libraries for host based unit tests
* Add host based test version of BaseLib with hooks for services that use
  privileged instructions.
* Add new UT_EXPECT_ASSERT_FAILURE() macro to UnitTestLib class
* Enable source level debug of unit tests
* Increase stack size to 256KB for host based tests on Windows
* Update BaseTools to support NULL libs for HOST_APPLICATION modules
* Guarantee print log works even if unit test generates an exception
* Use filename instead of function name in target mode logs

Cc: Liming Gao liming.gao@intel.com
Cc: Bob Feng bob.c.feng@intel.com
Cc: Sean Brogan sean.brogan@microsoft.com
Cc: Bret Barkelew Bret.Barkelew@microsoft.com
Cc: Jiewen Yao jiewen.yao@intel.com
Signed-off-by: Michael D Kinney michael.d.kinney@intel.com


Michael D Kinney (16):
  BaseTools/Python: Allow HOST_APPLICATION to use NULL libraries
  MdePkg/BaseCpuLibNull: Add Null version of CpuLib for host testing
  MdePkg/BaseCacheMaintenanceLibNull: Add Null instance for host testing
  MdePkg/BaseLib: Break out IA32/X64 GCC inline privileged functions
  MdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests
  UnitTestFrameworkPkg: Use host libraries from MdePkg
  UnitTestFrameworkPkg: Enable source level debug for host tests
  UnitTestFrameworkPkg: Set host application stack size to 256KB
  UnitTestFrameworkPkg: Change target mode DebugLib mapping
  UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup
  UnitTestFrameworkPkg/UnitTestLib: Fix target mode log messages
  UnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT()
  MdePkg/Include: Hook DebugLib _ASSERT() for unit tests
  MdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib
  MdePkg/Library/BaseStackCheckLib: Fix PCD type in INF
  UnitTestFramewokPkg/SampleUnitTest: Use UT_EXPECT_ASSERT_FAILURE()

 .../Python/Workspace/WorkspaceCommon.py       |    4 +-
 MdePkg/Include/Library/DebugLib.h             |   28 +-
 MdePkg/Include/Library/UnitTestLib.h          |   90 +
 .../BaseCacheMaintenanceLibNull.c             |  225 ++
 .../BaseCacheMaintenanceLibNull.inf           |   29 +
 .../BaseCacheMaintenanceLibNull.uni           |   12 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.c   |   37 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.inf |   26 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.uni |   11 +
 MdePkg/Library/BaseLib/BaseLib.inf            |    4 +-
 MdePkg/Library/BaseLib/Ia32/GccInline.c       | 1181 +------
 .../Ia32/{GccInline.c => GccInlinePriv.c}     |  601 +---
 MdePkg/Library/BaseLib/UnitTestHost.c         |  140 +
 MdePkg/Library/BaseLib/UnitTestHost.h         |   66 +
 .../Library/BaseLib/UnitTestHostBaseLib.inf   |  217 ++
 .../Library/BaseLib/UnitTestHostBaseLib.uni   |   11 +
 MdePkg/Library/BaseLib/X64/GccInline.c        | 1240 +------
 .../X64/{GccInline.c => GccInlinePriv.c}      |  572 +---
 MdePkg/Library/BaseLib/X86UnitTestHost.c      | 2977 +++++++++++++++++
 .../BaseStackCheckLib/BaseStackCheckLib.inf   |    2 +-
 MdePkg/MdePkg.dec                             |    8 +-
 MdePkg/MdePkg.dsc                             |    4 +-
 MdePkg/Test/MdePkgHostTest.dsc                |    5 +
 .../Include/Library/UnitTestHostBaseLib.h     |  582 ++++
 .../UnitTestDebugAssertLib.c                  |   49 +
 .../UnitTestDebugAssertLib.inf                |   31 +
 .../UnitTestDebugAssertLib.uni                |   11 +
 .../Library/UnitTestLib/Assert.c              |  217 +-
 .../Library/UnitTestLib/AssertCmocka.c        |   68 +
 .../Library/UnitTestLib/RunTests.c            |   23 +-
 .../Library/UnitTestLib/RunTestsCmocka.c      |   33 +-
 .../UnitTestResultReportLib.c                 |    3 +-
 .../PrivateInclude/UnitTestFrameworkTypes.h   |    1 +
 .../Sample/SampleUnitTest/SampleUnitTest.c    |  510 +++
 .../SampleUnitTest/SampleUnitTestDxe.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestHost.inf     |    3 +
 .../SampleUnitTest/SampleUnitTestPei.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestSmm.inf      |    3 +
 .../SampleUnitTestUefiShell.inf               |    3 +
 .../Test/UnitTestFrameworkPkgHostTest.dsc     |    5 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc |    4 +
 .../UnitTestFrameworkPkgHost.dsc.inc          |   11 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc        |   10 +-
 43 files changed, 5374 insertions(+), 3689 deletions(-)
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.c
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.uni
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni
 copy MdePkg/Library/BaseLib/Ia32/{GccInline.c => GccInlinePriv.c} (62%)
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.c
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.h
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.uni
 copy MdePkg/Library/BaseLib/X64/{GccInline.c => GccInlinePriv.c} (65%)
 create mode 100644 MdePkg/Library/BaseLib/X86UnitTestHost.c
 create mode 100644 MdePkg/Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.c
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.inf
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.uni

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62353): https://edk2.groups.io/g/devel/message/62353
Mute This Topic: https://groups.io/mt/75432213/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [EXTERNAL] [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes
Posted by Bret Barkelew via groups.io 3 years, 9 months ago
Can’t tell if I got them all. Just let me know if you’re missing any. Thanks!

- Bret

From: Michael D Kinney via groups.io<mailto:michael.d.kinney=intel.com@groups.io>
Sent: Friday, July 10, 2020 7:09 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: [EXTERNAL] [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes

Changes in V3
==============
* Add UnitTestHostBaseLib class for the global variable that allows
  host based unit tests to hook and emulate some BaseLib services

Changes in V2
==============
* Add UnitTestExpectAssertFailure() to UnitTestLib to simplify the macro
  UT_EXPECT_ASSERT_FAILURE() and provide better log messages.
* Expand UnitTestFrameworkPkg sample unit tests to cover test cases for the new
  UT_EXPECT_ASSERT_FAILURE() macro and all other UnitTestLib macros.
* Add failure type FAILURETYPE_EXPECTASSERT when the macro
  UT_EXPECT_ASSERT_FAILURE() does not detect an ASSERT().
* Move print of log messages to end of cleanup function to support log
  messages generated in a cleanup function.
* Update running of target-based tests to use SetJump()/LongJump()
  around prereq, cleanup, and unit test functions to match the behavior
  of host based tests using cmocka. This also requires all UnitTestLib
  Assert functions to generate error log message first and then call
  UnitTestFailure() where the LongJump() is made to make sure all log
  messages are added before the LongJump().

REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2797&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=uuTtY%2BtdCZvv4r6cCeBlydCmqftVVBuTwkg8TXtVqco%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2798&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=OZqCcWPq6GJ3QO3YQcAPV7r04u2xzJCwjDzg2QbW7Uc%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2799&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=%2BkvS3Ar5kX65TKkNy46hsNcGihYBHebpYguFJEXjVEg%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2800&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=Vxdm4iRHixD9FzJjGpIPAwZKgo6OKct1nxGfiU6ycv4%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2801&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=PkSMoe6u7y1yLFY%2BsvXVI0DRLvfWnCWRmPRN1L0G8wY%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2803&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=rRq%2ByS4%2FnUaA4hV8Rwfks16P3IGgePwDS1MuMYbaPXg%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2804&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=AQBJfetimL0OhXoNmLGOrlDmkz01RC0onv5OUR4Jl8k%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2805&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=%2B07i4x%2BTRHGq3SlQsDndfVJvuhqcno9EOWHD%2Ba36WVE%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2806&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=rrb2NdSxAxUHvUjS0D2Gh%2B0dbgQdU2JlPqtIfMvgTDE%3D&amp;reserved=0

* Add Null base libraries for host based unit tests
* Add host based test version of BaseLib with hooks for services that use
  privileged instructions.
* Add new UT_EXPECT_ASSERT_FAILURE() macro to UnitTestLib class
* Enable source level debug of unit tests
* Increase stack size to 256KB for host based tests on Windows
* Update BaseTools to support NULL libs for HOST_APPLICATION modules
* Guarantee print log works even if unit test generates an exception
* Use filename instead of function name in target mode logs

Cc: Liming Gao liming.gao@intel.com
Cc: Bob Feng bob.c.feng@intel.com
Cc: Sean Brogan sean.brogan@microsoft.com
Cc: Bret Barkelew Bret.Barkelew@microsoft.com
Cc: Jiewen Yao jiewen.yao@intel.com
Signed-off-by: Michael D Kinney michael.d.kinney@intel.com


Michael D Kinney (16):
  BaseTools/Python: Allow HOST_APPLICATION to use NULL libraries
  MdePkg/BaseCpuLibNull: Add Null version of CpuLib for host testing
  MdePkg/BaseCacheMaintenanceLibNull: Add Null instance for host testing
  MdePkg/BaseLib: Break out IA32/X64 GCC inline privileged functions
  MdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests
  UnitTestFrameworkPkg: Use host libraries from MdePkg
  UnitTestFrameworkPkg: Enable source level debug for host tests
  UnitTestFrameworkPkg: Set host application stack size to 256KB
  UnitTestFrameworkPkg: Change target mode DebugLib mapping
  UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup
  UnitTestFrameworkPkg/UnitTestLib: Fix target mode log messages
  UnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT()
  MdePkg/Include: Hook DebugLib _ASSERT() for unit tests
  MdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib
  MdePkg/Library/BaseStackCheckLib: Fix PCD type in INF
  UnitTestFramewokPkg/SampleUnitTest: Use UT_EXPECT_ASSERT_FAILURE()

 .../Python/Workspace/WorkspaceCommon.py       |    4 +-
 MdePkg/Include/Library/DebugLib.h             |   28 +-
 MdePkg/Include/Library/UnitTestLib.h          |   90 +
 .../BaseCacheMaintenanceLibNull.c             |  225 ++
 .../BaseCacheMaintenanceLibNull.inf           |   29 +
 .../BaseCacheMaintenanceLibNull.uni           |   12 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.c   |   37 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.inf |   26 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.uni |   11 +
 MdePkg/Library/BaseLib/BaseLib.inf            |    4 +-
 MdePkg/Library/BaseLib/Ia32/GccInline.c       | 1181 +------
 .../Ia32/{GccInline.c => GccInlinePriv.c}     |  601 +---
 MdePkg/Library/BaseLib/UnitTestHost.c         |  140 +
 MdePkg/Library/BaseLib/UnitTestHost.h         |   66 +
 .../Library/BaseLib/UnitTestHostBaseLib.inf   |  217 ++
 .../Library/BaseLib/UnitTestHostBaseLib.uni   |   11 +
 MdePkg/Library/BaseLib/X64/GccInline.c        | 1240 +------
 .../X64/{GccInline.c => GccInlinePriv.c}      |  572 +---
 MdePkg/Library/BaseLib/X86UnitTestHost.c      | 2977 +++++++++++++++++
 .../BaseStackCheckLib/BaseStackCheckLib.inf   |    2 +-
 MdePkg/MdePkg.dec                             |    8 +-
 MdePkg/MdePkg.dsc                             |    4 +-
 MdePkg/Test/MdePkgHostTest.dsc                |    5 +
 .../Include/Library/UnitTestHostBaseLib.h     |  582 ++++
 .../UnitTestDebugAssertLib.c                  |   49 +
 .../UnitTestDebugAssertLib.inf                |   31 +
 .../UnitTestDebugAssertLib.uni                |   11 +
 .../Library/UnitTestLib/Assert.c              |  217 +-
 .../Library/UnitTestLib/AssertCmocka.c        |   68 +
 .../Library/UnitTestLib/RunTests.c            |   23 +-
 .../Library/UnitTestLib/RunTestsCmocka.c      |   33 +-
 .../UnitTestResultReportLib.c                 |    3 +-
 .../PrivateInclude/UnitTestFrameworkTypes.h   |    1 +
 .../Sample/SampleUnitTest/SampleUnitTest.c    |  510 +++
 .../SampleUnitTest/SampleUnitTestDxe.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestHost.inf     |    3 +
 .../SampleUnitTest/SampleUnitTestPei.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestSmm.inf      |    3 +
 .../SampleUnitTestUefiShell.inf               |    3 +
 .../Test/UnitTestFrameworkPkgHostTest.dsc     |    5 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc |    4 +
 .../UnitTestFrameworkPkgHost.dsc.inc          |   11 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc        |   10 +-
 43 files changed, 5374 insertions(+), 3689 deletions(-)
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.c
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.uni
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni
 copy MdePkg/Library/BaseLib/Ia32/{GccInline.c => GccInlinePriv.c} (62%)
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.c
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.h
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.uni
 copy MdePkg/Library/BaseLib/X64/{GccInline.c => GccInlinePriv.c} (65%)
 create mode 100644 MdePkg/Library/BaseLib/X86UnitTestHost.c
 create mode 100644 MdePkg/Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.c
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.inf
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.uni

--
2.21.0.windows.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62587): https://edk2.groups.io/g/devel/message/62587
Mute This Topic: https://groups.io/mt/75514394/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes
Posted by Liming Gao 3 years, 9 months ago
Mike:
 Thanks for your update. This patch set is good to me. Reviewed-by: Liming Gao <liming.gao@intel.com>

Thanks
Liming
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael D Kinney
Sent: 2020年7月11日 10:09
To: devel@edk2.groups.io
Subject: [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes

Changes in V3
==============
* Add UnitTestHostBaseLib class for the global variable that allows
  host based unit tests to hook and emulate some BaseLib services

Changes in V2
==============
* Add UnitTestExpectAssertFailure() to UnitTestLib to simplify the macro
  UT_EXPECT_ASSERT_FAILURE() and provide better log messages.
* Expand UnitTestFrameworkPkg sample unit tests to cover test cases for the new
  UT_EXPECT_ASSERT_FAILURE() macro and all other UnitTestLib macros.
* Add failure type FAILURETYPE_EXPECTASSERT when the macro
  UT_EXPECT_ASSERT_FAILURE() does not detect an ASSERT().
* Move print of log messages to end of cleanup function to support log
  messages generated in a cleanup function.
* Update running of target-based tests to use SetJump()/LongJump()
  around prereq, cleanup, and unit test functions to match the behavior
  of host based tests using cmocka. This also requires all UnitTestLib
  Assert functions to generate error log message first and then call
  UnitTestFailure() where the LongJump() is made to make sure all log
  messages are added before the LongJump().

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2797
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2798
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2799
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2800
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2801
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2803
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2804
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2805
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2806

* Add Null base libraries for host based unit tests
* Add host based test version of BaseLib with hooks for services that use
  privileged instructions.
* Add new UT_EXPECT_ASSERT_FAILURE() macro to UnitTestLib class
* Enable source level debug of unit tests
* Increase stack size to 256KB for host based tests on Windows
* Update BaseTools to support NULL libs for HOST_APPLICATION modules
* Guarantee print log works even if unit test generates an exception
* Use filename instead of function name in target mode logs

Cc: Liming Gao liming.gao@intel.com
Cc: Bob Feng bob.c.feng@intel.com
Cc: Sean Brogan sean.brogan@microsoft.com
Cc: Bret Barkelew Bret.Barkelew@microsoft.com
Cc: Jiewen Yao jiewen.yao@intel.com
Signed-off-by: Michael D Kinney michael.d.kinney@intel.com


Michael D Kinney (16):
  BaseTools/Python: Allow HOST_APPLICATION to use NULL libraries
  MdePkg/BaseCpuLibNull: Add Null version of CpuLib for host testing
  MdePkg/BaseCacheMaintenanceLibNull: Add Null instance for host testing
  MdePkg/BaseLib: Break out IA32/X64 GCC inline privileged functions
  MdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests
  UnitTestFrameworkPkg: Use host libraries from MdePkg
  UnitTestFrameworkPkg: Enable source level debug for host tests
  UnitTestFrameworkPkg: Set host application stack size to 256KB
  UnitTestFrameworkPkg: Change target mode DebugLib mapping
  UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup
  UnitTestFrameworkPkg/UnitTestLib: Fix target mode log messages
  UnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT()
  MdePkg/Include: Hook DebugLib _ASSERT() for unit tests
  MdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib
  MdePkg/Library/BaseStackCheckLib: Fix PCD type in INF
  UnitTestFramewokPkg/SampleUnitTest: Use UT_EXPECT_ASSERT_FAILURE()

 .../Python/Workspace/WorkspaceCommon.py       |    4 +-
 MdePkg/Include/Library/DebugLib.h             |   28 +-
 MdePkg/Include/Library/UnitTestLib.h          |   90 +
 .../BaseCacheMaintenanceLibNull.c             |  225 ++
 .../BaseCacheMaintenanceLibNull.inf           |   29 +
 .../BaseCacheMaintenanceLibNull.uni           |   12 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.c   |   37 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.inf |   26 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.uni |   11 +
 MdePkg/Library/BaseLib/BaseLib.inf            |    4 +-
 MdePkg/Library/BaseLib/Ia32/GccInline.c       | 1181 +------
 .../Ia32/{GccInline.c => GccInlinePriv.c}     |  601 +---
 MdePkg/Library/BaseLib/UnitTestHost.c         |  140 +
 MdePkg/Library/BaseLib/UnitTestHost.h         |   66 +
 .../Library/BaseLib/UnitTestHostBaseLib.inf   |  217 ++
 .../Library/BaseLib/UnitTestHostBaseLib.uni   |   11 +
 MdePkg/Library/BaseLib/X64/GccInline.c        | 1240 +------
 .../X64/{GccInline.c => GccInlinePriv.c}      |  572 +---
 MdePkg/Library/BaseLib/X86UnitTestHost.c      | 2977 +++++++++++++++++
 .../BaseStackCheckLib/BaseStackCheckLib.inf   |    2 +-
 MdePkg/MdePkg.dec                             |    8 +-
 MdePkg/MdePkg.dsc                             |    4 +-
 MdePkg/Test/MdePkgHostTest.dsc                |    5 +
 .../Include/Library/UnitTestHostBaseLib.h     |  582 ++++
 .../UnitTestDebugAssertLib.c                  |   49 +
 .../UnitTestDebugAssertLib.inf                |   31 +
 .../UnitTestDebugAssertLib.uni                |   11 +
 .../Library/UnitTestLib/Assert.c              |  217 +-
 .../Library/UnitTestLib/AssertCmocka.c        |   68 +
 .../Library/UnitTestLib/RunTests.c            |   23 +-
 .../Library/UnitTestLib/RunTestsCmocka.c      |   33 +-
 .../UnitTestResultReportLib.c                 |    3 +-
 .../PrivateInclude/UnitTestFrameworkTypes.h   |    1 +
 .../Sample/SampleUnitTest/SampleUnitTest.c    |  510 +++
 .../SampleUnitTest/SampleUnitTestDxe.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestHost.inf     |    3 +
 .../SampleUnitTest/SampleUnitTestPei.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestSmm.inf      |    3 +
 .../SampleUnitTestUefiShell.inf               |    3 +
 .../Test/UnitTestFrameworkPkgHostTest.dsc     |    5 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc |    4 +
 .../UnitTestFrameworkPkgHost.dsc.inc          |   11 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc        |   10 +-
 43 files changed, 5374 insertions(+), 3689 deletions(-)  create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.c
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.uni
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni
 copy MdePkg/Library/BaseLib/Ia32/{GccInline.c => GccInlinePriv.c} (62%)  create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.c
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.h
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.uni
 copy MdePkg/Library/BaseLib/X64/{GccInline.c => GccInlinePriv.c} (65%)  create mode 100644 MdePkg/Library/BaseLib/X86UnitTestHost.c
 create mode 100644 MdePkg/Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.c
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.inf
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.uni

--
2.21.0.windows.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62479): https://edk2.groups.io/g/devel/message/62479
Mute This Topic: https://groups.io/mt/75432213/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes
Posted by Bret Barkelew via groups.io 3 years, 9 months ago
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>


- Bret

________________________________
From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Liming Gao via groups.io <liming.gao=intel.com@groups.io>
Sent: Monday, July 13, 2020 11:54:53 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [EXTERNAL] Re: [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes

Mike:
 Thanks for your update. This patch set is good to me. Reviewed-by: Liming Gao <liming.gao@intel.com>

Thanks
Liming
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael D Kinney
Sent: 2020年7月11日 10:09
To: devel@edk2.groups.io
Subject: [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes

Changes in V3
==============
* Add UnitTestHostBaseLib class for the global variable that allows
  host based unit tests to hook and emulate some BaseLib services

Changes in V2
==============
* Add UnitTestExpectAssertFailure() to UnitTestLib to simplify the macro
  UT_EXPECT_ASSERT_FAILURE() and provide better log messages.
* Expand UnitTestFrameworkPkg sample unit tests to cover test cases for the new
  UT_EXPECT_ASSERT_FAILURE() macro and all other UnitTestLib macros.
* Add failure type FAILURETYPE_EXPECTASSERT when the macro
  UT_EXPECT_ASSERT_FAILURE() does not detect an ASSERT().
* Move print of log messages to end of cleanup function to support log
  messages generated in a cleanup function.
* Update running of target-based tests to use SetJump()/LongJump()
  around prereq, cleanup, and unit test functions to match the behavior
  of host based tests using cmocka. This also requires all UnitTestLib
  Assert functions to generate error log message first and then call
  UnitTestFailure() where the LongJump() is made to make sure all log
  messages are added before the LongJump().

REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2797&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=Cvs4rSfp%2FUl15lR331i0WOqsz0X0XGYc9nPu%2FFu5Ce0%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2798&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=gKBdHVSP%2F3QmwmX%2FAhCjQcIC6BMU%2F8yx6BM03VYaugo%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2799&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=eBVwmQgDnQLCOKhIybCJ8nn9CU43aO3shuTlUSxzC%2BM%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2800&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=7sFBxWZvhxXfiLAyCgaExGqAW%2F8yfIU0p2hlMLK4XUg%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2801&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=jYoltIH%2BvS43A1b5koMYdK0bnmPt8Pa4tz6QkbezYc4%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2803&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=Neyrn2INlcMtlJ%2BbS456GPRWVxb5ALL%2B9BcLMGqX69Q%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2804&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=hkyOv8qhQ3iC%2FwvqnayiBeot6AYwfRho%2FUmhfcVd0qo%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2805&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=TLvx%2FUylNXEyMOBlikWOfnQHnbqyR1JiCm9uIod859Q%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2806&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cdb2bad178b6044d37e1208d827c2d38e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637303065010616592&amp;sdata=Wh7uoily48Be5EFItwd7o6whBtQZy82jh0cIDE%2FDrCY%3D&amp;reserved=0

* Add Null base libraries for host based unit tests
* Add host based test version of BaseLib with hooks for services that use
  privileged instructions.
* Add new UT_EXPECT_ASSERT_FAILURE() macro to UnitTestLib class
* Enable source level debug of unit tests
* Increase stack size to 256KB for host based tests on Windows
* Update BaseTools to support NULL libs for HOST_APPLICATION modules
* Guarantee print log works even if unit test generates an exception
* Use filename instead of function name in target mode logs

Cc: Liming Gao liming.gao@intel.com
Cc: Bob Feng bob.c.feng@intel.com
Cc: Sean Brogan sean.brogan@microsoft.com
Cc: Bret Barkelew Bret.Barkelew@microsoft.com
Cc: Jiewen Yao jiewen.yao@intel.com
Signed-off-by: Michael D Kinney michael.d.kinney@intel.com


Michael D Kinney (16):
  BaseTools/Python: Allow HOST_APPLICATION to use NULL libraries
  MdePkg/BaseCpuLibNull: Add Null version of CpuLib for host testing
  MdePkg/BaseCacheMaintenanceLibNull: Add Null instance for host testing
  MdePkg/BaseLib: Break out IA32/X64 GCC inline privileged functions
  MdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests
  UnitTestFrameworkPkg: Use host libraries from MdePkg
  UnitTestFrameworkPkg: Enable source level debug for host tests
  UnitTestFrameworkPkg: Set host application stack size to 256KB
  UnitTestFrameworkPkg: Change target mode DebugLib mapping
  UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup
  UnitTestFrameworkPkg/UnitTestLib: Fix target mode log messages
  UnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT()
  MdePkg/Include: Hook DebugLib _ASSERT() for unit tests
  MdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib
  MdePkg/Library/BaseStackCheckLib: Fix PCD type in INF
  UnitTestFramewokPkg/SampleUnitTest: Use UT_EXPECT_ASSERT_FAILURE()

 .../Python/Workspace/WorkspaceCommon.py       |    4 +-
 MdePkg/Include/Library/DebugLib.h             |   28 +-
 MdePkg/Include/Library/UnitTestLib.h          |   90 +
 .../BaseCacheMaintenanceLibNull.c             |  225 ++
 .../BaseCacheMaintenanceLibNull.inf           |   29 +
 .../BaseCacheMaintenanceLibNull.uni           |   12 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.c   |   37 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.inf |   26 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.uni |   11 +
 MdePkg/Library/BaseLib/BaseLib.inf            |    4 +-
 MdePkg/Library/BaseLib/Ia32/GccInline.c       | 1181 +------
 .../Ia32/{GccInline.c => GccInlinePriv.c}     |  601 +---
 MdePkg/Library/BaseLib/UnitTestHost.c         |  140 +
 MdePkg/Library/BaseLib/UnitTestHost.h         |   66 +
 .../Library/BaseLib/UnitTestHostBaseLib.inf   |  217 ++
 .../Library/BaseLib/UnitTestHostBaseLib.uni   |   11 +
 MdePkg/Library/BaseLib/X64/GccInline.c        | 1240 +------
 .../X64/{GccInline.c => GccInlinePriv.c}      |  572 +---
 MdePkg/Library/BaseLib/X86UnitTestHost.c      | 2977 +++++++++++++++++
 .../BaseStackCheckLib/BaseStackCheckLib.inf   |    2 +-
 MdePkg/MdePkg.dec                             |    8 +-
 MdePkg/MdePkg.dsc                             |    4 +-
 MdePkg/Test/MdePkgHostTest.dsc                |    5 +
 .../Include/Library/UnitTestHostBaseLib.h     |  582 ++++
 .../UnitTestDebugAssertLib.c                  |   49 +
 .../UnitTestDebugAssertLib.inf                |   31 +
 .../UnitTestDebugAssertLib.uni                |   11 +
 .../Library/UnitTestLib/Assert.c              |  217 +-
 .../Library/UnitTestLib/AssertCmocka.c        |   68 +
 .../Library/UnitTestLib/RunTests.c            |   23 +-
 .../Library/UnitTestLib/RunTestsCmocka.c      |   33 +-
 .../UnitTestResultReportLib.c                 |    3 +-
 .../PrivateInclude/UnitTestFrameworkTypes.h   |    1 +
 .../Sample/SampleUnitTest/SampleUnitTest.c    |  510 +++
 .../SampleUnitTest/SampleUnitTestDxe.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestHost.inf     |    3 +
 .../SampleUnitTest/SampleUnitTestPei.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestSmm.inf      |    3 +
 .../SampleUnitTestUefiShell.inf               |    3 +
 .../Test/UnitTestFrameworkPkgHostTest.dsc     |    5 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc |    4 +
 .../UnitTestFrameworkPkgHost.dsc.inc          |   11 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc        |   10 +-
 43 files changed, 5374 insertions(+), 3689 deletions(-)  create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.c
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.uni
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni
 copy MdePkg/Library/BaseLib/Ia32/{GccInline.c => GccInlinePriv.c} (62%)  create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.c
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.h
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.uni
 copy MdePkg/Library/BaseLib/X64/{GccInline.c => GccInlinePriv.c} (65%)  create mode 100644 MdePkg/Library/BaseLib/X86UnitTestHost.c
 create mode 100644 MdePkg/Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.c
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.inf
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.uni

--
2.21.0.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62581): https://edk2.groups.io/g/devel/message/62581
Mute This Topic: https://groups.io/mt/75432213/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [EXTERNAL] [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes
Posted by Bret Barkelew via groups.io 3 years, 9 months ago
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>


- Bret

From: Michael D Kinney via groups.io<mailto:michael.d.kinney=intel.com@groups.io>
Sent: Friday, July 10, 2020 7:09 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Subject: [EXTERNAL] [edk2-devel] [Patch v3 00/16] UnitTestFrameworkPkg: Enhancements and bug fixes

Changes in V3
==============
* Add UnitTestHostBaseLib class for the global variable that allows
  host based unit tests to hook and emulate some BaseLib services

Changes in V2
==============
* Add UnitTestExpectAssertFailure() to UnitTestLib to simplify the macro
  UT_EXPECT_ASSERT_FAILURE() and provide better log messages.
* Expand UnitTestFrameworkPkg sample unit tests to cover test cases for the new
  UT_EXPECT_ASSERT_FAILURE() macro and all other UnitTestLib macros.
* Add failure type FAILURETYPE_EXPECTASSERT when the macro
  UT_EXPECT_ASSERT_FAILURE() does not detect an ASSERT().
* Move print of log messages to end of cleanup function to support log
  messages generated in a cleanup function.
* Update running of target-based tests to use SetJump()/LongJump()
  around prereq, cleanup, and unit test functions to match the behavior
  of host based tests using cmocka. This also requires all UnitTestLib
  Assert functions to generate error log message first and then call
  UnitTestFailure() where the LongJump() is made to make sure all log
  messages are added before the LongJump().

REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2797&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=uuTtY%2BtdCZvv4r6cCeBlydCmqftVVBuTwkg8TXtVqco%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2798&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=OZqCcWPq6GJ3QO3YQcAPV7r04u2xzJCwjDzg2QbW7Uc%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2799&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=%2BkvS3Ar5kX65TKkNy46hsNcGihYBHebpYguFJEXjVEg%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2800&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=Vxdm4iRHixD9FzJjGpIPAwZKgo6OKct1nxGfiU6ycv4%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2801&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=PkSMoe6u7y1yLFY%2BsvXVI0DRLvfWnCWRmPRN1L0G8wY%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2803&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=rRq%2ByS4%2FnUaA4hV8Rwfks16P3IGgePwDS1MuMYbaPXg%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2804&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=AQBJfetimL0OhXoNmLGOrlDmkz01RC0onv5OUR4Jl8k%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2805&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=%2B07i4x%2BTRHGq3SlQsDndfVJvuhqcno9EOWHD%2Ba36WVE%3D&amp;reserved=0
REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2806&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C85c2633c67ce49ad912208d8253f684a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637300301547515364&amp;sdata=rrb2NdSxAxUHvUjS0D2Gh%2B0dbgQdU2JlPqtIfMvgTDE%3D&amp;reserved=0

* Add Null base libraries for host based unit tests
* Add host based test version of BaseLib with hooks for services that use
  privileged instructions.
* Add new UT_EXPECT_ASSERT_FAILURE() macro to UnitTestLib class
* Enable source level debug of unit tests
* Increase stack size to 256KB for host based tests on Windows
* Update BaseTools to support NULL libs for HOST_APPLICATION modules
* Guarantee print log works even if unit test generates an exception
* Use filename instead of function name in target mode logs

Cc: Liming Gao liming.gao@intel.com
Cc: Bob Feng bob.c.feng@intel.com
Cc: Sean Brogan sean.brogan@microsoft.com
Cc: Bret Barkelew Bret.Barkelew@microsoft.com
Cc: Jiewen Yao jiewen.yao@intel.com
Signed-off-by: Michael D Kinney michael.d.kinney@intel.com


Michael D Kinney (16):
  BaseTools/Python: Allow HOST_APPLICATION to use NULL libraries
  MdePkg/BaseCpuLibNull: Add Null version of CpuLib for host testing
  MdePkg/BaseCacheMaintenanceLibNull: Add Null instance for host testing
  MdePkg/BaseLib: Break out IA32/X64 GCC inline privileged functions
  MdePkg/Library/BaseLib: Add BaseLib instance for host based unit tests
  UnitTestFrameworkPkg: Use host libraries from MdePkg
  UnitTestFrameworkPkg: Enable source level debug for host tests
  UnitTestFrameworkPkg: Set host application stack size to 256KB
  UnitTestFrameworkPkg: Change target mode DebugLib mapping
  UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanup
  UnitTestFrameworkPkg/UnitTestLib: Fix target mode log messages
  UnitTestFrameworkPkg/UnitTestLib: Add checks for ASSERT()
  MdePkg/Include: Hook DebugLib _ASSERT() for unit tests
  MdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib
  MdePkg/Library/BaseStackCheckLib: Fix PCD type in INF
  UnitTestFramewokPkg/SampleUnitTest: Use UT_EXPECT_ASSERT_FAILURE()

 .../Python/Workspace/WorkspaceCommon.py       |    4 +-
 MdePkg/Include/Library/DebugLib.h             |   28 +-
 MdePkg/Include/Library/UnitTestLib.h          |   90 +
 .../BaseCacheMaintenanceLibNull.c             |  225 ++
 .../BaseCacheMaintenanceLibNull.inf           |   29 +
 .../BaseCacheMaintenanceLibNull.uni           |   12 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.c   |   37 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.inf |   26 +
 .../Library/BaseCpuLibNull/BaseCpuLibNull.uni |   11 +
 MdePkg/Library/BaseLib/BaseLib.inf            |    4 +-
 MdePkg/Library/BaseLib/Ia32/GccInline.c       | 1181 +------
 .../Ia32/{GccInline.c => GccInlinePriv.c}     |  601 +---
 MdePkg/Library/BaseLib/UnitTestHost.c         |  140 +
 MdePkg/Library/BaseLib/UnitTestHost.h         |   66 +
 .../Library/BaseLib/UnitTestHostBaseLib.inf   |  217 ++
 .../Library/BaseLib/UnitTestHostBaseLib.uni   |   11 +
 MdePkg/Library/BaseLib/X64/GccInline.c        | 1240 +------
 .../X64/{GccInline.c => GccInlinePriv.c}      |  572 +---
 MdePkg/Library/BaseLib/X86UnitTestHost.c      | 2977 +++++++++++++++++
 .../BaseStackCheckLib/BaseStackCheckLib.inf   |    2 +-
 MdePkg/MdePkg.dec                             |    8 +-
 MdePkg/MdePkg.dsc                             |    4 +-
 MdePkg/Test/MdePkgHostTest.dsc                |    5 +
 .../Include/Library/UnitTestHostBaseLib.h     |  582 ++++
 .../UnitTestDebugAssertLib.c                  |   49 +
 .../UnitTestDebugAssertLib.inf                |   31 +
 .../UnitTestDebugAssertLib.uni                |   11 +
 .../Library/UnitTestLib/Assert.c              |  217 +-
 .../Library/UnitTestLib/AssertCmocka.c        |   68 +
 .../Library/UnitTestLib/RunTests.c            |   23 +-
 .../Library/UnitTestLib/RunTestsCmocka.c      |   33 +-
 .../UnitTestResultReportLib.c                 |    3 +-
 .../PrivateInclude/UnitTestFrameworkTypes.h   |    1 +
 .../Sample/SampleUnitTest/SampleUnitTest.c    |  510 +++
 .../SampleUnitTest/SampleUnitTestDxe.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestHost.inf     |    3 +
 .../SampleUnitTest/SampleUnitTestPei.inf      |    3 +
 .../SampleUnitTest/SampleUnitTestSmm.inf      |    3 +
 .../SampleUnitTestUefiShell.inf               |    3 +
 .../Test/UnitTestFrameworkPkgHostTest.dsc     |    5 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc |    4 +
 .../UnitTestFrameworkPkgHost.dsc.inc          |   11 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc        |   10 +-
 43 files changed, 5374 insertions(+), 3689 deletions(-)
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.c
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.inf
 create mode 100644 MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCacheMaintenanceLibNull.uni
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.c
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.inf
 create mode 100644 MdePkg/Library/BaseCpuLibNull/BaseCpuLibNull.uni
 copy MdePkg/Library/BaseLib/Ia32/{GccInline.c => GccInlinePriv.c} (62%)
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.c
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHost.h
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
 create mode 100644 MdePkg/Library/BaseLib/UnitTestHostBaseLib.uni
 copy MdePkg/Library/BaseLib/X64/{GccInline.c => GccInlinePriv.c} (65%)
 create mode 100644 MdePkg/Library/BaseLib/X86UnitTestHost.c
 create mode 100644 MdePkg/Test/UnitTest/Include/Library/UnitTestHostBaseLib.h
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.c
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.inf
 create mode 100644 UnitTestFrameworkPkg/Library/UnitTestDebugAssertLib/UnitTestDebugAssertLib.uni

--
2.21.0.windows.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#62585): https://edk2.groups.io/g/devel/message/62585
Mute This Topic: https://groups.io/mt/75514387/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-