From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BAC17221523BF for ; Tue, 19 Dec 2017 15:55:35 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2017 16:00:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,429,1508828400"; d="scan'208";a="13197392" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.241.98.58]) by FMSMGA003.fm.intel.com with ESMTP; 19 Dec 2017 16:00:22 -0800 From: "Kinney, Michael D" To: edk2-devel@lists.01.org Cc: Sean Brogan , Liming Gao , Michael D Kinney Date: Tue, 19 Dec 2017 16:00:07 -0800 Message-Id: <20171220000014.9140-4-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.14.2.windows.3 In-Reply-To: <20171220000014.9140-1-michael.d.kinney@intel.com> References: <20171220000014.9140-1-michael.d.kinney@intel.com> Subject: [staging/edk2-test Patch 03/10] MsUnitTestPkg: Update for VS2017 and 32-bit apps X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Dec 2017 23:55:36 -0000 From: Sean Brogan 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 Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- 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