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 10/10] MsUnitTestPkg: Fix EDK II style issues
Date: Tue, 19 Dec 2017 16:00:14 -0800 [thread overview]
Message-ID: <20171220000014.9140-11-michael.d.kinney@intel.com> (raw)
In-Reply-To: <20171220000014.9140-1-michael.d.kinney@intel.com>
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>
---
.../Library/UnitTestAssertLib/UnitTestAssertLib.c | 344 ++++++++----
.../UnitTestBootUsbClassLib/UnitTestBootUsb.c | 167 +++---
.../UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c | 164 +++---
MsUnitTestPkg/Library/UnitTestLib/Md5.c | 139 +++--
MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c | 577 ++++++++++-----------
.../Library/UnitTestLogLib/UnitTestLogLib.c | 187 ++++---
.../UnitTestPersistenceFileSystemLib.c | 360 +++++++------
.../UnitTestPersistenceLibNull.c | 82 +--
.../UnitTestResultReportLib.c | 208 ++++----
.../Sample/SampleUnitTestApp/SampleUnitTestApp.c | 100 ++--
10 files changed, 1199 insertions(+), 1129 deletions(-)
diff --git a/MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c b/MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c
index 5721102818..48d26ae341 100644
--- a/MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c
+++ b/MsUnitTestPkg/Library/UnitTestAssertLib/UnitTestAssertLib.c
@@ -1,27 +1,27 @@
-/**
-Implement UnitTestLib
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** @file
+ Implement UnitTestLib
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#include <PiDxe.h>
@@ -35,17 +35,30 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
BOOLEAN
EFIAPI
UnitTestAssertTrue (
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN BOOLEAN Expression,
- IN CONST CHAR8 *FunctionName,
- IN UINTN LineNumber,
- IN CONST CHAR8 *Description
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN BOOLEAN Expression,
+ IN CONST CHAR8 *FunctionName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
)
{
- if (!Expression)
- {
- UnitTestLogFailure(Framework, FAILURETYPE_ASSERTTRUE, "%a::%d Expression (%a) is not TRUE!\n", FunctionName, LineNumber, Description);
- UnitTestLog(Framework, DEBUG_ERROR, "[ASSERT FAIL] %a::%d Expression (%a) is not TRUE!\n", FunctionName, LineNumber, Description );
+ if (!Expression) {
+ UnitTestLogFailure (
+ Framework,
+ FAILURETYPE_ASSERTTRUE,
+ "%a::%d Expression (%a) is not TRUE!\n",
+ FunctionName,
+ LineNumber,
+ Description
+ );
+ UnitTestLog (
+ Framework,
+ DEBUG_ERROR,
+ "[ASSERT FAIL] %a::%d Expression (%a) is not TRUE!\n",
+ FunctionName,
+ LineNumber,
+ Description
+ );
}
return Expression;
}
@@ -54,17 +67,30 @@ UnitTestAssertTrue (
BOOLEAN
EFIAPI
UnitTestAssertFalse (
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN BOOLEAN Expression,
- IN CONST CHAR8 *FunctionName,
- IN UINTN LineNumber,
- IN CONST CHAR8 *Description
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN BOOLEAN Expression,
+ IN CONST CHAR8 *FunctionName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
)
{
- if (Expression)
- {
- UnitTestLogFailure(Framework, FAILURETYPE_ASSERTFALSE, "%a::%d Expression(%a) is not FALSE!\n", FunctionName, LineNumber, Description );
- UnitTestLog(Framework, DEBUG_ERROR,"[ASSERT FAIL] %a::%d Expression (%a) is not FALSE!\n", FunctionName, LineNumber, Description );
+ if (Expression) {
+ UnitTestLogFailure (
+ Framework,
+ FAILURETYPE_ASSERTFALSE,
+ "%a::%d Expression(%a) is not FALSE!\n",
+ FunctionName,
+ LineNumber,
+ Description
+ );
+ UnitTestLog (
+ Framework,
+ DEBUG_ERROR,
+ "[ASSERT FAIL] %a::%d Expression (%a) is not FALSE!\n",
+ FunctionName,
+ LineNumber,
+ Description
+ );
}
return !Expression;
}
@@ -73,59 +99,110 @@ UnitTestAssertFalse (
BOOLEAN
EFIAPI
UnitTestAssertNotEfiError (
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN EFI_STATUS Status,
- IN CONST CHAR8 *FunctionName,
- IN UINTN LineNumber,
- IN CONST CHAR8 *Description
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN EFI_STATUS Status,
+ IN CONST CHAR8 *FunctionName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
)
{
- if (EFI_ERROR( Status ))
- {
- UnitTestLogFailure(Framework, FAILURETYPE_ASSERTNOTEFIERROR, "%a::%d Status '%a' is EFI_ERROR (%r)!\n", FunctionName, LineNumber, Description, Status);
- UnitTestLog(Framework, DEBUG_ERROR,"[ASSERT FAIL] %a::%d Status '%a' is EFI_ERROR (%r)!\n", FunctionName, LineNumber, Description, Status );
+ if (EFI_ERROR (Status)) {
+ UnitTestLogFailure (
+ Framework,
+ FAILURETYPE_ASSERTNOTEFIERROR,
+ "%a::%d Status '%a' is EFI_ERROR (%r)!\n",
+ FunctionName,
+ LineNumber,
+ Description,
+ Status
+ );
+ UnitTestLog (
+ Framework,
+ DEBUG_ERROR,
+ "[ASSERT FAIL] %a::%d Status '%a' is EFI_ERROR (%r)!\n",
+ FunctionName,
+ LineNumber,
+ Description, Status
+ );
}
- return !EFI_ERROR( Status );
+ return !EFI_ERROR (Status);
}
BOOLEAN
EFIAPI
UnitTestAssertEqual (
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN UINT64 ValueA,
- IN UINT64 ValueB,
- IN CONST CHAR8 *FunctionName,
- IN UINTN LineNumber,
- IN CONST CHAR8 *DescriptionA,
- IN CONST CHAR8 *DescriptionB
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN UINT64 ValueA,
+ IN UINT64 ValueB,
+ IN CONST CHAR8 *FunctionName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *DescriptionA,
+ IN CONST CHAR8 *DescriptionB
)
{
- if ((ValueA != ValueB))
- {
- UnitTestLogFailure(Framework, FAILURETYPE_ASSERTEQUAL, "%a::%d Value %a != %a (%d != %d)!\n", FunctionName, LineNumber, DescriptionA, DescriptionB, ValueA, ValueB);
- UnitTestLog(Framework, DEBUG_ERROR,"[ASSERT FAIL] %a::%d Value %a != %a (%d != %d)!\n", FunctionName, LineNumber, DescriptionA, DescriptionB, ValueA, ValueB );
+ if ((ValueA != ValueB)) {
+ UnitTestLogFailure (
+ Framework,
+ FAILURETYPE_ASSERTEQUAL,
+ "%a::%d Value %a != %a (%d != %d)!\n",
+ FunctionName,
+ LineNumber,
+ DescriptionA,
+ DescriptionB,
+ ValueA,
+ ValueB
+ );
+ UnitTestLog (
+ Framework,
+ DEBUG_ERROR,
+ "[ASSERT FAIL] %a::%d Value %a != %a (%d != %d)!\n",
+ FunctionName,
+ LineNumber,
+ DescriptionA,
+ DescriptionB,
+ ValueA,
+ ValueB
+ );
}
return (ValueA == ValueB);
}
BOOLEAN
EFIAPI
-UnitTestAssertMemEqual(
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN UINTN ValueA,
- IN UINTN ValueB,
- IN UINTN Length,
- IN CONST CHAR8 *FunctionName,
- IN UINTN LineNumber,
- IN CONST CHAR8 *DescriptionA,
- IN CONST CHAR8 *DescriptionB
-)
+UnitTestAssertMemEqual (
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN UINTN ValueA,
+ IN UINTN ValueB,
+ IN UINTN Length,
+ IN CONST CHAR8 *FunctionName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *DescriptionA,
+ IN CONST CHAR8 *DescriptionB
+ )
{
- if (CompareMem((VOID*)ValueA, (VOID*)ValueB, Length) != 0)
- {
- UnitTestLogFailure(Framework, FAILURETYPE_ASSERTEQUAL, __FUNCTION__, "%a::%d Memory at %a != %a for length %d bytes!\n", FunctionName, LineNumber, DescriptionA, DescriptionB, Length);
- UnitTestLog(Framework, DEBUG_ERROR, "[ASSERT FAIL] %a::%d Value %a != %a for length %d bytes!\n", FunctionName, LineNumber, DescriptionA, DescriptionB, Length);
+ if (CompareMem ((VOID *)ValueA, (VOID *)ValueB, Length) != 0) {
+ UnitTestLogFailure (
+ Framework,
+ FAILURETYPE_ASSERTEQUAL,
+ __FUNCTION__,
+ "%a::%d Memory at %a != %a for length %d bytes!\n",
+ FunctionName,
+ LineNumber,
+ DescriptionA,
+ DescriptionB,
+ Length
+ );
+ UnitTestLog (
+ Framework,
+ DEBUG_ERROR,
+ "[ASSERT FAIL] %a::%d Value %a != %a for length %d bytes!\n",
+ FunctionName,
+ LineNumber,
+ DescriptionA,
+ DescriptionB,
+ Length
+ );
return FALSE;
}
return TRUE;
@@ -135,19 +212,38 @@ UnitTestAssertMemEqual(
BOOLEAN
EFIAPI
UnitTestAssertNotEqual (
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN UINT64 ValueA,
- IN UINT64 ValueB,
- IN CONST CHAR8 *FunctionName,
- IN UINTN LineNumber,
- IN CONST CHAR8 *DescriptionA,
- IN CONST CHAR8 *DescriptionB
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN UINT64 ValueA,
+ IN UINT64 ValueB,
+ IN CONST CHAR8 *FunctionName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *DescriptionA,
+ IN CONST CHAR8 *DescriptionB
)
{
- if ((ValueA == ValueB))
- {
- UnitTestLogFailure(Framework, FAILURETYPE_ASSERTNOTEQUAL,"%a::%d Value %a == %a (%d == %d)!\n", FunctionName, LineNumber, DescriptionA, DescriptionB, ValueA, ValueB);
- UnitTestLog(Framework, DEBUG_ERROR,"[ASSERT FAIL] %a::%d Value %a == %a (%d == %d)!\n", FunctionName, LineNumber,DescriptionA, DescriptionB, ValueA, ValueB );
+ if ((ValueA == ValueB)) {
+ UnitTestLogFailure (
+ Framework,
+ FAILURETYPE_ASSERTNOTEQUAL,
+ "%a::%d Value %a == %a (%d == %d)!\n",
+ FunctionName,
+ LineNumber,
+ DescriptionA,
+ DescriptionB,
+ ValueA,
+ ValueB
+ );
+ UnitTestLog (
+ Framework,
+ DEBUG_ERROR,
+ "[ASSERT FAIL] %a::%d Value %a == %a (%d == %d)!\n",
+ FunctionName,
+ LineNumber,
+ DescriptionA,
+ DescriptionB,
+ ValueA,
+ ValueB
+ );
}
return (ValueA != ValueB);
}
@@ -156,36 +252,66 @@ UnitTestAssertNotEqual (
BOOLEAN
EFIAPI
UnitTestAssertStatusEqual (
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN EFI_STATUS Status,
- IN EFI_STATUS Expected,
- IN CONST CHAR8 *FunctionName,
- IN UINTN LineNumber,
- IN CONST CHAR8 *Description
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN EFI_STATUS Status,
+ IN EFI_STATUS Expected,
+ IN CONST CHAR8 *FunctionName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
)
{
- if ((Status != Expected))
- {
- UnitTestLogFailure(Framework, FAILURETYPE_ASSERTSTATUSEQUAL, "%a::%d Status '%a' is %r, should be %r!\n", FunctionName, LineNumber, Description, Status, Expected);
- UnitTestLog(Framework, DEBUG_ERROR,"[ASSERT FAIL] %a::%d Status '%a' is %r, should be %r!\n", FunctionName, LineNumber, Description, Status, Expected );
+ if ((Status != Expected)) {
+ UnitTestLogFailure (
+ Framework,
+ FAILURETYPE_ASSERTSTATUSEQUAL,
+ "%a::%d Status '%a' is %r, should be %r!\n",
+ FunctionName,
+ LineNumber,
+ Description,
+ Status,
+ Expected
+ );
+ UnitTestLog (
+ Framework,
+ DEBUG_ERROR,
+ "[ASSERT FAIL] %a::%d Status '%a' is %r, should be %r!\n",
+ FunctionName,
+ LineNumber,
+ Description,
+ Status,
+ Expected
+ );
}
return (Status == Expected);
}
BOOLEAN
EFIAPI
-UnitTestAssertNotNull(
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN VOID* Pointer,
- IN CONST CHAR8 *FunctionName,
- IN UINTN LineNumber,
- IN CONST CHAR8 *PointerName
-)
+UnitTestAssertNotNull (
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN VOID *Pointer,
+ IN CONST CHAR8 *FunctionName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *PointerName
+ )
{
- if (Pointer == NULL)
- {
- UnitTestLogFailure(Framework, FAILURETYPE_ASSERTNOTNULL, "%a::%d Pointer (%a) is NULL!\n", FunctionName, LineNumber, PointerName);
- UnitTestLog(Framework, DEBUG_ERROR, "[ASSERT FAIL] %a::%d Pointer (%a) is NULL!\n", FunctionName, LineNumber, PointerName);
+ if (Pointer == NULL) {
+ UnitTestLogFailure (
+ Framework,
+ FAILURETYPE_ASSERTNOTNULL,
+ "%a::%d Pointer (%a) is NULL!\n",
+ FunctionName,
+ LineNumber,
+ PointerName
+ );
+ UnitTestLog (
+ Framework,
+ DEBUG_ERROR,
+ "[ASSERT FAIL] %a::%d Pointer (%a) is NULL!\n",
+ FunctionName,
+ LineNumber,
+ PointerName
+ );
}
return (Pointer != NULL);
diff --git a/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c b/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
index 5f6b328b7e..30e4a95cee 100644
--- a/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
+++ b/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
@@ -1,28 +1,28 @@
-/**
-Implement UnitTestBootUsbLib using USB Class Boot option. This should be industry standard and should
-work on all platforms
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** @file
+ Implement UnitTestBootUsbLib using USB Class Boot option. This should be industry standard and should
+ work on all platforms
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
@@ -36,23 +36,30 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EFI_STATUS
EFIAPI
-SetUsbBootNext(
- VOID
-)
+SetUsbBootNext (
+ VOID
+ )
{
- EFI_STATUS Status;
- EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
- UINT32 Attributes;
- UINT8 *OptionalData = NULL;
- UINT32 OptionalDataSize = 0;
- UINT16 BootNextValue = 0xABCD; // this should be a safe number...
- USB_CLASS_DEVICE_PATH UsbDp;
- EFI_DEVICE_PATH_PROTOCOL *DpEnd = NULL;
- EFI_DEVICE_PATH_PROTOCOL *Dp = NULL;
- BOOLEAN NewOptionValid = FALSE;
-
- UsbDp.Header.Length[0] = (UINT8)(sizeof(USB_CLASS_DEVICE_PATH) & 0xff);
- UsbDp.Header.Length[1] = (UINT8)(sizeof(USB_CLASS_DEVICE_PATH) >> 8);
+ EFI_STATUS Status;
+ EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
+ UINT32 Attributes;
+ UINT8 *OptionalData;
+ UINT32 OptionalDataSize;
+ UINT16 BootNextValue;
+ USB_CLASS_DEVICE_PATH UsbDp;
+ EFI_DEVICE_PATH_PROTOCOL *DpEnd;
+ EFI_DEVICE_PATH_PROTOCOL *Dp;
+ BOOLEAN NewOptionValid;
+
+ OptionalData = NULL;
+ OptionalDataSize = 0;
+ BootNextValue = 0xABCD; // this should be a safe number...
+ DpEnd = NULL;
+ Dp = NULL;
+ NewOptionValid = FALSE;
+
+ UsbDp.Header.Length[0] = (UINT8)(sizeof (USB_CLASS_DEVICE_PATH) & 0xff);
+ UsbDp.Header.Length[1] = (UINT8)(sizeof (USB_CLASS_DEVICE_PATH) >> 8);
UsbDp.Header.Type = MESSAGING_DEVICE_PATH;
UsbDp.Header.SubType = MSG_USB_CLASS_DP;
UsbDp.VendorId = 0xFFFF;
@@ -63,69 +70,67 @@ SetUsbBootNext(
Attributes = LOAD_OPTION_ACTIVE;
- DpEnd = AppendDevicePathNode(NULL, NULL);
- if (DpEnd == NULL)
- {
- DEBUG((DEBUG_ERROR, "%a: Unable to create device path. DpEnd is NULL.\n", __FUNCTION__));
+ DpEnd = AppendDevicePathNode (NULL, NULL);
+ if (DpEnd == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: Unable to create device path. DpEnd is NULL.\n", __FUNCTION__));
Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
- Dp = AppendDevicePathNode(DpEnd, (EFI_DEVICE_PATH_PROTOCOL *)&UsbDp); //@MRT --- Is this memory leak becasue we lose the old Dp memory
- if (Dp == NULL)
- {
- DEBUG((DEBUG_ERROR, "%a: Unable to create device path. Dp is NULL.\n", __FUNCTION__));
+ //@MRT --- Is this memory leak becasue we lose the old Dp memory
+ Dp = AppendDevicePathNode (DpEnd, (EFI_DEVICE_PATH_PROTOCOL *)&UsbDp);
+ if (Dp == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: Unable to create device path. Dp is NULL.\n", __FUNCTION__));
Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
- Status = EfiBootManagerInitializeLoadOption(
- &NewOption,
- (UINTN) BootNextValue,
- LoadOptionTypeBoot,
- Attributes,
- L"Generic USB Class Device",
- Dp,
- OptionalData,
- OptionalDataSize
- );
-
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "%a: Error creating load option. Status = %r\n", __FUNCTION__, Status));
+ Status = EfiBootManagerInitializeLoadOption (
+ &NewOption,
+ (UINTN) BootNextValue,
+ LoadOptionTypeBoot,
+ Attributes,
+ L"Generic USB Class Device",
+ Dp,
+ OptionalData,
+ OptionalDataSize
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: Error creating load option. Status = %r\n", __FUNCTION__, Status));
goto CLEANUP;
}
NewOptionValid = TRUE;
- DEBUG((DEBUG_VERBOSE, "%a: Generic USB Class Device boot option created.\n", __FUNCTION__));
- Status = EfiBootManagerLoadOptionToVariable(&NewOption);
- if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, "%a: Error Saving boot option NV variable. Status = %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_VERBOSE, "%a: Generic USB Class Device boot option created.\n", __FUNCTION__));
+ Status = EfiBootManagerLoadOptionToVariable (&NewOption);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: Error Saving boot option NV variable. Status = %r\n", __FUNCTION__, Status));
goto CLEANUP;
}
//Set Boot Next
- Status = gRT->SetVariable(L"BootNext",
- &gEfiGlobalVariableGuid,
- (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE),
- sizeof(BootNextValue),
- &(BootNextValue));
+ Status = gRT->SetVariable (
+ L"BootNext",
+ &gEfiGlobalVariableGuid,
+ (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE),
+ sizeof (BootNextValue),
+ &(BootNextValue)
+ );
- DEBUG((DEBUG_VERBOSE, "%a - Set BootNext Status (%r)\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_VERBOSE, "%a - Set BootNext Status (%r)\n", __FUNCTION__, Status));
CLEANUP:
- if (Dp != NULL)
- {
- FreePool(Dp);
+ if (Dp != NULL) {
+ FreePool (Dp);
}
- if (DpEnd != NULL)
- {
- FreePool(DpEnd);
+ if (DpEnd != NULL) {
+ FreePool (DpEnd);
}
- if (NewOptionValid)
- {
- EfiBootManagerFreeLoadOption(&NewOption);
+ if (NewOptionValid) {
+ EfiBootManagerFreeLoadOption (&NewOption);
}
return Status;
diff --git a/MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c b/MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c
index 059c031bf9..b7b511eecb 100644
--- a/MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c
+++ b/MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c
@@ -1,27 +1,27 @@
-/**
-Implement UnitTestBootUsbLib using internal microsoft uefi boot usb boot option
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** @file
+ Implement UnitTestBootUsbLib using internal microsoft uefi boot usb boot option
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
@@ -35,67 +35,84 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EFI_STATUS
EFIAPI
SetUsbBootNext (
- VOID
+ VOID
)
{
EFI_STATUS Status;
- INT16 BootOptionIndex;
+ INT16 BootOptionIndex;
CHAR16 BootOptionName[30];
- CHAR16 *BootOptionIndexChar = NULL;
- UINT8 *OptionBuffer = NULL;
- UINTN OptionBufferSize = 0, VariableSize = 0;
- BOOLEAN IsUsbOptionFound = FALSE;
+ CHAR16 *BootOptionIndexChar;
+ UINT8 *OptionBuffer;
+ UINTN OptionBufferSize;
+ UINTN VariableSize;
+ BOOLEAN IsUsbOptionFound;
- StrCpyS(BootOptionName, sizeof (BootOptionName) / sizeof (BootOptionName[0]), L"Boot000");
- BootOptionIndexChar = BootOptionName + StrLen(BootOptionName);
+ BootOptionIndexChar = NULL;
+ OptionBuffer = NULL;
+ OptionBufferSize = 0;
+ VariableSize = 0;
+ IsUsbOptionFound = FALSE;
+
+ StrCpyS (BootOptionName, sizeof (BootOptionName) / sizeof (BootOptionName[0]), L"Boot000");
+ BootOptionIndexChar = BootOptionName + StrLen (BootOptionName);
//
// Walk through each of the first 10 boot options looking for the
// generic USB boot option.
- for (BootOptionIndex = 0; BootOptionIndex < 10; BootOptionIndex++)
- {
+ for (BootOptionIndex = 0; BootOptionIndex < 10; BootOptionIndex++) {
// Construct the BootOption name for this boot option.
// Do this by altering the last character of the name.
- UnicodeValueToStringS(BootOptionIndexChar, sizeof (BootOptionName) / sizeof (BootOptionName[0]) - StrLen(BootOptionName), 0, (INT64)BootOptionIndex, 1);
+ UnicodeValueToStringS (
+ BootOptionIndexChar,
+ sizeof (BootOptionName) / sizeof (BootOptionName[0]) - StrLen (BootOptionName),
+ 0,
+ (INT64)BootOptionIndex,
+ 1
+ );
// Attempt to retrieve the option.
- DEBUG(( DEBUG_VERBOSE, "%a - Checking for %s...\n", __FUNCTION__, BootOptionName ));
+ DEBUG ((DEBUG_VERBOSE, "%a - Checking for %s...\n", __FUNCTION__, BootOptionName));
VariableSize = OptionBufferSize;
- Status = gRT->GetVariable( BootOptionName,
- &gEfiGlobalVariableGuid,
- NULL,
- &VariableSize,
- OptionBuffer );
+ Status = gRT->GetVariable (
+ BootOptionName,
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &VariableSize,
+ OptionBuffer
+ );
// If we need a larger buffer, let's do that now.
- if (Status == EFI_BUFFER_TOO_SMALL)
- {
+ if (Status == EFI_BUFFER_TOO_SMALL) {
// Free the existing buffer.
- if (OptionBuffer != NULL)
- {
- FreePool( OptionBuffer );
+ if (OptionBuffer != NULL) {
+ FreePool (OptionBuffer);
}
// Allocate a larger buffer.
- OptionBuffer = AllocatePool( VariableSize );
+ OptionBuffer = AllocatePool (VariableSize);
// If you fail to... we've gotta get out of here.
- if (OptionBuffer == NULL)
- {
- DEBUG(( DEBUG_ERROR, "%a - Failed to allocate memory for Boot option variable %s...\n", __FUNCTION__, BootOptionName ));
+ if (OptionBuffer == NULL) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a - Failed to allocate memory for Boot option variable %s...\n",
+ __FUNCTION__,
+ BootOptionName
+ ));
return EFI_OUT_OF_RESOURCES;
}
OptionBufferSize = VariableSize;
// Now that we've got a larger buffer, try that again.
- Status = gRT->GetVariable( BootOptionName,
- &gEfiGlobalVariableGuid,
- NULL,
- &VariableSize,
- OptionBuffer );
+ Status = gRT->GetVariable (
+ BootOptionName,
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &VariableSize,
+ OptionBuffer
+ );
}
// If we failed to retrieve this option... move on with your life.
- if (EFI_ERROR( Status ))
- {
- DEBUG(( DEBUG_VERBOSE, "%a - Failed to locate option (%r). Moving on.\n", __FUNCTION__, Status ));
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_VERBOSE, "%a - Failed to locate option (%r). Moving on.\n", __FUNCTION__, Status));
continue;
}
@@ -104,8 +121,7 @@ SetUsbBootNext (
// optional data) and see whether it's "USB".
if (VariableSize > 4 &&
OptionBuffer[VariableSize - 4] == 'U' && OptionBuffer[VariableSize - 3] == 'S' &&
- OptionBuffer[VariableSize - 2] == 'B' && OptionBuffer[VariableSize - 1] == 0x00 )
- {
+ OptionBuffer[VariableSize - 2] == 'B' && OptionBuffer[VariableSize - 1] == 0x00) {
IsUsbOptionFound = TRUE;
break;
}
@@ -114,25 +130,23 @@ SetUsbBootNext (
//
// If the correct boot option was found,
// set it to the BootNext variable.
- if (IsUsbOptionFound)
- {
- Status = gRT->SetVariable( L"BootNext",
- &gEfiGlobalVariableGuid,
- (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE),
- sizeof( BootOptionIndex ),
- &BootOptionIndex );
- DEBUG(( DEBUG_VERBOSE, "%a - Set BootNext Status (%r)\n", __FUNCTION__, Status ));
- }
- else
- {
- DEBUG(( DEBUG_WARN, "%a - Could not find generic USB boot option.\n", __FUNCTION__));
+ if (IsUsbOptionFound) {
+ Status = gRT->SetVariable (
+ L"BootNext",
+ &gEfiGlobalVariableGuid,
+ (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE),
+ sizeof (BootOptionIndex),
+ &BootOptionIndex
+ );
+ DEBUG ((DEBUG_VERBOSE, "%a - Set BootNext Status (%r)\n", __FUNCTION__, Status));
+ } else {
+ DEBUG ((DEBUG_WARN, "%a - Could not find generic USB boot option.\n", __FUNCTION__));
Status = EFI_NOT_FOUND;
}
// Always put away your toys.
- if (OptionBuffer != NULL)
- {
- FreePool( OptionBuffer );
+ if (OptionBuffer != NULL) {
+ FreePool (OptionBuffer);
}
return Status;
diff --git a/MsUnitTestPkg/Library/UnitTestLib/Md5.c b/MsUnitTestPkg/Library/UnitTestLib/Md5.c
index 495b41730a..6bf3a53d4e 100644
--- a/MsUnitTestPkg/Library/UnitTestLib/Md5.c
+++ b/MsUnitTestPkg/Library/UnitTestLib/Md5.c
@@ -1,14 +1,14 @@
/** @file
Implementation of MD5 algorithm.
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
-This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
+ Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
@@ -27,7 +27,7 @@ CONST UINT32 Md5_Data[][2] = {
CONST UINT32 Md5_S[][4] = {
{ 7, 22, 17, 12 },
{ 5, 20, 14, 9 },
- { 4, 23, 16 ,11 },
+ { 4, 23, 16, 11 },
{ 6, 21, 15, 10 },
};
@@ -50,8 +50,7 @@ CONST UINT32 Md5_T[] = {
0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391
};
-CONST UINT8 Md5HashPadding[] =
-{
+CONST UINT8 Md5HashPadding[] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -73,7 +72,7 @@ CONST UINT8 Md5HashPadding[] =
//
// ROTATE_LEFT rotates x left n bits.
//
-#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+#define ROTATE_LEFT(x, n)(((x) << (n)) | ((x) >> (32 - (n))))
#define SA MedStates[Index2 & 3]
#define SB MedStates[(Index2 + 1) & 3]
@@ -83,18 +82,18 @@ CONST UINT8 Md5HashPadding[] =
/**
Tf1 is one basic MD5 transform function.
- @param[in] A A 32-bit quantity.
- @param[in] B A 32-bit quantity.
- @param[in] C A 32-bit quantity.
+ @param[in] A A 32-bit quantity.
+ @param[in] B A 32-bit quantity.
+ @param[in] C A 32-bit quantity.
- @return Output was produced as a 32-bit quantity based on the
- three 32-bit input quantity.
+ @return Output was produced as a 32-bit quantity based on the
+ three 32-bit input quantity.
**/
UINT32
Tf1 (
- IN UINT32 A,
- IN UINT32 B,
- IN UINT32 C
+ IN UINT32 A,
+ IN UINT32 B,
+ IN UINT32 C
)
{
return (A & B) | (~A & C);
@@ -103,18 +102,18 @@ Tf1 (
/**
Tf2 is one basic MD5 transform function.
- @param[in] A A 32-bit quantity.
- @param[in] B A 32-bit quantity.
- @param[in] C A 32-bit quantity.
+ @param[in] A A 32-bit quantity.
+ @param[in] B A 32-bit quantity.
+ @param[in] C A 32-bit quantity.
- @return Output was produced as a 32-bit quantity based on the
- three 32-bit input quantity.
+ @return Output was produced as a 32-bit quantity based on the
+ three 32-bit input quantity.
**/
UINT32
Tf2 (
- IN UINT32 A,
- IN UINT32 B,
- IN UINT32 C
+ IN UINT32 A,
+ IN UINT32 B,
+ IN UINT32 C
)
{
return (A & C) | (B & ~C);
@@ -123,18 +122,18 @@ Tf2 (
/**
Tf3 is one basic MD5 transform function.
- @param[in] A A 32-bit quantity.
- @param[in] B A 32-bit quantity.
- @param[in] C A 32-bit quantity.
+ @param[in] A A 32-bit quantity.
+ @param[in] B A 32-bit quantity.
+ @param[in] C A 32-bit quantity.
- @return Output was produced as a 32-bit quantity based on the
- three 32-bit input quantity.
+ @return Output was produced as a 32-bit quantity based on the
+ three 32-bit input quantity.
**/
UINT32
Tf3 (
- IN UINT32 A,
- IN UINT32 B,
- IN UINT32 C
+ IN UINT32 A,
+ IN UINT32 B,
+ IN UINT32 C
)
{
return A ^ B ^ C;
@@ -143,18 +142,18 @@ Tf3 (
/**
Tf4 is one basic MD5 transform function.
- @param[in] A A 32-bit quantity.
- @param[in] B A 32-bit quantity.
- @param[in] C A 32-bit quantity.
+ @param[in] A A 32-bit quantity.
+ @param[in] B A 32-bit quantity.
+ @param[in] C A 32-bit quantity.
- @return Output was produced as a 32-bit quantity based on the
- three 32-bit input quantity.
+ @return Output was produced as a 32-bit quantity based on the
+ three 32-bit input quantity.
**/
UINT32
Tf4 (
- IN UINT32 A,
- IN UINT32 B,
- IN UINT32 C
+ IN UINT32 A,
+ IN UINT32 B,
+ IN UINT32 C
)
{
return B ^ (A | ~C);
@@ -162,7 +161,7 @@ Tf4 (
typedef
UINT32
-(*MD5_TRANSFORM_FUNC) (
+(*MD5_TRANSFORM_FUNC)(
IN UINT32 A,
IN UINT32 B,
IN UINT32 C
@@ -203,7 +202,7 @@ MD5Transform (
for (Index1 = 0; Index1 < 4; Index1++) {
IndexD = Md5_Data[Index1][0];
for (Index2 = 16; Index2 > 0; Index2--) {
- SA += (*Md5_F[Index1]) (SB, SC, SD) + Data[IndexD] + Md5_T[IndexT];
+ SA += (*Md5_F[Index1])(SB, SC, SD) + Data[IndexD] + Md5_T[IndexT];
SA = ROTATE_LEFT (SA, Md5_S[Index1][Index2 & 3]);
SA += SB;
@@ -227,19 +226,19 @@ MD5Transform (
All of Md5 code generated for the sequential 64-bytes data segaments are be
accumulated in MD5Final() function.
- @param[in, out] Md5Ctx The data structure of storing the original data
- segment and the final result.
- @param[in] Data The data wanted to be transformed.
- @param[in] DataLen The length of data.
+ @param[in, out] Md5Ctx The data structure of storing the original data
+ segment and the final result.
+ @param[in] Data The data wanted to be transformed.
+ @param[in] DataLen The length of data.
**/
VOID
MD5UpdateBlock (
- IN OUT MD5_CTX *Md5Ctx,
- IN CONST UINT8 *Data,
- IN UINTN DataLen
+ IN OUT MD5_CTX *Md5Ctx,
+ IN CONST UINT8 *Data,
+ IN UINTN DataLen
)
{
- UINTN Limit;
+ UINTN Limit;
for (Limit = 64 - Md5Ctx->Count; DataLen >= 64 - Md5Ctx->Count; Limit = 64) {
CopyMem (Md5Ctx->M + Md5Ctx->Count, (VOID *)Data, Limit);
@@ -257,9 +256,9 @@ MD5UpdateBlock (
/**
Initialize four 32-bits chaining variables and use them to do the Md5 transform.
- @param[out] Md5Ctx The data structure of Md5.
+ @param[out] Md5Ctx The data structure of Md5.
- @retval EFI_SUCCESS Initialization is ok.
+ @retval EFI_SUCCESS Initialization is ok.
**/
EFI_STATUS
MD5Init (
@@ -282,19 +281,19 @@ MD5Init (
/**
the external interface of Md5 algorithm
- @param[in, out] Md5Ctx The data structure of storing the original data
- segment and the final result.
- @param[in] Data The data wanted to be transformed.
- @param[in] DataLen The length of data.
+ @param[in, out] Md5Ctx The data structure of storing the original data
+ segment and the final result.
+ @param[in] Data The data wanted to be transformed.
+ @param[in] DataLen The length of data.
- @retval EFI_SUCCESS The transform is ok.
- @retval Others Other errors as indicated.
+ @retval EFI_SUCCESS The transform is ok.
+ @retval Others Other errors as indicated.
**/
EFI_STATUS
MD5Update (
- IN OUT MD5_CTX *Md5Ctx,
- IN VOID *Data,
- IN UINTN DataLen
+ IN OUT MD5_CTX *Md5Ctx,
+ IN VOID *Data,
+ IN UINTN DataLen
)
{
if (EFI_ERROR (Md5Ctx->Status)) {
@@ -310,20 +309,20 @@ MD5Update (
Accumulate the MD5 value of every data segment and generate the finial
result according to MD5 algorithm.
- @param[in, out] Md5Ctx The data structure of storing the original data
+ @param[in, out] Md5Ctx The data structure of storing the original data
segment and the final result.
@param[out] HashVal The final 128-bits output.
- @retval EFI_SUCCESS The transform is ok.
- @retval Others Other errors as indicated.
+ @retval EFI_SUCCESS The transform is ok.
+ @retval Others Other errors as indicated.
**/
EFI_STATUS
MD5Final (
- IN OUT MD5_CTX *Md5Ctx,
- OUT UINT8 *HashVal
+ IN OUT MD5_CTX *Md5Ctx,
+ OUT UINT8 *HashVal
)
{
- UINTN PadLength;
+ UINTN PadLength;
if (Md5Ctx->Status == EFI_ALREADY_STARTED) {
//
diff --git a/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c b/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
index c181eae5e4..2d5f00898b 100644
--- a/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
@@ -1,26 +1,26 @@
-/**
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** @file
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
@@ -69,14 +69,14 @@ UpdateTestFromSave (
@param[in] ShortTitleString A pointer to the short title string to be evaluated.
- @retval TRUE The string is acceptable.
- @retval FALSE The string should not be used.
+ @retval TRUE The string is acceptable.
+ @retval FALSE The string should not be used.
**/
STATIC
BOOLEAN
IsFrameworkShortNameValid (
- IN CHAR16 *ShortTitleString
+ IN CHAR16 *ShortTitleString
)
{
// TODO: Finish this function.
@@ -85,19 +85,18 @@ IsFrameworkShortNameValid (
STATIC
-CHAR16*
+CHAR16 *
AllocateAndCopyString (
- IN CHAR16 *StringToCopy
+ IN CHAR16 *StringToCopy
)
{
CHAR16 *NewString = NULL;
UINTN NewStringLength;
- NewStringLength = StrnLenS( StringToCopy, UNIT_TEST_MAX_STRING_LENGTH ) + 1;
- NewString = AllocatePool( NewStringLength * sizeof( CHAR16 ) );
- if (NewString != NULL)
- {
- StrCpyS( NewString, NewStringLength, StringToCopy );
+ NewStringLength = StrnLenS (StringToCopy, UNIT_TEST_MAX_STRING_LENGTH) + 1;
+ NewString = AllocatePool (NewStringLength * sizeof (CHAR16));
+ if (NewString != NULL) {
+ StrCpyS (NewString, NewStringLength, StringToCopy);
}
return NewString;
@@ -107,17 +106,17 @@ AllocateAndCopyString (
STATIC
VOID
SetFrameworkFingerprint (
- OUT UINT8 *Fingerprint,
- IN UNIT_TEST_FRAMEWORK *Framework
+ OUT UINT8 *Fingerprint,
+ IN UNIT_TEST_FRAMEWORK *Framework
)
{
- MD5Init( &mFingerprintCtx );
+ MD5Init (&mFingerprintCtx);
// For this one we'll just use the title and version as the unique fingerprint.
- MD5Update( &mFingerprintCtx, Framework->Title, (StrLen( Framework->Title ) * sizeof( CHAR16 )) );
- MD5Update( &mFingerprintCtx, Framework->VersionString, (StrLen( Framework->VersionString ) * sizeof( CHAR16 )) );
+ MD5Update (&mFingerprintCtx, Framework->Title, (StrLen (Framework->Title) * sizeof (CHAR16)));
+ MD5Update (&mFingerprintCtx, Framework->VersionString, (StrLen (Framework->VersionString) * sizeof (CHAR16)));
- MD5Final( &mFingerprintCtx, &Framework->Fingerprint[0] );
+ MD5Final (&mFingerprintCtx, &Framework->Fingerprint[0]);
return;
} // SetFrameworkFingerprint()
@@ -125,19 +124,19 @@ SetFrameworkFingerprint (
STATIC
VOID
SetSuiteFingerprint (
- OUT UINT8 *Fingerprint,
- IN UNIT_TEST_FRAMEWORK *Framework,
- IN UNIT_TEST_SUITE *Suite
+ OUT UINT8 *Fingerprint,
+ IN UNIT_TEST_FRAMEWORK *Framework,
+ IN UNIT_TEST_SUITE *Suite
)
{
- MD5Init( &mFingerprintCtx );
+ MD5Init (&mFingerprintCtx);
// For this one, we'll use the fingerprint from the framework, and the title of the suite.
- MD5Update( &mFingerprintCtx, &Framework->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE );
- MD5Update( &mFingerprintCtx, Suite->Title, (StrLen( Suite->Title ) * sizeof( CHAR16 )) );
- MD5Update(&mFingerprintCtx, Suite->Package, (StrLen(Suite->Package) * sizeof(CHAR16)));
+ MD5Update (&mFingerprintCtx, &Framework->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE);
+ MD5Update (&mFingerprintCtx, Suite->Title, (StrLen (Suite->Title) * sizeof (CHAR16)));
+ MD5Update (&mFingerprintCtx, Suite->Package, (StrLen (Suite->Package) * sizeof (CHAR16)));
- MD5Final( &mFingerprintCtx, &Suite->Fingerprint[0] );
+ MD5Final (&mFingerprintCtx, &Suite->Fingerprint[0]);
return;
} // SetSuiteFingerprint()
@@ -145,19 +144,19 @@ SetSuiteFingerprint (
STATIC
VOID
SetTestFingerprint (
- OUT UINT8 *Fingerprint,
- IN UNIT_TEST_SUITE *Suite,
- IN UNIT_TEST *Test
+ OUT UINT8 *Fingerprint,
+ IN UNIT_TEST_SUITE *Suite,
+ IN UNIT_TEST *Test
)
{
- MD5Init( &mFingerprintCtx );
+ MD5Init (&mFingerprintCtx);
// For this one, we'll use the fingerprint from the suite, and the description and classname of the test.
- MD5Update( &mFingerprintCtx, &Suite->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE );
- MD5Update( &mFingerprintCtx, Test->Description, (StrLen( Test->Description ) * sizeof( CHAR16 )) );
- MD5Update(&mFingerprintCtx, Test->ClassName, (StrLen(Test->ClassName) * sizeof(CHAR16)));
+ MD5Update (&mFingerprintCtx, &Suite->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE);
+ MD5Update (&mFingerprintCtx, Test->Description, (StrLen (Test->Description) * sizeof (CHAR16)));
+ MD5Update (&mFingerprintCtx, Test->ClassName, (StrLen (Test->ClassName) * sizeof (CHAR16)));
- MD5Final( &mFingerprintCtx, &Test->Fingerprint[0] );
+ MD5Final (&mFingerprintCtx, &Test->Fingerprint[0]);
return;
} // SetTestFingerprint()
@@ -165,11 +164,11 @@ SetTestFingerprint (
STATIC
BOOLEAN
CompareFingerprints (
- IN UINT8 *FingerprintA,
- IN UINT8 *FingerprintB
+ IN UINT8 *FingerprintA,
+ IN UINT8 *FingerprintB
)
{
- return (CompareMem( FingerprintA, FingerprintB, UNIT_TEST_FINGERPRINT_SIZE ) == 0);
+ return (CompareMem (FingerprintA, FingerprintB, UNIT_TEST_FINGERPRINT_SIZE) == 0);
} // SetTestFingerprint()
@@ -187,7 +186,7 @@ FreeUnitTestFramework (
STATIC
EFI_STATUS
FreeUnitTestSuiteEntry (
- IN UNIT_TEST_SUITE_LIST_ENTRY *SuiteEntry
+ IN UNIT_TEST_SUITE_LIST_ENTRY *SuiteEntry
)
{
// TODO: Finish this function.
@@ -198,7 +197,7 @@ FreeUnitTestSuiteEntry (
STATIC
EFI_STATUS
FreeUnitTestTestEntry (
- IN UNIT_TEST_LIST_ENTRY *TestEntry
+ IN UNIT_TEST_LIST_ENTRY *TestEntry
)
{
// TODO: Finish this function.
@@ -214,18 +213,18 @@ FreeUnitTestTestEntry (
/*
-Method to Initialize the Unit Test framework
+ Method to Initialize the Unit Test framework
-@retval Success - Unit Test init.
-@retval EFI_ERROR - Unit Tests init failed.
+ @retval Success - Unit Test init.
+ @retval EFI_ERROR - Unit Tests init failed.
*/
EFI_STATUS
EFIAPI
InitUnitTestFramework (
- OUT UNIT_TEST_FRAMEWORK **Framework,
- IN CHAR16 *Title,
- IN CHAR16 *ShortTitle,
- IN CHAR16 *VersionString
+ OUT UNIT_TEST_FRAMEWORK **Framework,
+ IN CHAR16 *Title,
+ IN CHAR16 *ShortTitle,
+ IN CHAR16 *VersionString
)
{
EFI_STATUS Status = EFI_SUCCESS;
@@ -234,55 +233,49 @@ InitUnitTestFramework (
//
// First, check all pointers and make sure nothing's broked.
if (Framework == NULL || Title == NULL ||
- ShortTitle == NULL || VersionString == NULL)
- {
+ ShortTitle == NULL || VersionString == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Next, determine whether all of the strings are good to use.
- if (!IsFrameworkShortNameValid( ShortTitle ))
- {
+ if (!IsFrameworkShortNameValid (ShortTitle)) {
return EFI_INVALID_PARAMETER;
}
//
// Next, set aside some space to start messing with the framework.
- NewFramework = AllocateZeroPool( sizeof( UNIT_TEST_FRAMEWORK ) );
- if (NewFramework == NULL)
- {
+ NewFramework = AllocateZeroPool (sizeof (UNIT_TEST_FRAMEWORK));
+ if (NewFramework == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Next, set up all the test data.
- NewFramework->Title = AllocateAndCopyString( Title );
- NewFramework->ShortTitle = AllocateAndCopyString( ShortTitle );
- NewFramework->VersionString = AllocateAndCopyString( VersionString );
+ NewFramework->Title = AllocateAndCopyString (Title);
+ NewFramework->ShortTitle = AllocateAndCopyString (ShortTitle);
+ NewFramework->VersionString = AllocateAndCopyString (VersionString);
NewFramework->Log = NULL;
NewFramework->CurrentTest = NULL;
NewFramework->SavedState = NULL;
if (NewFramework->Title == NULL || NewFramework->ShortTitle == NULL ||
- NewFramework->VersionString == NULL)
- {
+ NewFramework->VersionString == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
- InitializeListHead( &(NewFramework->TestSuiteList) );
+ InitializeListHead (&(NewFramework->TestSuiteList));
//
// Create the framework fingerprint.
- SetFrameworkFingerprint( &NewFramework->Fingerprint[0], NewFramework );
+ SetFrameworkFingerprint (&NewFramework->Fingerprint[0], NewFramework);
//
// If there is a persisted context, load it now.
- if (DoesCacheExist( NewFramework ))
- {
- Status = LoadUnitTestCache( NewFramework, (UNIT_TEST_SAVE_HEADER **)(&(NewFramework->SavedState)));
- if (EFI_ERROR( Status ))
- {
+ if (DoesCacheExist (NewFramework)) {
+ Status = LoadUnitTestCache (NewFramework, (UNIT_TEST_SAVE_HEADER **)(& (NewFramework->SavedState)));
+ if (EFI_ERROR (Status)) {
// Don't actually report it as an error, but emit a warning.
- DEBUG(( DEBUG_ERROR, "%a - Cache was detected, but failed to load.\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a - Cache was detected, but failed to load.\n", __FUNCTION__));
Status = EFI_SUCCESS;
}
}
@@ -290,14 +283,12 @@ InitUnitTestFramework (
Exit:
//
// If we're good, then let's copy the framework.
- if (!EFI_ERROR( Status ))
- {
+ if (!EFI_ERROR (Status)) {
*Framework = NewFramework;
}
// Otherwise, we need to undo this horrible thing that we've done.
- else
- {
- FreeUnitTestFramework( NewFramework );
+ else {
+ FreeUnitTestFramework (NewFramework);
}
return Status;
@@ -308,11 +299,11 @@ EFI_STATUS
EFIAPI
CreateUnitTestSuite (
OUT UNIT_TEST_SUITE **Suite,
- IN UNIT_TEST_FRAMEWORK *Framework,
- IN CHAR16 *Title,
- IN CHAR16 *Package,
- IN UNIT_TEST_SUITE_SETUP Sup OPTIONAL,
- IN UNIT_TEST_SUITE_TEARDOWN Tdn OPTIONAL
+ IN UNIT_TEST_FRAMEWORK *Framework,
+ IN CHAR16 *Title,
+ IN CHAR16 *Package,
+ IN UNIT_TEST_SUITE_SETUP Sup, OPTIONAL
+ IN UNIT_TEST_SUITE_TEARDOWN Tdn OPTIONAL
)
{
EFI_STATUS Status = EFI_SUCCESS;
@@ -320,56 +311,50 @@ CreateUnitTestSuite (
//
// First, let's check to make sure that our parameters look good.
- if ((Framework == NULL) || (Title == NULL) || (Package == NULL))
- {
+ if ((Framework == NULL) || (Title == NULL) || (Package == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// Create the new entry.
- NewSuiteEntry = AllocateZeroPool( sizeof( UNIT_TEST_SUITE_LIST_ENTRY ) );
- if (NewSuiteEntry == NULL)
- {
+ NewSuiteEntry = AllocateZeroPool (sizeof (UNIT_TEST_SUITE_LIST_ENTRY));
+ if (NewSuiteEntry == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Copy the fields we think we need.
- NewSuiteEntry->UTS.Title = AllocateAndCopyString( Title );
- NewSuiteEntry->UTS.Package = AllocateAndCopyString(Package);
+ NewSuiteEntry->UTS.Title = AllocateAndCopyString (Title);
+ NewSuiteEntry->UTS.Package = AllocateAndCopyString (Package);
NewSuiteEntry->UTS.Setup = Sup;
NewSuiteEntry->UTS.Teardown = Tdn;
NewSuiteEntry->UTS.ParentFramework = Framework;
- InitializeListHead( &(NewSuiteEntry->Entry) ); // List entry for sibling suites.
- InitializeListHead( &(NewSuiteEntry->UTS.TestCaseList) ); // List entry for child tests.
- if (NewSuiteEntry->UTS.Title == NULL)
- {
+ InitializeListHead (&(NewSuiteEntry->Entry)); // List entry for sibling suites.
+ InitializeListHead (&(NewSuiteEntry->UTS.TestCaseList)); // List entry for child tests.
+ if (NewSuiteEntry->UTS.Title == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
- if (NewSuiteEntry->UTS.Package == NULL)
- {
+ if (NewSuiteEntry->UTS.Package == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
//
// Create the suite fingerprint.
- SetSuiteFingerprint( &NewSuiteEntry->UTS.Fingerprint[0], Framework, &NewSuiteEntry->UTS );
+ SetSuiteFingerprint (&NewSuiteEntry->UTS.Fingerprint[0], Framework, &NewSuiteEntry->UTS);
Exit:
//
// If everything is going well, add the new suite to the tail list for the framework.
- if (!EFI_ERROR( Status ))
- {
- InsertTailList( &(Framework->TestSuiteList), (LIST_ENTRY*)NewSuiteEntry );
+ if (!EFI_ERROR (Status)) {
+ InsertTailList (&(Framework->TestSuiteList), (LIST_ENTRY *)NewSuiteEntry);
*Suite = &NewSuiteEntry->UTS;
}
// Otherwise, make with the destruction.
- else
- {
- FreeUnitTestSuiteEntry( NewSuiteEntry );
+ else {
+ FreeUnitTestSuiteEntry (NewSuiteEntry);
}
return Status;
@@ -379,38 +364,36 @@ Exit:
EFI_STATUS
EFIAPI
AddTestCase (
- IN UNIT_TEST_SUITE *Suite,
- IN CHAR16 *Description,
- IN CHAR16 *ClassName,
- IN UNIT_TEST_FUNCTION Func,
- IN UNIT_TEST_PREREQ PreReq OPTIONAL,
- IN UNIT_TEST_CLEANUP CleanUp OPTIONAL,
- IN UNIT_TEST_CONTEXT Context OPTIONAL
+ IN UNIT_TEST_SUITE *Suite,
+ IN CHAR16 *Description,
+ IN CHAR16 *ClassName,
+ IN UNIT_TEST_FUNCTION Func,
+ IN UNIT_TEST_PREREQ PreReq, OPTIONAL
+ IN UNIT_TEST_CLEANUP CleanUp, OPTIONAL
+ IN UNIT_TEST_CONTEXT Context OPTIONAL
)
{
EFI_STATUS Status = EFI_SUCCESS;
UNIT_TEST_LIST_ENTRY *NewTestEntry;
- UNIT_TEST_FRAMEWORK *ParentFramework = (UNIT_TEST_FRAMEWORK*)Suite->ParentFramework;
+ UNIT_TEST_FRAMEWORK *ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
//
// First, let's check to make sure that our parameters look good.
- if ((Suite == NULL) || (Description == NULL) || (ClassName == NULL))
- {
+ if ((Suite == NULL) || (Description == NULL) || (ClassName == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// Create the new entry.
- NewTestEntry = AllocateZeroPool( sizeof( UNIT_TEST_LIST_ENTRY ) );
- if (NewTestEntry == NULL)
- {
+ NewTestEntry = AllocateZeroPool (sizeof (UNIT_TEST_LIST_ENTRY));
+ if (NewTestEntry == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Copy the fields we think we need.
- NewTestEntry->UT.Description = AllocateAndCopyString( Description );
- NewTestEntry->UT.ClassName = AllocateAndCopyString(ClassName);
+ NewTestEntry->UT.Description = AllocateAndCopyString (Description);
+ NewTestEntry->UT.ClassName = AllocateAndCopyString (ClassName);
NewTestEntry->UT.FailureType = FAILURETYPE_NOFAILURE;
NewTestEntry->UT.FailureMessage[0] = '\0';
NewTestEntry->UT.Log = NULL;
@@ -420,37 +403,33 @@ AddTestCase (
NewTestEntry->UT.Context = Context;
NewTestEntry->UT.Result = UNIT_TEST_PENDING;
NewTestEntry->UT.ParentSuite = Suite;
- InitializeListHead( &(NewTestEntry->Entry) ); // List entry for sibling tests.
- if (NewTestEntry->UT.Description == NULL)
- {
+ InitializeListHead (&(NewTestEntry->Entry)); // List entry for sibling tests.
+ if (NewTestEntry->UT.Description == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
//
// Create the test fingerprint.
- SetTestFingerprint( &NewTestEntry->UT.Fingerprint[0], Suite, &NewTestEntry->UT );
+ SetTestFingerprint (&NewTestEntry->UT.Fingerprint[0], Suite, &NewTestEntry->UT);
// TODO: Make sure that duplicate fingerprints cannot be created.
//
// If there is saved test data, update this record.
- if (ParentFramework->SavedState != NULL)
- {
- UpdateTestFromSave( &NewTestEntry->UT, ParentFramework->SavedState );
+ if (ParentFramework->SavedState != NULL) {
+ UpdateTestFromSave (&NewTestEntry->UT, ParentFramework->SavedState);
}
Exit:
//
// If everything is going well, add the new suite to the tail list for the framework.
- if (!EFI_ERROR( Status ))
- {
- InsertTailList( &(Suite->TestCaseList), (LIST_ENTRY*)NewTestEntry );
+ if (!EFI_ERROR (Status)) {
+ InsertTailList (&(Suite->TestCaseList), (LIST_ENTRY *)NewTestEntry);
}
// Otherwise, make with the destruction.
- else
- {
- FreeUnitTestTestEntry( NewTestEntry );
+ else {
+ FreeUnitTestTestEntry (NewTestEntry);
}
return Status;
@@ -466,59 +445,53 @@ Exit:
STATIC
EFI_STATUS
RunTestSuite (
- IN UNIT_TEST_SUITE *Suite
+ IN UNIT_TEST_SUITE *Suite
)
{
UNIT_TEST_LIST_ENTRY *TestEntry = NULL;
UNIT_TEST *Test;
- UNIT_TEST_FRAMEWORK *ParentFramework = (UNIT_TEST_FRAMEWORK*)Suite->ParentFramework;
+ UNIT_TEST_FRAMEWORK *ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
- if (Suite == NULL)
- {
+ if (Suite == NULL) {
return EFI_INVALID_PARAMETER;
}
- DEBUG((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
- DEBUG((DEBUG_VERBOSE, "RUNNING TEST SUITE: %s\n", Suite->Title));
- DEBUG((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
+ DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
+ DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %s\n", Suite->Title));
+ DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
- if (Suite->Setup != NULL)
- {
- Suite->Setup( Suite->ParentFramework );
+ if (Suite->Setup != NULL) {
+ Suite->Setup (Suite->ParentFramework);
}
//
// Iterate all tests within the suite
//
- for (TestEntry = (UNIT_TEST_LIST_ENTRY*)GetFirstNode( &(Suite->TestCaseList) ); // Start at the beginning.
- (LIST_ENTRY*)TestEntry != &(Suite->TestCaseList); // Go until you loop back to the head.
- TestEntry = (UNIT_TEST_LIST_ENTRY*)GetNextNode( &(Suite->TestCaseList), (LIST_ENTRY*)TestEntry) ) // Always get the next test.
- {
+ for (TestEntry = (UNIT_TEST_LIST_ENTRY *)GetFirstNode (&(Suite->TestCaseList)); // Start at the beginning.
+ (LIST_ENTRY *)TestEntry != &(Suite->TestCaseList); // Go until you loop back to the head.
+ TestEntry = (UNIT_TEST_LIST_ENTRY *)GetNextNode (&(Suite->TestCaseList), (LIST_ENTRY *)TestEntry)) { // Always get the next test.
Test = &TestEntry->UT;
ParentFramework->CurrentTest = Test;
- DEBUG((DEBUG_VERBOSE, "*********************************************************\n"));
- DEBUG((DEBUG_VERBOSE, " RUNNING TEST: %s:\n", Test->Description));
- DEBUG((DEBUG_VERBOSE, "**********************************************************\n"));
+ DEBUG ((DEBUG_VERBOSE, "*********************************************************\n"));
+ DEBUG ((DEBUG_VERBOSE, " RUNNING TEST: %s:\n", Test->Description));
+ DEBUG ((DEBUG_VERBOSE, "**********************************************************\n"));
//
// First, check to see whether the test has already been run.
// NOTE: This would generally only be the case if a saved state was detected and loaded.
- if (Test->Result != UNIT_TEST_PENDING && Test->Result != UNIT_TEST_RUNNING)
- {
- DEBUG(( DEBUG_VERBOSE, "Test was run on a previous pass. Skipping.\n" ));
+ if (Test->Result != UNIT_TEST_PENDING && Test->Result != UNIT_TEST_RUNNING) {
+ DEBUG ((DEBUG_VERBOSE, "Test was run on a previous pass. Skipping.\n"));
ParentFramework->CurrentTest = NULL;
continue;
}
//
// Next, if we're still running, make sure that our test prerequisites are in place.
- if (Test->Result == UNIT_TEST_PENDING && Test->PreReq != NULL)
- {
- DEBUG(( DEBUG_VERBOSE, "PREREQ\n" ));
- if (Test->PreReq( Suite->ParentFramework, Test->Context ) != UNIT_TEST_PASSED)
- {
- DEBUG(( DEBUG_ERROR, "PreReq Not Met\n" ));
+ if (Test->Result == UNIT_TEST_PENDING && Test->PreReq != NULL) {
+ DEBUG ((DEBUG_VERBOSE, "PREREQ\n"));
+ if (Test->PreReq (Suite->ParentFramework, Test->Context) != UNIT_TEST_PASSED) {
+ DEBUG ((DEBUG_ERROR, "PreReq Not Met\n"));
Test->Result = UNIT_TEST_ERROR_PREREQ_NOT_MET;
ParentFramework->CurrentTest = NULL;
continue;
@@ -531,14 +504,13 @@ RunTestSuite (
// or quit. The UNIT_TEST_RUNNING state will allow the test to resume
// but will prevent the PreReq from being dispatched a second time.
Test->Result = UNIT_TEST_RUNNING;
- Test->Result = Test->RunTest( Suite->ParentFramework, Test->Context );
+ Test->Result = Test->RunTest (Suite->ParentFramework, Test->Context);
//
// Finally, clean everything up, if need be.
- if (Test->CleanUp != NULL)
- {
- DEBUG(( DEBUG_VERBOSE, "CLEANUP\n" ));
- Test->CleanUp( Suite->ParentFramework, Test->Context );
+ if (Test->CleanUp != NULL) {
+ DEBUG ((DEBUG_VERBOSE, "CLEANUP\n"));
+ Test->CleanUp (Suite->ParentFramework, Test->Context);
}
//
@@ -547,9 +519,8 @@ RunTestSuite (
} // End Test iteration
- if (Suite->Teardown != NULL)
- {
- Suite->Teardown( Suite->ParentFramework );
+ if (Suite->Teardown != NULL) {
+ Suite->Teardown (Suite->ParentFramework);
}
return EFI_SUCCESS;
@@ -557,39 +528,36 @@ RunTestSuite (
EFI_STATUS
EFIAPI
-RunAllTestSuites(
+RunAllTestSuites (
IN UNIT_TEST_FRAMEWORK *Framework
)
{
UNIT_TEST_SUITE_LIST_ENTRY *Suite = NULL;
EFI_STATUS Status;
- if (Framework == NULL)
- {
+ if (Framework == NULL) {
return EFI_INVALID_PARAMETER;
}
- DEBUG((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
- DEBUG((DEBUG_VERBOSE, "------------ RUNNING ALL TEST SUITES --------------\n"));
- DEBUG((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
+ DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
+ DEBUG ((DEBUG_VERBOSE, "------------ RUNNING ALL TEST SUITES --------------\n"));
+ DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
//
// Iterate all suites
//
- for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY*)GetFirstNode(&Framework->TestSuiteList);
- (LIST_ENTRY*)Suite != &Framework->TestSuiteList;
- Suite = (UNIT_TEST_SUITE_LIST_ENTRY*)GetNextNode(&Framework->TestSuiteList, (LIST_ENTRY*)Suite))
- {
- Status = RunTestSuite(&(Suite->UTS));
- if (EFI_ERROR(Status))
- {
- DEBUG((DEBUG_ERROR, "Test Suite Failed with Error. %r\n", Status));
+ for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetFirstNode (&Framework->TestSuiteList);
+ (LIST_ENTRY *)Suite != &Framework->TestSuiteList;
+ Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetNextNode (&Framework->TestSuiteList, (LIST_ENTRY *)Suite)) {
+ Status = RunTestSuite (& (Suite->UTS));
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Test Suite Failed with Error. %r\n", Status));
}
} // End Suite iteration
//Save current state so if test is started again it doesn't have to run. It will just report
- SaveFrameworkState(Framework, NULL, 0);
- OutputUnitTestFrameworkReport(Framework);
+ SaveFrameworkState (Framework, NULL, 0);
+ OutputUnitTestFrameworkReport (Framework);
return EFI_SUCCESS;
}
@@ -615,12 +583,10 @@ UpdateTestFromSave (
//
// First, evaluate the inputs.
- if (Test == NULL || SavedState == NULL)
- {
+ if (Test == NULL || SavedState == NULL) {
return;
}
- if (SavedState->TestCount == 0)
- {
+ if (SavedState->TestCount == 0) {
return;
}
@@ -628,33 +594,34 @@ UpdateTestFromSave (
// Next, determine whether a matching test can be found.
// Start at the beginning.
MatchingTest = NULL;
- FloatingPointer = (UINT8*)SavedState + sizeof( *SavedState );
- for (Index = 0; Index < SavedState->TestCount; Index++)
- {
- CurrentTest = (UNIT_TEST_SAVE_TEST*)FloatingPointer;
- if (CompareFingerprints( &Test->Fingerprint[0], &CurrentTest->Fingerprint[0] ))
- {
+ FloatingPointer = (UINT8 *)SavedState + sizeof (*SavedState);
+ for (Index = 0; Index < SavedState->TestCount; Index++) {
+ CurrentTest = (UNIT_TEST_SAVE_TEST *)FloatingPointer;
+ if (CompareFingerprints (&Test->Fingerprint[0], &CurrentTest->Fingerprint[0])) {
MatchingTest = CurrentTest;
// If there's a saved context, it's important that we iterate through the entire list.
- if (!SavedState->HasSavedContext)
- {
+ if (!SavedState->HasSavedContext) {
break;
}
}
// If we didn't find it, we have to increment to the next test.
- FloatingPointer = (UINT8*)CurrentTest + CurrentTest->Size;
+ FloatingPointer = (UINT8 *)CurrentTest + CurrentTest->Size;
}
//
// If a matching test was found, copy the status.
- if (MatchingTest)
- {
+ if (MatchingTest) {
// Override the test status with the saved status.
Test->Result = MatchingTest->Result;
Test->FailureType = MatchingTest->FailureType;
- StrnCpyS(&Test->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH, &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
@@ -662,27 +629,28 @@ UpdateTestFromSave (
// IMPORTANT NOTE: There are security implications here.
// This data is user-supplied and we're about to play kinda
// fast and loose with data buffers.
- if (MatchingTest->Size > sizeof( UNIT_TEST_SAVE_TEST ))
- {
- UnitTestLogInit(Test, ((UINT8*)MatchingTest + sizeof( UNIT_TEST_SAVE_TEST )), MatchingTest->Size - sizeof( UNIT_TEST_SAVE_TEST ) );
+ if (MatchingTest->Size > sizeof (UNIT_TEST_SAVE_TEST)) {
+ UnitTestLogInit (
+ Test,
+ ((UINT8 *)MatchingTest + sizeof (UNIT_TEST_SAVE_TEST)),
+ MatchingTest->Size - sizeof (UNIT_TEST_SAVE_TEST)
+ );
}
}
//
// If the saved context exists and matches this test, grab it, too.
- if (SavedState->HasSavedContext)
- {
+ if (SavedState->HasSavedContext) {
// TODO: Reconcile the difference between the way "size" works for Test Saves
// and the way it works for Context Saves. Too confusing to use it different ways.
// If there was a saved context, the "matching test" loop will have placed the FloatingPointer
// at the beginning of the context structure.
- SavedContext = (UNIT_TEST_SAVE_CONTEXT*)FloatingPointer;
+ SavedContext = (UNIT_TEST_SAVE_CONTEXT *)FloatingPointer;
if (SavedContext->Size > 0 &&
- CompareFingerprints( &Test->Fingerprint[0], &SavedContext->Fingerprint[0] ))
- {
+ CompareFingerprints (&Test->Fingerprint[0], &SavedContext->Fingerprint[0])) {
// Override the test context with the saved context.
- Test->Context = (VOID*)((UINT8*)SavedContext + sizeof( *SavedContext ));
+ Test->Context = (VOID *)((UINT8 *)SavedContext + sizeof (*SavedContext));
}
}
@@ -691,11 +659,11 @@ UpdateTestFromSave (
STATIC
-UNIT_TEST_SAVE_HEADER*
+UNIT_TEST_SAVE_HEADER *
SerializeState (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
- IN UNIT_TEST_CONTEXT ContextToSave OPTIONAL,
- IN UINTN ContextToSaveSize
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
+ IN UNIT_TEST_CONTEXT ContextToSave, OPTIONAL
+ IN UINTN ContextToSaveSize
)
{
UNIT_TEST_FRAMEWORK *Framework = FrameworkHandle;
@@ -711,8 +679,7 @@ SerializeState (
//
// First, let's not make assumptions about the parameters.
if (Framework == NULL || (ContextToSave != NULL && ContextToSaveSize == 0) ||
- ContextToSaveSize > MAX_UINT32)
- {
+ ContextToSaveSize > MAX_UINT32) {
return NULL;
}
@@ -720,26 +687,23 @@ SerializeState (
// Next, we've gotta figure out the resources that will be required to serialize the
// the framework state so that we can persist it.
// To start with, we're gonna need a header.
- TotalSize = sizeof( UNIT_TEST_SAVE_HEADER );
+ TotalSize = sizeof (UNIT_TEST_SAVE_HEADER);
// Now we need to figure out how many tests there are.
TestCount = 0;
// Iterate all suites.
SuiteListHead = &Framework->TestSuiteList;
- for (Suite = GetFirstNode( SuiteListHead ); Suite != SuiteListHead; Suite = GetNextNode( SuiteListHead, Suite ))
- {
+ for (Suite = GetFirstNode (SuiteListHead); Suite != SuiteListHead; Suite = GetNextNode (SuiteListHead, Suite)) {
// Iterate all tests within the suite.
- TestListHead = &((UNIT_TEST_SUITE_LIST_ENTRY*)Suite)->UTS.TestCaseList;
- for (Test = GetFirstNode( TestListHead ); Test != TestListHead; Test = GetNextNode( TestListHead, Test ))
- {
- UnitTest = &((UNIT_TEST_LIST_ENTRY*)Test)->UT;
+ TestListHead = &((UNIT_TEST_SUITE_LIST_ENTRY *)Suite)->UTS.TestCaseList;
+ for (Test = GetFirstNode (TestListHead); Test != TestListHead; Test = GetNextNode (TestListHead, Test)) {
+ UnitTest = &((UNIT_TEST_LIST_ENTRY *)Test)->UT;
// Account for the size of a test structure.
- TotalSize += sizeof( UNIT_TEST_SAVE_TEST );
+ TotalSize += sizeof (UNIT_TEST_SAVE_TEST);
// If there's a log, make sure to account for the log size.
- if (UnitTest->Log != NULL)
- {
+ if (UnitTest->Log != NULL) {
// The +1 is for the NULL character. Can't forget the NULL character.
- LogSize = (StrLen( UnitTest->Log ) + 1) * sizeof( CHAR16 );
- ASSERT( LogSize < MAX_UINT32 );
+ LogSize = (StrLen (UnitTest->Log) + 1) * sizeof (CHAR16);
+ ASSERT (LogSize < MAX_UINT32);
TotalSize += (UINT32)LogSize;
}
// Increment the test count.
@@ -747,21 +711,18 @@ SerializeState (
}
}
// If there are no tests, we're done here.
- if (TestCount == 0)
- {
+ if (TestCount == 0) {
return NULL;
}
// Add room for the context, if there is one.
- if (ContextToSave != NULL)
- {
- TotalSize += sizeof( UNIT_TEST_SAVE_CONTEXT ) + (UINT32)ContextToSaveSize;
+ if (ContextToSave != NULL) {
+ TotalSize += sizeof (UNIT_TEST_SAVE_CONTEXT) + (UINT32)ContextToSaveSize;
}
//
// Now that we know the size, we need to allocate space for the serialized output.
- Header = AllocateZeroPool( TotalSize );
- if (Header == NULL)
- {
+ Header = AllocateZeroPool (TotalSize);
+ if (Header == NULL) {
return NULL;
}
@@ -769,42 +730,44 @@ SerializeState (
// Alright, let's start setting up some data.
Header->Version = UNIT_TEST_PERSISTENCE_LIB_VERSION;
Header->BlobSize = TotalSize;
- CopyMem( &Header->Fingerprint[0], &Framework->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE );
- CopyMem( &Header->StartTime, &Framework->StartTime, sizeof( EFI_TIME ) );
+ CopyMem (&Header->Fingerprint[0], &Framework->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE);
+ CopyMem (&Header->StartTime, &Framework->StartTime, sizeof (EFI_TIME));
Header->TestCount = TestCount;
Header->HasSavedContext = FALSE;
//
// Start adding all of the test cases.
// Set the floating pointer to the start of the current test save buffer.
- FloatingPointer = (UINT8*)Header + sizeof( UNIT_TEST_SAVE_HEADER );
+ FloatingPointer = (UINT8 *)Header + sizeof (UNIT_TEST_SAVE_HEADER);
// Iterate all suites.
SuiteListHead = &Framework->TestSuiteList;
- for (Suite = GetFirstNode( SuiteListHead ); Suite != SuiteListHead; Suite = GetNextNode( SuiteListHead, Suite ))
- {
+ for (Suite = GetFirstNode (SuiteListHead); Suite != SuiteListHead; Suite = GetNextNode (SuiteListHead, Suite)) {
// Iterate all tests within the suite.
- TestListHead = &((UNIT_TEST_SUITE_LIST_ENTRY*)Suite)->UTS.TestCaseList;
- for (Test = GetFirstNode( TestListHead ); Test != TestListHead; Test = GetNextNode( TestListHead, Test ))
- {
- TestSaveData = (UNIT_TEST_SAVE_TEST*)FloatingPointer;
- UnitTest = &((UNIT_TEST_LIST_ENTRY*)Test)->UT;
+ TestListHead = &((UNIT_TEST_SUITE_LIST_ENTRY *)Suite)->UTS.TestCaseList;
+ for (Test = GetFirstNode (TestListHead); Test != TestListHead; Test = GetNextNode (TestListHead, Test)) {
+ TestSaveData = (UNIT_TEST_SAVE_TEST *)FloatingPointer;
+ UnitTest = &((UNIT_TEST_LIST_ENTRY *)Test)->UT;
// Save the fingerprint.
- CopyMem( &TestSaveData->Fingerprint[0], &UnitTest->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE );
+ CopyMem (&TestSaveData->Fingerprint[0], &UnitTest->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE);
// Save the result.
TestSaveData->Result = UnitTest->Result;
TestSaveData->FailureType = UnitTest->FailureType;
- StrnCpyS(&TestSaveData->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH, &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.
- FloatingPointer += sizeof( UNIT_TEST_SAVE_TEST );
- if (UnitTest->Log != NULL)
- {
+ FloatingPointer += sizeof (UNIT_TEST_SAVE_TEST);
+ if (UnitTest->Log != NULL) {
// The +1 is for the NULL character. Can't forget the NULL character.
- LogSize = (StrLen( UnitTest->Log ) + 1) * sizeof( CHAR16 );
- CopyMem( FloatingPointer, UnitTest->Log, LogSize );
+ LogSize = (StrLen (UnitTest->Log) + 1) * sizeof (CHAR16);
+ CopyMem (FloatingPointer, UnitTest->Log, LogSize);
FloatingPointer += LogSize;
}
@@ -813,18 +776,17 @@ SerializeState (
// Maybe.
// Am I tired of writing code?
// Yes.
- TestSaveData->Size = (UINT32)(FloatingPointer - (UINT8*)TestSaveData);
+ TestSaveData->Size = (UINT32)(FloatingPointer - (UINT8 *)TestSaveData);
}
}
//
// If there is a context to save, let's do that now.
- if (ContextToSave != NULL && Framework->CurrentTest != NULL)
- {
- TestSaveContext = (UNIT_TEST_SAVE_CONTEXT*)FloatingPointer;
+ if (ContextToSave != NULL && Framework->CurrentTest != NULL) {
+ TestSaveContext = (UNIT_TEST_SAVE_CONTEXT *)FloatingPointer;
TestSaveContext->Size = (UINT32)ContextToSaveSize;
- CopyMem( &TestSaveContext->Fingerprint[0], &Framework->CurrentTest->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE );
- CopyMem( ((UINT8*)TestSaveContext + sizeof( UNIT_TEST_SAVE_CONTEXT )), ContextToSave, ContextToSaveSize );
+ CopyMem (&TestSaveContext->Fingerprint[0], &Framework->CurrentTest->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE);
+ CopyMem (((UINT8 *)TestSaveContext + sizeof (UNIT_TEST_SAVE_CONTEXT)), ContextToSave, ContextToSaveSize);
Header->HasSavedContext = TRUE;
}
@@ -835,42 +797,39 @@ SerializeState (
EFI_STATUS
EFIAPI
SaveFrameworkState (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
- IN UNIT_TEST_CONTEXT ContextToSave OPTIONAL,
- IN UINTN ContextToSaveSize
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
+ IN UNIT_TEST_CONTEXT ContextToSave, OPTIONAL
+ IN UINTN ContextToSaveSize
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
UNIT_TEST_SAVE_HEADER *Header = NULL;
//
// First, let's not make assumptions about the parameters.
if (FrameworkHandle == NULL || (ContextToSave != NULL && ContextToSaveSize == 0) ||
- ContextToSaveSize > MAX_UINT32)
- {
+ ContextToSaveSize > MAX_UINT32) {
return EFI_INVALID_PARAMETER;
}
//
// Now, let's package up all the data for saving.
- Header = SerializeState( FrameworkHandle, ContextToSave, ContextToSaveSize );
- if (Header == NULL)
- {
+ Header = SerializeState (FrameworkHandle, ContextToSave, ContextToSaveSize);
+ if (Header == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// All that should be left to do is save it using the associated persistence lib.
- Status = SaveUnitTestCache( FrameworkHandle, Header );
- if (EFI_ERROR( Status ))
- {
- DEBUG(( DEBUG_ERROR, "%a - Could not save state! %r\n", __FUNCTION__, Status ));
+ Status = SaveUnitTestCache (FrameworkHandle, Header);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a - Could not save state! %r\n", __FUNCTION__, Status));
Status = EFI_DEVICE_ERROR;
}
//
// Free data that was used.
- FreePool( Header );
+ FreePool (Header);
return Status;
} // SaveFrameworkState()
@@ -879,36 +838,34 @@ SaveFrameworkState (
EFI_STATUS
EFIAPI
SaveFrameworkStateAndQuit (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
- IN UNIT_TEST_CONTEXT ContextToSave OPTIONAL,
- IN UINTN ContextToSaveSize
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
+ IN UNIT_TEST_CONTEXT ContextToSave, OPTIONAL
+ IN UINTN ContextToSaveSize
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// First, let's not make assumptions about the parameters.
- if (FrameworkHandle == NULL)
- {
+ if (FrameworkHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Now, save all the data associated with this framework.
- Status = SaveFrameworkState( FrameworkHandle, ContextToSave, ContextToSaveSize );
+ Status = SaveFrameworkState (FrameworkHandle, ContextToSave, ContextToSaveSize);
//
// If we're all good, let's book...
- if (!EFI_ERROR( Status ))
- {
+ if (!EFI_ERROR (Status)) {
//
// Free data that was used.
- FreeUnitTestFramework( (UNIT_TEST_FRAMEWORK*)FrameworkHandle );
+ FreeUnitTestFramework ((UNIT_TEST_FRAMEWORK *)FrameworkHandle);
//
// Quit
- gBS->Exit( gImageHandle, EFI_SUCCESS, 0, NULL );
- DEBUG(( DEBUG_ERROR, "%a - Unit test failed to quit! Framework can no longer be used!\n", __FUNCTION__ ));
+ gBS->Exit (gImageHandle, EFI_SUCCESS, 0, NULL);
+ DEBUG ((DEBUG_ERROR, "%a - Unit test failed to quit! Framework can no longer be used!\n", __FUNCTION__));
//
// We REALLY shouldn't be here.
@@ -921,38 +878,36 @@ SaveFrameworkStateAndQuit (
/**
NOTE: Takes in a ResetType, but currently only supports EfiResetCold
- and EfiResetWarm. All other types will return EFI_INVALID_PARAMETER.
- If a more specific reset is required, use SaveFrameworkState() and
- call gRT->ResetSystem() directly.
+ and EfiResetWarm. All other types will return EFI_INVALID_PARAMETER.
+ If a more specific reset is required, use SaveFrameworkState() and
+ call gRT->ResetSystem() directly.
**/
EFI_STATUS
EFIAPI
SaveFrameworkStateAndReboot (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
- IN UNIT_TEST_CONTEXT ContextToSave OPTIONAL,
- IN UINTN ContextToSaveSize,
- IN EFI_RESET_TYPE ResetType
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
+ IN UNIT_TEST_CONTEXT ContextToSave, OPTIONAL
+ IN UINTN ContextToSaveSize,
+ IN EFI_RESET_TYPE ResetType
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// First, let's not make assumptions about the parameters.
if (FrameworkHandle == NULL ||
- (ResetType != EfiResetCold && ResetType != EfiResetWarm))
- {
+ (ResetType != EfiResetCold && ResetType != EfiResetWarm)) {
return EFI_INVALID_PARAMETER;
}
//
// Now, save all the data associated with this framework.
- Status = SaveFrameworkState( FrameworkHandle, ContextToSave, ContextToSaveSize );
+ Status = SaveFrameworkState (FrameworkHandle, ContextToSave, ContextToSaveSize);
//
// If we're all good, let's book...
- if (!EFI_ERROR( Status ))
- {
+ if (!EFI_ERROR (Status)) {
//
// Next, we want to update the BootNext variable to USB
// so that we have a fighting chance of coming back here.
@@ -961,12 +916,12 @@ SaveFrameworkStateAndReboot (
//
// Free data that was used.
- FreeUnitTestFramework( (UNIT_TEST_FRAMEWORK*)FrameworkHandle );
+ FreeUnitTestFramework ((UNIT_TEST_FRAMEWORK *)FrameworkHandle);
//
// Reset
- gRT->ResetSystem( ResetType, EFI_SUCCESS, 0, NULL );
- DEBUG(( DEBUG_ERROR, "%a - Unit test failed to quit! Framework can no longer be used!\n", __FUNCTION__));
+ gRT->ResetSystem (ResetType, EFI_SUCCESS, 0, NULL);
+ DEBUG ((DEBUG_ERROR, "%a - Unit test failed to quit! Framework can no longer be used!\n", __FUNCTION__));
//
// We REALLY shouldn't be here.
diff --git a/MsUnitTestPkg/Library/UnitTestLogLib/UnitTestLogLib.c b/MsUnitTestPkg/Library/UnitTestLogLib/UnitTestLogLib.c
index d5146fcacb..f21e587e88 100644
--- a/MsUnitTestPkg/Library/UnitTestLogLib/UnitTestLogLib.c
+++ b/MsUnitTestPkg/Library/UnitTestLogLib/UnitTestLogLib.c
@@ -1,27 +1,27 @@
-/**
-Implement UnitTestLogLib - Unit test debugging log
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** @file
+ Implement UnitTestLogLib - Unit test debugging log
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
@@ -41,20 +41,18 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-struct _UNIT_TEST_LOG_PREFIX_STRING
-{
+struct _UNIT_TEST_LOG_PREFIX_STRING {
UNIT_TEST_STATUS LogLevel;
CHAR8 *String;
};
-struct _UNIT_TEST_LOG_PREFIX_STRING mLogPrefixStrings[] =
-{
+struct _UNIT_TEST_LOG_PREFIX_STRING mLogPrefixStrings[] = {
{ DEBUG_ERROR, "[ERROR] " },
{ DEBUG_WARN, "[WARNING] " },
{ DEBUG_INFO, "[INFO] " },
{ DEBUG_VERBOSE, "[VERBOSE] " }
};
-UINTN mLogPrefixStringsCount = sizeof( mLogPrefixStrings ) / sizeof( mLogPrefixStrings[0] );
+UINTN mLogPrefixStringsCount = sizeof (mLogPrefixStrings) / sizeof (mLogPrefixStrings[0]);
@@ -66,18 +64,16 @@ UINTN mLogPrefixStringsCount = sizeof( mLogPrefixStrings ) / sizeof( mLogPrefixS
//=============================================================================
STATIC
-CONST CHAR8*
+CONST CHAR8 *
GetStringForStatusLogPrefix (
- IN UINTN LogLevel
+ IN UINTN LogLevel
)
{
- UINTN Index;
+ UINTN Index;
CHAR8 *Result = NULL;
- for (Index = 0; Index < mLogPrefixStringsCount; Index++)
- {
- if (mLogPrefixStrings[Index].LogLevel == LogLevel)
- {
+ for (Index = 0; Index < mLogPrefixStringsCount; Index++) {
+ if (mLogPrefixStrings[Index].LogLevel == LogLevel) {
Result = mLogPrefixStrings[Index].String;
break;
}
@@ -91,8 +87,8 @@ GetStringForStatusLogPrefix (
STATIC
EFI_STATUS
AddStringToUnitTestLog (
- IN OUT UNIT_TEST *UnitTest,
- IN CONST CHAR16 *String
+ IN OUT UNIT_TEST *UnitTest,
+ IN CONST CHAR16 *String
)
{
EFI_STATUS Status;
@@ -100,28 +96,29 @@ AddStringToUnitTestLog (
//
// Make sure that you're cooking with gas.
//
- if (UnitTest == NULL || String == NULL)
- {
+ if (UnitTest == NULL || String == NULL) {
return EFI_INVALID_PARAMETER;
}
// If this is the first log for the test allocate log space
- if (UnitTest->Log == NULL)
- {
- UnitTestLogInit(UnitTest, NULL, 0);
+ if (UnitTest->Log == NULL) {
+ UnitTestLogInit (UnitTest, NULL, 0);
}
- if (UnitTest->Log == NULL)
- {
- DEBUG((DEBUG_ERROR, "Failed to allocate space for unit test log\n"));
- ASSERT(UnitTest->Log != NULL);
+ if (UnitTest->Log == NULL) {
+ DEBUG ((DEBUG_ERROR, "Failed to allocate space for unit test log\n"));
+ ASSERT (UnitTest->Log != NULL);
return EFI_OUT_OF_RESOURCES;
}
- Status = StrnCatS(UnitTest->Log, UNIT_TEST_MAX_LOG_BUFFER/ sizeof(CHAR16), String, UNIT_TEST_MAX_SINGLE_LOG_STRING_LENGTH);
- if(EFI_ERROR(Status))
- {
- DEBUG((DEBUG_ERROR, "Failed to add unit test log string. Status = %r\n", Status));
+ Status = StrnCatS (
+ UnitTest->Log,
+ UNIT_TEST_MAX_LOG_BUFFER / sizeof (CHAR16),
+ String,
+ UNIT_TEST_MAX_SINGLE_LOG_STRING_LENGTH
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed to add unit test log string. Status = %r\n", Status));
return Status;
}
@@ -130,22 +127,21 @@ AddStringToUnitTestLog (
STATIC
EFI_STATUS
-AddUnitTestFailure(
- IN OUT UNIT_TEST *UnitTest,
- IN CONST CHAR16 *FailureMessage,
- FAILURE_TYPE FailureType
-)
+AddUnitTestFailure (
+ IN OUT UNIT_TEST *UnitTest,
+ IN CONST CHAR16 *FailureMessage,
+ FAILURE_TYPE FailureType
+ )
{
//
// Make sure that you're cooking with gas.
//
- if (UnitTest == NULL || FailureMessage == NULL)
- {
+ if (UnitTest == NULL || FailureMessage == NULL) {
return EFI_INVALID_PARAMETER;
}
UnitTest->FailureType = FailureType;
- StrCpyS(&UnitTest->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH, FailureMessage);
+ StrCpyS (&UnitTest->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH, FailureMessage);
return EFI_SUCCESS;
}
@@ -159,45 +155,41 @@ AddUnitTestFailure(
VOID
EFIAPI
UnitTestLogInit (
-IN OUT UNIT_TEST *Test,
-IN UINT8 *Buffer,
-IN UINTN BufferSize
-)
+ IN OUT UNIT_TEST *Test,
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize
+ )
{
//
// Make sure that you're cooking with gas.
//
- if (Test == NULL)
- {
- DEBUG((DEBUG_ERROR, "%a called with invalid Test parameter\n", __FUNCTION__));
+ if (Test == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a called with invalid Test parameter\n", __FUNCTION__));
return;
}
// If this is the first log for the test allocate log space
- if (Test->Log == NULL)
- {
- Test->Log = AllocateZeroPool(UNIT_TEST_MAX_LOG_BUFFER);
+ if (Test->Log == NULL) {
+ Test->Log = AllocateZeroPool (UNIT_TEST_MAX_LOG_BUFFER);
}
//check again to make sure allocate worked
- if(Test->Log == NULL)
- {
- DEBUG((DEBUG_ERROR, "Failed to allocate memory for the log\n"));
+ if (Test->Log == NULL) {
+ DEBUG ((DEBUG_ERROR, "Failed to allocate memory for the log\n"));
return;
}
- if((Buffer != NULL) && (BufferSize > 0) && ((BufferSize <= UNIT_TEST_MAX_LOG_BUFFER)))
- {
- CopyMem(Test->Log, Buffer, BufferSize);
+ if ((Buffer != NULL) && (BufferSize > 0) && ((BufferSize <= UNIT_TEST_MAX_LOG_BUFFER))) {
+ CopyMem (Test->Log, Buffer, BufferSize);
}
}
VOID
EFIAPI
UnitTestLog (
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- IN UINTN ErrorLevel,
- IN CONST CHAR8 *Format,
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
...
)
{
@@ -205,51 +197,48 @@ UnitTestLog (
CHAR16 LogString[UNIT_TEST_MAX_SINGLE_LOG_STRING_LENGTH];
CONST CHAR8 *LogTypePrefix = NULL;
VA_LIST Marker;
- UINTN LogLevel = (UINTN) PcdGet32(UnitTestLogLevel);
+ UINTN LogLevel = (UINTN) PcdGet32 (UnitTestLogLevel);
//
// Make sure that this debug mode is enabled.
//
if ((ErrorLevel & LogLevel) == 0) {
- return;
+ return;
}
//
// If we need to define a new format string...
// well... get to it.
//
- LogTypePrefix = GetStringForStatusLogPrefix( ErrorLevel );
- if (LogTypePrefix != NULL)
- {
- AsciiSPrint( NewFormatString, sizeof( NewFormatString ), "%a%a", LogTypePrefix, Format );
- }
- else
- {
- AsciiStrCpyS( NewFormatString, sizeof( NewFormatString ), Format );
+ LogTypePrefix = GetStringForStatusLogPrefix (ErrorLevel);
+ if (LogTypePrefix != NULL) {
+ AsciiSPrint (NewFormatString, sizeof (NewFormatString), "%a%a", LogTypePrefix, Format);
+ } else {
+ AsciiStrCpyS (NewFormatString, sizeof (NewFormatString), Format);
}
//
// Convert the message to an ASCII String
//
VA_START (Marker, Format);
- UnicodeVSPrintAsciiFormat( LogString, sizeof( LogString ), NewFormatString, Marker );
+ UnicodeVSPrintAsciiFormat (LogString, sizeof (LogString), NewFormatString, Marker);
VA_END (Marker);
//
// Finally, add the string to the log.
//
- AddStringToUnitTestLog( ((UNIT_TEST_FRAMEWORK*)Framework)->CurrentTest, LogString );
+ AddStringToUnitTestLog (((UNIT_TEST_FRAMEWORK *)Framework)->CurrentTest, LogString);
return;
}
VOID
EFIAPI
-UnitTestLogFailure(
- IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
- FAILURE_TYPE FailureType,
- IN CONST CHAR8 *Format,
+UnitTestLogFailure (
+ IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
+ IN FAILURE_TYPE FailureType,
+ IN CONST CHAR8 *Format,
...
-)
+ )
{
CHAR16 LogString[UNIT_TEST_TESTFAILUREMSG_LENGTH];
VA_LIST Marker;
@@ -258,14 +247,14 @@ UnitTestLogFailure(
//
// Convert the message to an ASCII String
//
- VA_START(Marker, Format);
- UnicodeVSPrintAsciiFormat(LogString, sizeof(LogString), Format, Marker);
- VA_END(Marker);
+ VA_START (Marker, Format);
+ UnicodeVSPrintAsciiFormat (LogString, sizeof (LogString), Format, Marker);
+ VA_END (Marker);
//
// Finally, add the string to the log.
//
- AddUnitTestFailure(((UNIT_TEST_FRAMEWORK*)Framework)->CurrentTest, LogString, FailureType);
+ AddUnitTestFailure (((UNIT_TEST_FRAMEWORK *)Framework)->CurrentTest, LogString, FailureType);
return;
}
diff --git a/MsUnitTestPkg/Library/UnitTestPersistenceFileSystemLib/UnitTestPersistenceFileSystemLib.c b/MsUnitTestPkg/Library/UnitTestPersistenceFileSystemLib/UnitTestPersistenceFileSystemLib.c
index c137a1b738..0b3b6deaec 100644
--- a/MsUnitTestPkg/Library/UnitTestPersistenceFileSystemLib/UnitTestPersistenceFileSystemLib.c
+++ b/MsUnitTestPkg/Library/UnitTestPersistenceFileSystemLib/UnitTestPersistenceFileSystemLib.c
@@ -1,30 +1,30 @@
-/** @file -- UnitTestPersistenceFilesystemLib.c
-
-This is an instance of the Unit Test Persistence Lib that will utilize
-the filesystem that a test application is running from to save a serialized
-version of the internal test state in case the test needs to quit and restore.
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** @file
+
+ This is an instance of the Unit Test Persistence Lib that will utilize
+ the filesystem that a test application is running from to save a serialized
+ version of the internal test state in case the test needs to quit and restore.
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
#include <PiDxe.h>
@@ -43,18 +43,18 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/**
TODO: STUFF!!
- @retval !NULL A pointer to the EFI_FILE protocol instance for the filesystem.
- @retval NULL Filesystem could not be found or an error occurred.
+ @retval !NULL A pointer to the EFI_FILE protocol instance for the filesystem.
+ @retval NULL Filesystem could not be found or an error occurred.
**/
STATIC
-EFI_DEVICE_PATH_PROTOCOL*
+EFI_DEVICE_PATH_PROTOCOL *
GetCacheFileDevicePath (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle
)
{
- EFI_STATUS Status;
- UNIT_TEST_FRAMEWORK *Framework = (UNIT_TEST_FRAMEWORK*)FrameworkHandle;
+ EFI_STATUS Status;
+ UNIT_TEST_FRAMEWORK *Framework = (UNIT_TEST_FRAMEWORK *)FrameworkHandle;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
CHAR16 *AppPath = NULL, *CacheFilePath = NULL;
CHAR16 *FileSuffix = L"_Cache.dat";
@@ -65,12 +65,13 @@ GetCacheFileDevicePath (
// First, we need to get some information from the loaded image.
// Namely, where the hell are you?
//
- Status = gBS->HandleProtocol( gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**)&LoadedImage );
- if (EFI_ERROR( Status ))
- {
- DEBUG(( DEBUG_WARN, "%a - Failed to locate DevicePath for loaded image. %r\n", __FUNCTION__, Status ));
+ Status = gBS->HandleProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_WARN, "%a - Failed to locate DevicePath for loaded image. %r\n", __FUNCTION__, Status));
return NULL;
}
@@ -82,19 +83,16 @@ GetCacheFileDevicePath (
// NOTE: This may not be necessary... Path processing functions exist...
// PathCleanUpDirectories (FileNameCopy);
// if (PathRemoveLastItem (FileNameCopy)) {
- AppPath = ConvertDevicePathToText( LoadedImage->FilePath, TRUE, TRUE ); // NOTE: This must be freed.
- DirectorySlashOffset = StrLen( AppPath );
+ AppPath = ConvertDevicePathToText (LoadedImage->FilePath, TRUE, TRUE); // NOTE: This must be freed.
+ DirectorySlashOffset = StrLen (AppPath);
// Make sure we didn't get any weird data.
- if (DirectorySlashOffset == 0)
- {
- DEBUG(( DEBUG_ERROR, "%a - Weird 0-length string when processing app path.\n", __FUNCTION__ ));
+ if (DirectorySlashOffset == 0) {
+ DEBUG ((DEBUG_ERROR, "%a - Weird 0-length string when processing app path.\n", __FUNCTION__));
goto Exit;
}
// Now that we know we have a decent string, let's take a deeper look.
- do
- {
- if (AppPath[DirectorySlashOffset] == L'\\')
- {
+ do {
+ if (AppPath[DirectorySlashOffset] == L'\\') {
break;
}
DirectorySlashOffset--;
@@ -105,9 +103,8 @@ GetCacheFileDevicePath (
// That would be the path to the parent directory that the test app is executing from.
// Let's check and make sure that's right.
//
- if (AppPath[DirectorySlashOffset] != L'\\')
- {
- DEBUG(( DEBUG_ERROR, "%a - Could not find a single directory separator in app path.\n", __FUNCTION__ ));
+ if (AppPath[DirectorySlashOffset] != L'\\') {
+ DEBUG ((DEBUG_ERROR, "%a - Could not find a single directory separator in app path.\n", __FUNCTION__));
goto Exit;
}
@@ -115,32 +112,39 @@ GetCacheFileDevicePath (
// Now we know some things, we're ready to produce our output string, I think.
//
CacheFilePathLength = DirectorySlashOffset + 1;
- CacheFilePathLength += StrLen( Framework->ShortTitle );
- CacheFilePathLength += StrLen( FileSuffix );
+ CacheFilePathLength += StrLen (Framework->ShortTitle);
+ CacheFilePathLength += StrLen (FileSuffix);
CacheFilePathLength += 1; // Don't forget the NULL terminator.
- CacheFilePath = AllocateZeroPool( CacheFilePathLength * sizeof( CHAR16 ) );
+ CacheFilePath = AllocateZeroPool (CacheFilePathLength * sizeof (CHAR16));
//
// Let's produce our final path string, shall we?
//
- StrnCpyS( CacheFilePath, CacheFilePathLength, AppPath, DirectorySlashOffset + 1 ); // Copy the path for the parent directory.
- StrCatS( CacheFilePath, CacheFilePathLength, Framework->ShortTitle ); // Copy the base name for the test cache.
- StrCatS( CacheFilePath, CacheFilePathLength, FileSuffix ); // Copy the file suffix.
+ StrnCpyS (
+ CacheFilePath,
+ CacheFilePathLength,
+ AppPath,
+ DirectorySlashOffset + 1
+ ); // Copy the path for the parent directory.
+ StrCatS (
+ CacheFilePath,
+ CacheFilePathLength,
+ Framework->ShortTitle
+ ); // Copy the base name for the test cache.
+ StrCatS (CacheFilePath, CacheFilePathLength, FileSuffix); // Copy the file suffix.
//
// Finally, try to create the device path for the thing thing.
//
- CacheFileDevicePath = FileDevicePath( LoadedImage->DeviceHandle, CacheFilePath );
+ CacheFileDevicePath = FileDevicePath (LoadedImage->DeviceHandle, CacheFilePath);
Exit:
// Always put away your toys.
- if (AppPath != NULL)
- {
- FreePool( AppPath );
+ if (AppPath != NULL) {
+ FreePool (AppPath);
}
- if (CacheFilePath != NULL)
- {
- FreePool( CacheFilePath);
+ if (CacheFilePath != NULL) {
+ FreePool (CacheFilePath);
}
return CacheFileDevicePath;
@@ -151,47 +155,47 @@ Exit:
Determines whether a persistence cache already exists for
the given framework.
- @param[in] FrameworkHandle A pointer to the framework that is being persisted.
+ @param[in] FrameworkHandle A pointer to the framework that is being persisted.
- @retval TRUE
- @retval FALSE Cache doesn't exist or an error occurred.
+ @retval TRUE
+ @retval FALSE Cache doesn't exist or an error occurred.
**/
BOOLEAN
EFIAPI
DoesCacheExist (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle
)
{
- EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
- EFI_STATUS Status;
- EFI_HANDLE FileDeviceHandle;
- SHELL_FILE_HANDLE FileHandle;
+ EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
+ EFI_STATUS Status;
+ EFI_HANDLE FileDeviceHandle;
+ SHELL_FILE_HANDLE FileHandle;
// NOTE: This devpath is allocated and must be freed.
- FileDevicePath = GetCacheFileDevicePath( FrameworkHandle );
+ FileDevicePath = GetCacheFileDevicePath (FrameworkHandle);
// Check to see whether the file exists.
// If the file can be opened for reading, it exists.
// Otherwise, probably not.
- Status = ShellOpenFileByDevicePath( &FileDevicePath,
- &FileDeviceHandle,
- &FileHandle,
- EFI_FILE_MODE_READ,
- 0 );
- if (!EFI_ERROR( Status ))
- {
- ShellCloseFile( &FileHandle );
+ Status = ShellOpenFileByDevicePath (
+ &FileDevicePath,
+ &FileDeviceHandle,
+ &FileHandle,
+ EFI_FILE_MODE_READ,
+ 0
+ );
+ if (!EFI_ERROR (Status)) {
+ ShellCloseFile (&FileHandle);
}
- if (FileDevicePath != NULL)
- {
- FreePool( FileDevicePath );
+ if (FileDevicePath != NULL) {
+ FreePool (FileDevicePath);
}
- DEBUG(( DEBUG_VERBOSE, "%a - Returning %d\n", __FUNCTION__, !EFI_ERROR( Status ) ));
+ DEBUG ((DEBUG_VERBOSE, "%a - Returning %d\n", __FUNCTION__, !EFI_ERROR (Status)));
- return !EFI_ERROR( Status );
+ return !EFI_ERROR (Status);
} // DoesCacheExist()
@@ -200,69 +204,69 @@ DoesCacheExist (
state in a manner that can persist a Unit Test Application quit or
even a system reboot.
- @param[in] FrameworkHandle A pointer to the framework that is being persisted.
- @param[in] SaveData A pointer to the buffer containing the serialized
- framework internal state.
+ @param[in] FrameworkHandle A pointer to the framework that is being persisted.
+ @param[in] SaveData A pointer to the buffer containing the serialized
+ framework internal state.
- @retval EFI_SUCCESS Data is persisted and the test can be safely quit.
- @retval Others Data is not persisted and test cannot be resumed upon exit.
+ @retval EFI_SUCCESS Data is persisted and the test can be safely quit.
+ @retval Others Data is not persisted and test cannot be resumed upon exit.
**/
EFI_STATUS
EFIAPI
SaveUnitTestCache (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
- IN UNIT_TEST_SAVE_HEADER *SaveData
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
+ IN UNIT_TEST_SAVE_HEADER *SaveData
)
{
- EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
- EFI_STATUS Status;
- EFI_HANDLE FileDeviceHandle;
- SHELL_FILE_HANDLE FileHandle;
- UINTN WriteCount;
+ EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
+ EFI_STATUS Status;
+ EFI_HANDLE FileDeviceHandle;
+ SHELL_FILE_HANDLE FileHandle;
+ UINTN WriteCount;
//
// Check the inputs for sanity.
- if (FrameworkHandle == NULL || SaveData == NULL)
- {
+ if (FrameworkHandle == NULL || SaveData == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Determine the path for the cache file.
// NOTE: This devpath is allocated and must be freed.
- FileDevicePath = GetCacheFileDevicePath( FrameworkHandle );
+ FileDevicePath = GetCacheFileDevicePath (FrameworkHandle);
//
//First lets open the file if it exists so we can delete it...This is the work around for truncation
//
- Status = ShellOpenFileByDevicePath(&FileDevicePath,
- &FileDeviceHandle,
- &FileHandle,
- (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE),
- 0);
-
- if (!EFI_ERROR(Status))
- {
+ Status = ShellOpenFileByDevicePath (
+ &FileDevicePath,
+ &FileDeviceHandle,
+ &FileHandle,
+ (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE),
+ 0
+ );
+
+ if (!EFI_ERROR (Status)) {
//if file handle above was opened it will be closed by the delete.
- Status = ShellDeleteFile(&FileHandle);
- if (EFI_ERROR(Status))
- {
- DEBUG((DEBUG_ERROR, "%a failed to delete file %r\n", __FUNCTION__, Status));
+ Status = ShellDeleteFile (&FileHandle);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a failed to delete file %r\n", __FUNCTION__, Status));
}
}
//
// Now that we know the path to the file... let's open it for writing.
//
- Status = ShellOpenFileByDevicePath( &FileDevicePath,
- &FileDeviceHandle,
- &FileHandle,
- (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE),
- 0 );
- if (EFI_ERROR( Status ))
- {
- DEBUG(( DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __FUNCTION__, Status ));
+ Status = ShellOpenFileByDevicePath (
+ &FileDevicePath,
+ &FileDeviceHandle,
+ &FileHandle,
+ (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE),
+ 0
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __FUNCTION__, Status));
goto Exit;
}
@@ -270,29 +274,27 @@ SaveUnitTestCache (
// Write the data to the file.
//
WriteCount = SaveData->BlobSize;
- DEBUG(( DEBUG_INFO, "%a - Writing %d bytes to file...\n", __FUNCTION__, WriteCount ));
- Status = ShellWriteFile( FileHandle,
- &WriteCount,
- SaveData );
-
- if (EFI_ERROR( Status ) || WriteCount != SaveData->BlobSize)
- {
- DEBUG(( DEBUG_ERROR, "%a - Writing to file failed! %r\n", __FUNCTION__, Status ));
- }
- else
- {
- DEBUG(( DEBUG_INFO, "%a - SUCCESS!\n", __FUNCTION__));
+ DEBUG ((DEBUG_INFO, "%a - Writing %d bytes to file...\n", __FUNCTION__, WriteCount));
+ Status = ShellWriteFile (
+ FileHandle,
+ &WriteCount,
+ SaveData
+ );
+
+ if (EFI_ERROR (Status) || WriteCount != SaveData->BlobSize) {
+ DEBUG ((DEBUG_ERROR, "%a - Writing to file failed! %r\n", __FUNCTION__, Status));
+ } else {
+ DEBUG ((DEBUG_INFO, "%a - SUCCESS!\n", __FUNCTION__));
}
//
// No matter what, we should probably close the file.
//
- ShellCloseFile( &FileHandle );
+ ShellCloseFile (&FileHandle);
Exit:
- if (FileDevicePath != NULL)
- {
- FreePool( FileDevicePath );
+ if (FileDevicePath != NULL) {
+ FreePool (FileDevicePath);
}
return Status;
@@ -303,14 +305,14 @@ Exit:
Will retrieve any cached state associated with the given framework.
Will allocate a buffer to hold the loaded data.
- @param[in] FrameworkHandle A pointer to the framework that is being persisted.
- @param[in] SaveData A pointer pointer that will be updated with the address
- of the loaded data buffer.
+ @param[in] FrameworkHandle A pointer to the framework that is being persisted.
+ @param[in] SaveData A pointer pointer that will be updated with the address
+ of the loaded data buffer.
- @retval EFI_SUCCESS Data has been loaded successfully and SaveData is updated
- with a pointer to the buffer.
- @retval Others An error has occurred and no data has been loaded. SaveData
- is set to NULL.
+ @retval EFI_SUCCESS Data has been loaded successfully and SaveData is updated
+ with a pointer to the buffer.
+ @retval Others An error has occurred and no data has been loaded. SaveData
+ is set to NULL.
**/
EFI_STATUS
@@ -320,10 +322,10 @@ LoadUnitTestCache (
OUT UNIT_TEST_SAVE_HEADER **SaveData
)
{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
- EFI_HANDLE FileDeviceHandle;
- SHELL_FILE_HANDLE FileHandle;
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
+ EFI_HANDLE FileDeviceHandle;
+ SHELL_FILE_HANDLE FileHandle;
BOOLEAN IsFileOpened = FALSE;
UINT64 LargeFileSize;
UINTN FileSize;
@@ -331,80 +333,72 @@ LoadUnitTestCache (
//
// Check the inputs for sanity.
- if (FrameworkHandle == NULL || SaveData == NULL)
- {
+ if (FrameworkHandle == NULL || SaveData == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Determine the path for the cache file.
// NOTE: This devpath is allocated and must be freed.
- FileDevicePath = GetCacheFileDevicePath( FrameworkHandle );
+ FileDevicePath = GetCacheFileDevicePath (FrameworkHandle);
//
// Now that we know the path to the file... let's open it for writing.
//
- Status = ShellOpenFileByDevicePath( &FileDevicePath,
- &FileDeviceHandle,
- &FileHandle,
- EFI_FILE_MODE_READ,
- 0 );
- if (EFI_ERROR( Status ))
- {
- DEBUG(( DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __FUNCTION__, Status ));
+ Status = ShellOpenFileByDevicePath (
+ &FileDevicePath,
+ &FileDeviceHandle,
+ &FileHandle,
+ EFI_FILE_MODE_READ,
+ 0
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __FUNCTION__, Status));
goto Exit;
- }
- else
- {
+ } else {
IsFileOpened = TRUE;
}
//
// Now that the file is opened, we need to determine how large a buffer we need.
- Status = ShellGetFileSize( FileHandle, &LargeFileSize );
- if (EFI_ERROR( Status ))
- {
- DEBUG(( DEBUG_ERROR, "%a - Failed to determine file size! %r\n", __FUNCTION__, Status ));
+ Status = ShellGetFileSize (FileHandle, &LargeFileSize);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a - Failed to determine file size! %r\n", __FUNCTION__, Status));
goto Exit;
}
//
// Now that we know the size, let's allocated a buffer to hold the contents.
FileSize = (UINTN)LargeFileSize; // You know what... if it's too large, this lib don't care.
- Buffer = AllocatePool( FileSize );
- if (Buffer == NULL)
- {
- DEBUG(( DEBUG_ERROR, "%a - Failed to allocate a pool to hold the file contents! %r\n", __FUNCTION__, Status ));
+ Buffer = AllocatePool (FileSize);
+ if (Buffer == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a - Failed to allocate a pool to hold the file contents! %r\n", __FUNCTION__, Status));
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
//
// Finally, let's read the bloody data.
- Status = ShellReadFile( FileHandle, &FileSize, Buffer );
- if (EFI_ERROR( Status ))
- {
- DEBUG(( DEBUG_ERROR, "%a - Failed to read the file contents! %r\n", __FUNCTION__, Status ));
+ Status = ShellReadFile (FileHandle, &FileSize, Buffer);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a - Failed to read the file contents! %r\n", __FUNCTION__, Status));
}
Exit:
//
// Always put away your toys.
- if (FileDevicePath != NULL)
- {
- FreePool( FileDevicePath );
+ if (FileDevicePath != NULL) {
+ FreePool (FileDevicePath);
}
- if (IsFileOpened)
- {
- ShellCloseFile( &FileHandle );
+ if (IsFileOpened) {
+ ShellCloseFile (&FileHandle);
}
//
// If we're returning an error, make sure
// the state is sane.
- if (EFI_ERROR( Status ) && Buffer != NULL)
- {
- FreePool( Buffer );
+ if (EFI_ERROR (Status) && Buffer != NULL) {
+ FreePool (Buffer);
Buffer = NULL;
}
diff --git a/MsUnitTestPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.c b/MsUnitTestPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.c
index 01ac4a4fe7..ef1cda8d3f 100644
--- a/MsUnitTestPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.c
+++ b/MsUnitTestPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.c
@@ -1,27 +1,27 @@
/** @file -- UnitTestNullPersistenceLib.c
-This is an instance of the Unit Test Persistence Lib that does nothing.
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ This is an instance of the Unit Test Persistence Lib that does nothing.
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
@@ -35,16 +35,16 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Determines whether a persistence cache already exists for
the given framework.
- @param[in] FrameworkHandle A pointer to the framework that is being persisted.
+ @param[in] FrameworkHandle A pointer to the framework that is being persisted.
- @retval TRUE
- @retval FALSE Cache doesn't exist or an error occurred.
+ @retval TRUE
+ @retval FALSE Cache doesn't exist or an error occurred.
**/
BOOLEAN
EFIAPI
DoesCacheExist (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle
)
{
return FALSE;
@@ -56,19 +56,19 @@ DoesCacheExist (
state in a manner that can persist a Unit Test Application quit or
even a system reboot.
- @param[in] FrameworkHandle A pointer to the framework that is being persisted.
- @param[in] SaveData A pointer to the buffer containing the serialized
- framework internal state.
+ @param[in] FrameworkHandle A pointer to the framework that is being persisted.
+ @param[in] SaveData A pointer to the buffer containing the serialized
+ framework internal state.
- @retval EFI_SUCCESS Data is persisted and the test can be safely quit.
- @retval Others Data is not persisted and test cannot be resumed upon exit.
+ @retval EFI_SUCCESS Data is persisted and the test can be safely quit.
+ @retval Others Data is not persisted and test cannot be resumed upon exit.
**/
EFI_STATUS
EFIAPI
SaveUnitTestCache (
- IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
- IN UNIT_TEST_SAVE_HEADER *SaveData
+ IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle,
+ IN UNIT_TEST_SAVE_HEADER *SaveData
)
{
return EFI_UNSUPPORTED;
@@ -79,14 +79,14 @@ SaveUnitTestCache (
Will retrieve any cached state associated with the given framework.
Will allocate a buffer to hold the loaded data.
- @param[in] FrameworkHandle A pointer to the framework that is being persisted.
- @param[in] SaveData A pointer pointer that will be updated with the address
- of the loaded data buffer.
+ @param[in] FrameworkHandle A pointer to the framework that is being persisted.
+ @param[in] SaveData A pointer pointer that will be updated with the address
+ of the loaded data buffer.
- @retval EFI_SUCCESS Data has been loaded successfully and SaveData is updated
- with a pointer to the buffer.
- @retval Others An error has occurred and no data has been loaded. SaveData
- is set to NULL.
+ @retval EFI_SUCCESS Data has been loaded successfully and SaveData is updated
+ with a pointer to the buffer.
+ @retval Others An error has occurred and no data has been loaded. SaveData
+ is set to NULL.
**/
EFI_STATUS
diff --git a/MsUnitTestPkg/Library/UnitTestResultReportPlainTextOutputLib/UnitTestResultReportLib.c b/MsUnitTestPkg/Library/UnitTestResultReportPlainTextOutputLib/UnitTestResultReportLib.c
index 9c243a34e3..c713de25f8 100644
--- a/MsUnitTestPkg/Library/UnitTestResultReportPlainTextOutputLib/UnitTestResultReportLib.c
+++ b/MsUnitTestPkg/Library/UnitTestResultReportPlainTextOutputLib/UnitTestResultReportLib.c
@@ -1,28 +1,27 @@
-/**
-Implement UnitTestResultReportLib doing plain txt out to console
-
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** @file
+ Implement UnitTestResultReportLib doing plain txt out to console
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
@@ -35,31 +34,27 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-struct _UNIT_TEST_STATUS_STRING
-{
+struct _UNIT_TEST_STATUS_STRING {
UNIT_TEST_STATUS Status;
CHAR8 *String;
};
-struct _UNIT_TEST_STATUS_STRING mStatusStrings[] =
-{
+struct _UNIT_TEST_STATUS_STRING mStatusStrings[] = {
{ UNIT_TEST_PASSED, "PASSED" },
{ UNIT_TEST_ERROR_PREREQ_NOT_MET, "NOT RUN - PREREQ FAILED" },
{ UNIT_TEST_ERROR_TEST_FAILED, "FAILED" },
{ UNIT_TEST_RUNNING, "RUNNING" },
{ UNIT_TEST_PENDING, "PENDING" }
};
-UINTN mStatusStringsCount = sizeof( mStatusStrings ) / sizeof( mStatusStrings[0] );
+UINTN mStatusStringsCount = sizeof (mStatusStrings) / sizeof (mStatusStrings[0]);
CHAR8 *mUnknownStatus = "**UNKNOWN**";
-struct _UNIT_TEST_FAILURE_TYPE_STRING
-{
+struct _UNIT_TEST_FAILURE_TYPE_STRING {
FAILURE_TYPE Type;
CHAR8 *String;
};
-struct _UNIT_TEST_FAILURE_TYPE_STRING mFailureTypeStrings[]=
-{
+struct _UNIT_TEST_FAILURE_TYPE_STRING mFailureTypeStrings[] = {
{ FAILURETYPE_NOFAILURE, "NO FAILURE"},
{ FAILURETYPE_OTHER, "OTHER FAILURE" },
{ FAILURETYPE_ASSERTTRUE, "ASSERT_TRUE FAILURE" },
@@ -68,9 +63,9 @@ struct _UNIT_TEST_FAILURE_TYPE_STRING mFailureTypeStrings[]=
{ FAILURETYPE_ASSERTNOTEQUAL, "ASSERT_NOTEQUAL FAILURE"},
{ FAILURETYPE_ASSERTNOTEFIERROR, "ASSERT_NOTEFIERROR FAILURE"},
{ FAILURETYPE_ASSERTSTATUSEQUAL, "ASSERT_STATUSEQUAL FAILURE"},
- { FAILURETYPE_ASSERTNOTNULL , "ASSERT_NOTNULL FAILURE" }
+ { FAILURETYPE_ASSERTNOTNULL, "ASSERT_NOTNULL FAILURE" }
};
-UINTN mFailureTypeStringsCount = sizeof(mFailureTypeStrings) / sizeof(mFailureTypeStrings[0]);
+UINTN mFailureTypeStringsCount = sizeof (mFailureTypeStrings) / sizeof (mFailureTypeStrings[0]);
CHAR8 *mUnknownFailureType = "*UNKNOWN* Failure";
//=============================================================================
@@ -80,19 +75,17 @@ CHAR8 *mUnknownFailureType = "*UNKNOWN* Failure";
//=============================================================================
STATIC
-CONST CHAR8*
+CONST CHAR8 *
GetStringForUnitTestStatus (
- IN UNIT_TEST_STATUS Status
+ IN UNIT_TEST_STATUS Status
)
{
- UINTN Index;
- CHAR8 *Result;
+ UINTN Index;
+ CHAR8 *Result;
Result = mUnknownStatus;
- for (Index = 0; Index < mStatusStringsCount; Index++)
- {
- if (mStatusStrings[Index].Status == Status)
- {
+ for (Index = 0; Index < mStatusStringsCount; Index++) {
+ if (mStatusStrings[Index].Status == Status) {
Result = mStatusStrings[Index].String;
break;
}
@@ -102,39 +95,36 @@ GetStringForUnitTestStatus (
}
STATIC
-CONST CHAR8*
-GetStringForFailureType(
- IN FAILURE_TYPE Failure
-)
+CONST CHAR8 *
+GetStringForFailureType (
+ IN FAILURE_TYPE Failure
+ )
{
- UINTN Index;
- CHAR8 *Result;
+ UINTN Index;
+ CHAR8 *Result;
Result = mUnknownFailureType;
- for (Index = 0; Index < mFailureTypeStringsCount; Index++)
- {
- if (mFailureTypeStrings[Index].Type == Failure)
- {
+ for (Index = 0; Index < mFailureTypeStringsCount; Index++) {
+ if (mFailureTypeStrings[Index].Type == Failure) {
Result = mFailureTypeStrings[Index].String;
break;
}
}
- if (Result == mUnknownFailureType)
- {
- DEBUG((DEBUG_INFO, "%a Failure Type does not have string defined 0x%X\n", __FUNCTION__ , (UINT32)Failure));
+ if (Result == mUnknownFailureType) {
+ DEBUG ((DEBUG_INFO, "%a Failure Type does not have string defined 0x%X\n", __FUNCTION__, (UINT32)Failure));
}
return Result;
}
/*
-Method to print the Unit Test run results
+ Method to print the Unit Test run results
-@retval Success
+ @retval Success
*/
EFI_STATUS
EFIAPI
-OutputUnitTestFrameworkReport(
+OutputUnitTestFrameworkReport (
IN UNIT_TEST_FRAMEWORK *Framework
)
{
@@ -143,87 +133,89 @@ OutputUnitTestFrameworkReport(
INTN NotRun = 0;
UNIT_TEST_SUITE_LIST_ENTRY *Suite = NULL;
- if (Framework == NULL)
- {
+ if (Framework == NULL) {
return EFI_INVALID_PARAMETER;
}
- Print( L"---------------------------------------------------------\n" );
- Print( L"------------- UNIT TEST FRAMEWORK RESULTS ---------------\n" );
- Print( L"---------------------------------------------------------\n" );
+ Print (L"---------------------------------------------------------\n");
+ Print (L"------------- UNIT TEST FRAMEWORK RESULTS ---------------\n");
+ Print (L"---------------------------------------------------------\n");
//print the version and time
//
// Iterate all suites
//
- for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY*)GetFirstNode(&Framework->TestSuiteList);
- (LIST_ENTRY*)Suite != &Framework->TestSuiteList;
- Suite = (UNIT_TEST_SUITE_LIST_ENTRY*)GetNextNode(&Framework->TestSuiteList, (LIST_ENTRY*)Suite))
- {
+ for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetFirstNode (&Framework->TestSuiteList);
+ (LIST_ENTRY *)Suite != &Framework->TestSuiteList;
+ Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetNextNode (&Framework->TestSuiteList, (LIST_ENTRY *)Suite)) {
UNIT_TEST_LIST_ENTRY *Test = NULL;
INTN SPassed = 0;
INTN SFailed = 0;
INTN SNotRun = 0;
- Print( L"/////////////////////////////////////////////////////////\n" );
- Print( L" SUITE: %s\n", Suite->UTS.Title );
- Print( L" PACKAGE: %s\n", Suite->UTS.Package);
- Print( L"/////////////////////////////////////////////////////////\n" );
+ Print (L"/////////////////////////////////////////////////////////\n");
+ Print (L" SUITE: %s\n", Suite->UTS.Title);
+ Print (L" PACKAGE: %s\n", Suite->UTS.Package);
+ Print (L"/////////////////////////////////////////////////////////\n");
//
// Iterate all tests within the suite
//
- for (Test = (UNIT_TEST_LIST_ENTRY*)GetFirstNode(&(Suite->UTS.TestCaseList));
- (LIST_ENTRY*)Test != &(Suite->UTS.TestCaseList);
- Test = (UNIT_TEST_LIST_ENTRY*)GetNextNode(&(Suite->UTS.TestCaseList), (LIST_ENTRY*)Test))
- {
+ for (Test = (UNIT_TEST_LIST_ENTRY *)GetFirstNode (& (Suite->UTS.TestCaseList));
+ (LIST_ENTRY *)Test != &(Suite->UTS.TestCaseList);
+ Test = (UNIT_TEST_LIST_ENTRY *)GetNextNode (& (Suite->UTS.TestCaseList), (LIST_ENTRY *)Test)) {
- Print (L"*********************************************************\n" );
+ Print (L"*********************************************************\n");
Print (L" CLASS NAME: %s\n", Test->UT.ClassName);
- Print( L" TEST: %s\n", Test->UT.Description );
- Print( L" STATUS: %a\n", GetStringForUnitTestStatus( Test->UT.Result ) );
- Print( L" FAILURE: %a\n", GetStringForFailureType(Test->UT.FailureType));
- Print( L" FAILURE MESSAGE:\n%a\n", Test->UT.FailureMessage);
-
- if (Test->UT.Log != NULL)
- {
- Print( L" LOG:\n" );
+ Print (L" TEST: %s\n", Test->UT.Description);
+ Print (L" STATUS: %a\n", GetStringForUnitTestStatus (Test->UT.Result));
+ Print (L" FAILURE: %a\n", GetStringForFailureType (Test->UT.FailureType));
+ Print (L" FAILURE MESSAGE:\n%a\n", Test->UT.FailureMessage);
+
+ if (Test->UT.Log != NULL) {
+ Print (L" LOG:\n");
// NOTE: This has to be done directly because all of the other
// "formatted" print statements have caps on the string size.
- gST->ConOut->OutputString( gST->ConOut, Test->UT.Log );
+ gST->ConOut->OutputString (gST->ConOut, Test->UT.Log);
}
- switch (Test->UT.Result)
- {
- case UNIT_TEST_PASSED: SPassed++; break;
- case UNIT_TEST_ERROR_TEST_FAILED: SFailed++; break;
- case UNIT_TEST_PENDING: // Fall through...
- case UNIT_TEST_RUNNING: // Fall through...
- case UNIT_TEST_ERROR_PREREQ_NOT_MET: SNotRun++; break;
- default: break;
+ switch (Test->UT.Result) {
+ case UNIT_TEST_PASSED:
+ SPassed++;
+ break;
+ case UNIT_TEST_ERROR_TEST_FAILED:
+ SFailed++;
+ break;
+ case UNIT_TEST_PENDING: // Fall through...
+ case UNIT_TEST_RUNNING: // Fall through...
+ case UNIT_TEST_ERROR_PREREQ_NOT_MET:
+ SNotRun++;
+ break;
+ default:
+ break;
}
- Print( L"**********************************************************\n" );
+ Print (L"**********************************************************\n");
} //End Test iteration
- Print( L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" );
- Print( L"Suite Stats\n" );
- Print( L" Passed: %d (%d%%)\n", SPassed, (SPassed * 100)/(SPassed+SFailed+SNotRun) );
- Print( L" Failed: %d (%d%%)\n", SFailed, (SFailed * 100) / (SPassed + SFailed + SNotRun) );
- Print( L" Not Run: %d (%d%%)\n", SNotRun, (SNotRun * 100) / (SPassed + SFailed + SNotRun) );
- Print( L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n" );
+ Print (L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ Print (L"Suite Stats\n");
+ Print (L" Passed: %d (%d%%)\n", SPassed, (SPassed * 100) / (SPassed + SFailed + SNotRun));
+ Print (L" Failed: %d (%d%%)\n", SFailed, (SFailed * 100) / (SPassed + SFailed + SNotRun));
+ Print (L" Not Run: %d (%d%%)\n", SNotRun, (SNotRun * 100) / (SPassed + SFailed + SNotRun));
+ Print (L"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
Passed += SPassed; //add to global counters
Failed += SFailed; //add to global counters
NotRun += SNotRun; //add to global coutners
}//End Suite iteration
- Print( L"=========================================================\n" );
- Print( L"Total Stats\n" );
- Print( L" Passed: %d (%d%%)\n", Passed, (Passed * 100) / (Passed + Failed + NotRun) );
- Print( L" Failed: %d (%d%%)\n", Failed, (Failed * 100) / (Passed + Failed + NotRun) );
- Print( L" Not Run: %d (%d%%)\n", NotRun, (NotRun * 100) / (Passed + Failed + NotRun) );
- Print( L"=========================================================\n" );
+ Print (L"=========================================================\n");
+ Print (L"Total Stats\n");
+ Print (L" Passed: %d (%d%%)\n", Passed, (Passed * 100) / (Passed + Failed + NotRun));
+ Print (L" Failed: %d (%d%%)\n", Failed, (Failed * 100) / (Passed + Failed + NotRun));
+ Print (L" Not Run: %d (%d%%)\n", NotRun, (NotRun * 100) / (Passed + Failed + NotRun));
+ Print (L"=========================================================\n");
return EFI_SUCCESS;
}
diff --git a/MsUnitTestPkg/Sample/SampleUnitTestApp/SampleUnitTestApp.c b/MsUnitTestPkg/Sample/SampleUnitTestApp/SampleUnitTestApp.c
index 73af67a8e4..578a5b4270 100644
--- a/MsUnitTestPkg/Sample/SampleUnitTestApp/SampleUnitTestApp.c
+++ b/MsUnitTestPkg/Sample/SampleUnitTestApp/SampleUnitTestApp.c
@@ -1,27 +1,27 @@
-/** @file -- SampleUnitTestApp.c
-This is a sample EFI Shell application to demostrate the usage of the Unit Test Library.
-
-Copyright (c) 2016, Microsoft Corporation
-
-All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-1. Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+/** @file
+ This is a sample EFI Shell application to demostrate the usage of the Unit Test Library.
+
+ Copyright (c) 2016, Microsoft Corporation
+
+ All rights reserved.
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**/
@@ -101,7 +101,7 @@ OnePlusOneShouldEqualTwo (
B = 1;
C = A + B;
- UT_ASSERT_EQUAL(C, 2);
+ UT_ASSERT_EQUAL (C, 2);
return UNIT_TEST_PASSED;
} // OnePlusOneShouldEqualTwo()
@@ -114,10 +114,10 @@ GlobalBooleanShouldBeChangeable (
)
{
mSampleGlobalTestBoolean = TRUE;
- UT_ASSERT_TRUE(mSampleGlobalTestBoolean);
+ UT_ASSERT_TRUE (mSampleGlobalTestBoolean);
mSampleGlobalTestBoolean = FALSE;
- UT_ASSERT_FALSE(mSampleGlobalTestBoolean);
+ UT_ASSERT_FALSE (mSampleGlobalTestBoolean);
return UNIT_TEST_PASSED;
} // GlobalBooleanShouldBeChangeable()
@@ -148,11 +148,11 @@ GlobalPointerShouldBeChangeable (
/**
SampleUnitTestApp
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
- @retval EFI_SUCCESS The entry point executed successfully.
- @retval other Some error occured when executing this entry point.
+ @retval EFI_SUCCESS The entry point executed successfully.
+ @retval other Some error occured when executing this entry point.
**/
EFI_STATUS
@@ -162,56 +162,52 @@ SampleUnitTestApp (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
UNIT_TEST_FRAMEWORK *Fw = NULL;
UNIT_TEST_SUITE *SimpleMathTests, *GlobalVarTests;
- DEBUG(( DEBUG_INFO, "%s v%s\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION ));
+ DEBUG ((DEBUG_INFO, "%s v%s\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
//
// Start setting up the test framework for running the tests.
//
- Status = InitUnitTestFramework( &Fw, UNIT_TEST_APP_NAME, UNIT_TEST_APP_SHORT_NAME, UNIT_TEST_APP_VERSION );
- if (EFI_ERROR( Status ))
- {
- DEBUG((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
+ Status = InitUnitTestFramework (&Fw, UNIT_TEST_APP_NAME, UNIT_TEST_APP_SHORT_NAME, UNIT_TEST_APP_VERSION);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
goto EXIT;
}
//
// Populate the SimpleMathTests Unit Test Suite.
//
- Status = CreateUnitTestSuite( &SimpleMathTests, Fw, L"Simple Math Tests", L"Sample.Math", NULL, NULL );
- if (EFI_ERROR( Status ))
- {
- DEBUG((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SimpleMathTests\n"));
+ Status = CreateUnitTestSuite (&SimpleMathTests, Fw, L"Simple Math Tests", L"Sample.Math", NULL, NULL);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SimpleMathTests\n"));
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
- AddTestCase( SimpleMathTests, L"Adding 1 to 1 should produce 2", L"Sample.Math.Addition", OnePlusOneShouldEqualTwo, NULL, NULL, NULL );
+ AddTestCase (SimpleMathTests, L"Adding 1 to 1 should produce 2", L"Sample.Math.Addition", OnePlusOneShouldEqualTwo, NULL, NULL, NULL);
//
// Populate the GlobalVarTests Unit Test Suite.
//
- Status = CreateUnitTestSuite( &GlobalVarTests, Fw, L"Global Variable Tests", L"Sample.Globals", NULL, NULL );
- if (EFI_ERROR( Status ))
- {
- DEBUG((DEBUG_ERROR, "Failed in CreateUnitTestSuite for GlobalVarTests\n"));
+ Status = CreateUnitTestSuite (&GlobalVarTests, Fw, L"Global Variable Tests", L"Sample.Globals", NULL, NULL);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for GlobalVarTests\n"));
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
- AddTestCase( GlobalVarTests, L"You should be able to change a global BOOLEAN", L"Sample.Globals.Boolean", GlobalBooleanShouldBeChangeable, NULL, NULL, NULL );
- AddTestCase( GlobalVarTests, L"You should be able to change a global pointer", L"Sample.Globals.Pointer", GlobalPointerShouldBeChangeable, MakeSureThatPointerIsNull, ClearThePointer, NULL );
+ AddTestCase (GlobalVarTests, L"You should be able to change a global BOOLEAN", L"Sample.Globals.Boolean", GlobalBooleanShouldBeChangeable, NULL, NULL, NULL);
+ AddTestCase (GlobalVarTests, L"You should be able to change a global pointer", L"Sample.Globals.Pointer", GlobalPointerShouldBeChangeable, MakeSureThatPointerIsNull, ClearThePointer, NULL);
//
// Execute the tests.
//
- Status = RunAllTestSuites( Fw );
+ Status = RunAllTestSuites (Fw);
EXIT:
- if (Fw)
- {
- FreeUnitTestFramework( Fw );
+ if (Fw) {
+ FreeUnitTestFramework (Fw);
}
return Status;
--
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 ` [staging/edk2-test Patch 03/10] MsUnitTestPkg: Update for VS2017 and 32-bit apps Kinney, Michael D
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 ` Kinney, Michael D [this message]
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-11-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