UnitTestFrameworkPkg: Use /MTd and enable Address Sanitizers

* Update host based unit test VS20xx builds to use /MTd instead of
  /MT to enable use of debug libraries for host based unit tests.
* Enable /fsanitize=address for host based unit test VS2019 builds
* Enable /fsanitize=address for host based unit test VS2022 builds
* Enable -fsanitize=address for host based unit test GCC builds
* Add UNIT_TESTING_ADDRESS_SANITIZER_ENABLE define that is set to
  TRUE by default so it is always enabled, but can be set to FALSE
  to temporarily disable during development/debug of unit tests.
* Add address sanitizer information to ReadMe.md

Enabling the Address Sanitizer can detect double frees, buffer
overflow, buffer underflow, access to invalid addresses, and
various exceptions. These can be detected in both the unit test
case sources as well as the code under test.

Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Michael D Kinney
2024-10-22 00:28:19 -07:00
committed by mergify[bot]
parent 8d0e23d998
commit de06288019
4 changed files with 71 additions and 9 deletions

View File

@@ -28,6 +28,6 @@
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
[BuildOptions]
MSFT:*_*_*_CC_FLAGS == /c /EHs /Zi /Od /MT
MSFT:*_*_*_CC_FLAGS == /c /EHs /Zi /Od /MTd
GCC:*_*_IA32_CC_FLAGS == -g -c -fshort-wchar -fexceptions -O0 -m32 -malign-double -fno-pie
GCC:*_*_X64_CC_FLAGS == -g -c -fshort-wchar -fexceptions -O0 -m64 -fno-pie "-DEFIAPI=__attribute__((ms_abi))"

View File

@@ -31,6 +31,6 @@
UnitTestLib
[BuildOptions]
MSFT:*_*_*_CC_FLAGS == /c /EHs /Zi /Od /MT
MSFT:*_*_*_CC_FLAGS == /c /EHs /Zi /Od /MTd
GCC:*_*_IA32_CC_FLAGS == -g -c -fshort-wchar -fexceptions -O0 -m32 -malign-double -fno-pie
GCC:*_*_X64_CC_FLAGS == -g -c -fshort-wchar -fexceptions -O0 -m64 -fno-pie "-DEFIAPI=__attribute__((ms_abi))"