From: "Kinney, Michael D" <michael.d.kinney@intel.com>
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.brogan@microsoft.com>,
Liming Gao <liming.gao@intel.com>,
Michael D Kinney <michael.d.kinney@intel.com>
Subject: [staging/edk2-test Patch 03/10] MsUnitTestPkg: Update for VS2017 and 32-bit apps
Date: Tue, 19 Dec 2017 16:00:07 -0800 [thread overview]
Message-ID: <20171220000014.9140-4-michael.d.kinney@intel.com> (raw)
In-Reply-To: <20171220000014.9140-1-michael.d.kinney@intel.com>
From: Sean Brogan <sean.brogan@microsoft.com>
Cherry-picked from branch:
https://github.com/Microsoft/MS_UEFI/tree/share/XmlAndUnitTest
Commit:
https://github.com/Microsoft/MS_UEFI/commit/d2901abfc9823c21d3a962fa69e025a92832466b
* Update Unit Test framework with minor changes to allow
32 bit apps to work.
* Update to support VS2017 compiler
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
MsUnitTestPkg/Include/Library/UnitTestAssertLib.h | 12 ++++++------
MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c | 8 ++++----
.../Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c | 2 ++
MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c | 4 ++--
MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.inf | 1 +
MsUnitTestPkg/MsUnitTestPkg.dec | 7 +++++++
6 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/MsUnitTestPkg/Include/Library/UnitTestAssertLib.h b/MsUnitTestPkg/Include/Library/UnitTestAssertLib.h
index 9f942848f9..2ebc61b5ab 100644
--- a/MsUnitTestPkg/Include/Library/UnitTestAssertLib.h
+++ b/MsUnitTestPkg/Include/Library/UnitTestAssertLib.h
@@ -37,13 +37,13 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if(!UnitTestAssertFalse( Framework, (Expression), __FUNCTION__, __LINE__, #Expression )) { return UNIT_TEST_ERROR_TEST_FAILED;}
#define UT_ASSERT_EQUAL(ValueA, ValueB) \
- if(!UnitTestAssertEqual( Framework, (UINTN)ValueA, (UINTN)ValueB, __FUNCTION__, __LINE__, #ValueA, #ValueB )) { return UNIT_TEST_ERROR_TEST_FAILED;}
+ if(!UnitTestAssertEqual( Framework, (UINT64)ValueA, (UINT64)ValueB, __FUNCTION__, __LINE__, #ValueA, #ValueB )) { return UNIT_TEST_ERROR_TEST_FAILED;}
#define UT_ASSERT_MEM_EQUAL(ValueA, ValueB, Length) \
if(!UnitTestAssertMemEqual( Framework, (UINTN)ValueA, (UINTN)ValueB, (UINTN)Length, __FUNCTION__, __LINE__, #ValueA, #ValueB )) { return UNIT_TEST_ERROR_TEST_FAILED;}
#define UT_ASSERT_NOT_EQUAL(ValueA, ValueB) \
- if(!UnitTestAssertNotEqual( Framework, ValueA, ValueB, __FUNCTION__, __LINE__, #ValueA, #ValueB )) { return UNIT_TEST_ERROR_TEST_FAILED;}
+ if(!UnitTestAssertNotEqual( Framework, (UINT64)ValueA, (UINT64)ValueB, __FUNCTION__, __LINE__, #ValueA, #ValueB )) { return UNIT_TEST_ERROR_TEST_FAILED;}
#define UT_ASSERT_NOT_EFI_ERROR(Status) \
if(!UnitTestAssertNotEfiError( Framework, Status, __FUNCTION__, __LINE__, #Status )) { return UNIT_TEST_ERROR_TEST_FAILED;}
@@ -89,8 +89,8 @@ BOOLEAN
EFIAPI
UnitTestAssertEqual (
IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN UINTN ValueA,
- IN UINTN ValueB,
+ IN UINT64 ValueA,
+ IN UINT64 ValueB,
IN CONST CHAR8 *FunctionName,
IN UINTN LineNumber,
IN CONST CHAR8 *DescriptionA,
@@ -114,8 +114,8 @@ BOOLEAN
EFIAPI
UnitTestAssertNotEqual (
IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN UINTN ValueA,
- IN UINTN ValueB,
+ IN UINT64 ValueA,
+ IN UINT64 ValueB,
IN CONST CHAR8 *FunctionName,
IN UINTN LineNumber,
IN CONST CHAR8 *DescriptionA,
diff --git a/MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c b/MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c
index 94279c7056..5721102818 100644
--- a/MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c
+++ b/MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c
@@ -93,8 +93,8 @@ BOOLEAN
EFIAPI
UnitTestAssertEqual (
IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN UINTN ValueA,
- IN UINTN ValueB,
+ IN UINT64 ValueA,
+ IN UINT64 ValueB,
IN CONST CHAR8 *FunctionName,
IN UINTN LineNumber,
IN CONST CHAR8 *DescriptionA,
@@ -136,8 +136,8 @@ BOOLEAN
EFIAPI
UnitTestAssertNotEqual (
IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN UINTN ValueA,
- IN UINTN ValueB,
+ IN UINT64 ValueA,
+ IN UINT64 ValueB,
IN CONST CHAR8 *FunctionName,
IN UINTN LineNumber,
IN CONST CHAR8 *DescriptionA,
diff --git a/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c b/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
index c176de726f..7fe82fb849 100644
--- a/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
+++ b/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
@@ -67,6 +67,7 @@ SetUsbBootNext(
if (DpEnd == NULL)
{
DEBUG((DEBUG_ERROR, __FUNCTION__ ": Unable to create device path. DpEnd is NULL.\n"));
+ Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
@@ -74,6 +75,7 @@ SetUsbBootNext(
if (Dp == NULL)
{
DEBUG((DEBUG_ERROR, __FUNCTION__ ": Unable to create device path. Dp is NULL.\n"));
+ Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
diff --git a/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c b/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
index 53ce0792fb..bc4176d36e 100644
--- a/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
@@ -654,7 +654,7 @@ UpdateTestFromSave (
Test->Result = MatchingTest->Result;
Test->FailureType = MatchingTest->FailureType;
- StrnCpy(&Test->FailureMessage[0], &MatchingTest->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH);
+ StrnCpyS(&Test->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH, &MatchingTest->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH);
// If there is a log string associated, grab that.
// We can tell that there's a log string because the "size" will be larger than
@@ -795,7 +795,7 @@ SerializeState (
// Save the result.
TestSaveData->Result = UnitTest->Result;
TestSaveData->FailureType = UnitTest->FailureType;
- StrnCpy(&TestSaveData->FailureMessage[0], &UnitTest->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH);
+ StrnCpyS(&TestSaveData->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH, &UnitTest->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH);
// If there is a log, save the log.
diff --git a/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.inf b/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.inf
index d85db8ebb9..a6576e1b85 100644
--- a/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.inf
+++ b/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.inf
@@ -39,6 +39,7 @@ LIBRARY_CLASS = UnitTestLib|DXE_DRIVER UEFI_APPLICATION
DebugLib
MemoryAllocationLib
BaseMemoryLib
+ BaseLib
UefiRuntimeServicesTableLib
UefiLib
UnitTestLogLib
diff --git a/MsUnitTestPkg/MsUnitTestPkg.dec b/MsUnitTestPkg/MsUnitTestPkg.dec
index 86c481d47d..9bc205c377 100644
--- a/MsUnitTestPkg/MsUnitTestPkg.dec
+++ b/MsUnitTestPkg/MsUnitTestPkg.dec
@@ -39,6 +39,13 @@
[LibraryClasses]
+ ## @libraryclass Provides a unit test framework
+ #
+ UnitTestLib|Include\Library\UnitTestLib.h
+
+ ## @libraryclass Provide unit test assert helpers
+ #
+ UnitTestAssertLib|Include\Library\UnitTestAssertLib.h
[Guids]
--
2.14.2.windows.3
next prev parent reply other threads:[~2017-12-19 23:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 0:00 [staging/edk2-test Patch 00/10] MsUnitTestPkg: Add Unit Test Support and sample Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 01/10] " Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 02/10] MsUnitTestPkg: Update copyright and license info Kinney, Michael D
2017-12-20 0:00 ` Kinney, Michael D [this message]
2017-12-20 0:00 ` [staging/edk2-test Patch 04/10] MsUnitTestPkg/Include: Remove use of variadic macros Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 05/10] MsUnitTestPkg/Library: Use safe string functions Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 06/10] MsUnitTestPkg/UnitTestLib: Fix GCC build errors Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 07/10] MsUnitTestPkg/Library: Update __FUNCTION__ usage Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 08/10] MsUnitTestPkg: Add missing library classes Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 09/10] MsUnitTestPkg: Add missing DSC file Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 10/10] MsUnitTestPkg: Fix EDK II style issues Kinney, Michael D
2018-01-18 8:10 ` [staging/edk2-test Patch 00/10] MsUnitTestPkg: Add Unit Test Support and sample Sean Brogan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171220000014.9140-4-michael.d.kinney@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox