diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc index 134384b11d2..ccd1adac1aa 100644 --- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc +++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc @@ -66,33 +66,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDisable|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE - } - # MU_CHANGE [END] - Add a host-based unit test for common variable services code. - - # MU_CHANGE [BEGIN] - Add a host-based unit test for common variable services code. - MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.inf { - - UefiLib|MdePkg/Test/Library/StubUefiLib/StubUefiLib.inf - VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf - VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf - TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf - AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf - DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf - UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf - DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf - UefiRuntimeServicesTableLib|MdePkg/Test/Library/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf - UefiBootServicesTableLib|MdePkg/Test/Library/MockUefiBootServicesTableLib/MockUefiBootServicesTableLib.inf - SynchronizationLib|MdePkg/Test/Library/SynchronizationLibHostUnitTest/SynchronizationLibHostUnitTest.inf - VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf - HobLib|MdePkg/Test/Library/StubHobLib/StubHobLib.inf - - VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf - NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf - NULL|MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLibVariableDxe.inf - - - gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDisable|TRUE - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE + # SCT tests are noisy, so disable VERBOSE. + gUnitTestFrameworkPkgTokenSpaceGuid.PcdUnitTestLogLevel|0x00000007 } # MU_CHANGE [END] - Add a host-based unit test for common variable services code. diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestConformance.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestConformance.c index 4109a112407..1ac20cdc6a1 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestConformance.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestConformance.c @@ -5,12 +5,12 @@ 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 + 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. - + **/ /*++ @@ -24,9 +24,10 @@ Module Name: #include "VariableServicesBBTestMain.h" + #if (EFI_SPECIFICATION_VERSION >= 0x0002000A) -extern EFI_GUID gGlobalVariableGuid; -extern EFI_GUID gHwErrRecGuid; +extern EFI_GUID gGlobalVariableGuid; +extern EFI_GUID gHwErrRecGuid; #endif // @@ -35,26 +36,26 @@ extern EFI_GUID gHwErrRecGuid; EFI_STATUS GetVariableConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); EFI_STATUS GetNextVariableNameConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); EFI_STATUS SetVariableConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -63,148 +64,149 @@ SetVariableConfTest ( EFI_STATUS GetVariableConfTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetVariableConfTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetVariableConfTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetVariableConfTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetVariableConfTestSub5 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetVariableConfTestSub6 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetVariableConfTestSub7 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetNextVariableNameConfTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetNextVariableNameConfTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetNextVariableNameConfTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetNextVariableNameConfTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetNextVariableNameConfTestSub5 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetNextVariableNameConfTestSub6 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetNextVariableNameConfTestSub7 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableConfTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableConfTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableConfTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableConfTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); #if (EFI_SPECIFICATION_VERSION >= 0x00020000) EFI_STATUS QueryVariableInfoConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); + // // QueryVariableInfo with MaximumVariableStorageSize being NULL // EFI_STATUS QueryVariableInfoConfTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ); // @@ -212,32 +214,35 @@ QueryVariableInfoConfTestSub1 ( // EFI_STATUS QueryVariableInfoConfTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ); + // // QueryVariableInfo with MaximumVariableSize being NULL // EFI_STATUS QueryVariableInfoConfTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ); + + // // QueryVariableInfo with Attributes being 0 // EFI_STATUS QueryVariableInfoConfTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ); // @@ -245,10 +250,10 @@ QueryVariableInfoConfTestSub4 ( // EFI_STATUS QueryVariableInfoConfTestSub5 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ); #endif @@ -268,10 +273,10 @@ QueryVariableInfoConfTestSub5 ( */ EFI_STATUS GetVariableConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -289,7 +294,7 @@ GetVariableConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -336,6 +341,7 @@ GetVariableConfTest ( return EFI_SUCCESS; } + /** * TDS 3.2 - Entry point for RT->GetNextVariableName() Conformance Test. * @param This A pointer to the EFI_BB_TEST_PROTOCOL instance. @@ -347,10 +353,10 @@ GetVariableConfTest ( */ EFI_STATUS GetNextVariableNameConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -368,7 +374,7 @@ GetNextVariableNameConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -414,6 +420,7 @@ GetNextVariableNameConfTest ( return EFI_SUCCESS; } + /** * TDS 3.3 - Entry point for RT->SetVariable() Conformance Test. * @param This A pointer to the EFI_BB_TEST_PROTOCOL instance. @@ -425,10 +432,10 @@ GetNextVariableNameConfTest ( */ EFI_STATUS SetVariableConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -446,7 +453,7 @@ SetVariableConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -494,15 +501,15 @@ SetVariableConfTest ( */ EFI_STATUS GetVariableConfTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -519,13 +526,13 @@ GetVariableConfTestSub1 ( // GetVariable should not succeed when VariableName is NULL // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - NULL, // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + NULL, // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + Data // Data + ); if (Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -543,8 +550,7 @@ GetVariableConfTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -564,6 +570,7 @@ GetVariableConfTestSub1 ( return EFI_SUCCESS; } + /** * GetVariable when VendorGuid is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -575,15 +582,15 @@ GetVariableConfTestSub1 ( */ EFI_STATUS GetVariableConfTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -600,13 +607,13 @@ GetVariableConfTestSub2 ( // GetVariable should not succeed when VendorGuid is NULL // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - NULL, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + NULL, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + Data // Data + ); if (Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -624,8 +631,7 @@ GetVariableConfTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -645,6 +651,7 @@ GetVariableConfTestSub2 ( return EFI_SUCCESS; } + /** * GetVariable when DataSize is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -656,15 +663,15 @@ GetVariableConfTestSub2 ( */ EFI_STATUS GetVariableConfTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -691,7 +698,7 @@ GetVariableConfTestSub3 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -741,8 +748,7 @@ GetVariableConfTestSub3 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -773,6 +779,7 @@ GetVariableConfTestSub3 ( return EFI_SUCCESS; } + /** * GetVariable when Data is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -784,16 +791,16 @@ GetVariableConfTestSub3 ( */ EFI_STATUS GetVariableConfTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -820,7 +827,7 @@ GetVariableConfTestSub4 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -847,13 +854,13 @@ GetVariableConfTestSub4 ( // GetVariable should not succeed when Data is NULL // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - NULL // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + NULL // Data + ); if (Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -871,8 +878,7 @@ GetVariableConfTestSub4 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -903,6 +909,7 @@ GetVariableConfTestSub4 ( return EFI_SUCCESS; } + /** * GetVariable with nonexistent VariableName. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -914,16 +921,16 @@ GetVariableConfTestSub4 ( */ EFI_STATUS GetVariableConfTestSub5 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -950,7 +957,7 @@ GetVariableConfTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -983,7 +990,7 @@ GetVariableConfTestSub5 ( 0, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1010,13 +1017,13 @@ GetVariableConfTestSub5 ( // GetVariable should not succeed with a nonexistent VariableName // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + Data // Data + ); if (Status == EFI_NOT_FOUND) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -1034,8 +1041,7 @@ GetVariableConfTestSub5 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); // @@ -1052,7 +1058,7 @@ GetVariableConfTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1082,7 +1088,7 @@ GetVariableConfTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1109,13 +1115,13 @@ GetVariableConfTestSub5 ( // GetVariable should not succeed with a nonexistent VariableName // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + Data // Data + ); if (Status == EFI_NOT_FOUND) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -1133,8 +1139,7 @@ GetVariableConfTestSub5 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); // @@ -1173,6 +1178,7 @@ GetVariableConfTestSub5 ( return Status; } + /** * GetVariable with nonexistent VendorGuid. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1184,16 +1190,16 @@ GetVariableConfTestSub5 ( */ EFI_STATUS GetVariableConfTestSub6 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -1212,7 +1218,6 @@ GetVariableConfTestSub6 ( for (DataIndex = 0; DataIndex < 10; DataIndex++) { Data[DataIndex] = (UINT8)DataIndex; } - Status = RT->SetVariable ( L"TestVariable", // VariableName &gTestVendor2Guid, // VendorGuid @@ -1220,7 +1225,7 @@ GetVariableConfTestSub6 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1247,13 +1252,13 @@ GetVariableConfTestSub6 ( // GetVariable should not succeed with a nonexistent VendorGuid // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + Data // Data + ); if (Status == EFI_NOT_FOUND) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -1271,8 +1276,7 @@ GetVariableConfTestSub6 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); // @@ -1303,6 +1307,7 @@ GetVariableConfTestSub6 ( return EFI_SUCCESS; } + /** * GetVariable without enough DataSize. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1314,16 +1319,16 @@ GetVariableConfTestSub6 ( */ EFI_STATUS GetVariableConfTestSub7 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -1350,7 +1355,7 @@ GetVariableConfTestSub7 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1377,16 +1382,15 @@ GetVariableConfTestSub7 ( // GetVariable should not succeed when DataSize is 0 // DataSize = 0; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + Data // Data + ); if ((Status == EFI_BUFFER_TOO_SMALL) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -1403,29 +1407,26 @@ GetVariableConfTestSub7 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_BUFFER_TOO_SMALL + Status, EFI_BUFFER_TOO_SMALL ); StandardLib->RecordMessage ( StandardLib, EFI_VERBOSE_LEVEL_DEFAULT, L"DataSize=%d, Expected=%d\n", - DataSize, - 10 + DataSize, 10 ); DataSize = 0; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - NULL // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + NULL // Data + ); if ((Status == EFI_BUFFER_TOO_SMALL) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -1442,32 +1443,29 @@ GetVariableConfTestSub7 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_BUFFER_TOO_SMALL + Status, EFI_BUFFER_TOO_SMALL ); StandardLib->RecordMessage ( StandardLib, EFI_VERBOSE_LEVEL_DEFAULT, L"DataSize=%d, Expected=%d\n", - DataSize, - 10 + DataSize, 10 ); // // GetVariable should not succeed when DataSize is required - 1 // DataSize = 9; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + Data // Data + ); if ((Status == EFI_BUFFER_TOO_SMALL) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -1484,16 +1482,14 @@ GetVariableConfTestSub7 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_BUFFER_TOO_SMALL + Status, EFI_BUFFER_TOO_SMALL ); StandardLib->RecordMessage ( StandardLib, EFI_VERBOSE_LEVEL_DEFAULT, L"DataSize=%d, Expected=%d\n", - DataSize, - 10 + DataSize, 10 ); // @@ -1524,6 +1520,7 @@ GetVariableConfTestSub7 ( return EFI_SUCCESS; } + /** * GetNextVariableName when VariableNameSize is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1535,15 +1532,15 @@ GetVariableConfTestSub7 ( */ EFI_STATUS GetNextVariableNameConfTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - CHAR16 VariableName[MAX_BUFFER_SIZE]; - EFI_GUID VendorGuid; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + CHAR16 VariableName[MAX_BUFFER_SIZE]; + EFI_GUID VendorGuid; // // Trace ... @@ -1560,11 +1557,11 @@ GetNextVariableNameConfTestSub1 ( // GetNextVariableName should not succeed when VariableNameSize is NULL // VariableName[0] = L'\0'; - Status = RT->GetNextVariableName ( - NULL, // VariableNameSize - VariableName, // VariableName - &VendorGuid // VendorGuid - ); + Status = RT->GetNextVariableName ( + NULL, // VariableNameSize + VariableName, // VariableName + &VendorGuid // VendorGuid + ); if (Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -1582,8 +1579,7 @@ GetNextVariableNameConfTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -1603,6 +1599,7 @@ GetNextVariableNameConfTestSub1 ( return EFI_SUCCESS; } + /** * GetNextVariableName when VariableName is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1614,15 +1611,15 @@ GetNextVariableNameConfTestSub1 ( */ EFI_STATUS GetNextVariableNameConfTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN VariableNameSize; - EFI_GUID VendorGuid; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN VariableNameSize; + EFI_GUID VendorGuid; // // Trace ... @@ -1639,11 +1636,11 @@ GetNextVariableNameConfTestSub2 ( // GetNextVariableName should not succeed when VariableNameSize is NULL // VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - NULL, // VariableName - &VendorGuid // VendorGuid - ); + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + NULL, // VariableName + &VendorGuid // VendorGuid + ); if (Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -1661,8 +1658,7 @@ GetNextVariableNameConfTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -1682,6 +1678,7 @@ GetNextVariableNameConfTestSub2 ( return EFI_SUCCESS; } + /** * GetNextVariableName when VendorGuid is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1693,15 +1690,15 @@ GetNextVariableNameConfTestSub2 ( */ EFI_STATUS GetNextVariableNameConfTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN VariableNameSize; - CHAR16 VariableName[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN VariableNameSize; + CHAR16 VariableName[MAX_BUFFER_SIZE]; // // Trace ... @@ -1717,13 +1714,13 @@ GetNextVariableNameConfTestSub3 ( // // GetNextVariableName should not succeed when VariableNameSize is NULL // - VariableName[0] = L'\0'; + VariableName[0] = L'\0'; VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - VariableName, // VariableName - NULL // VendorGuid - ); + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + VariableName, // VariableName + NULL // VendorGuid + ); if (Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -1741,8 +1738,7 @@ GetNextVariableNameConfTestSub3 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -1762,6 +1758,7 @@ GetNextVariableNameConfTestSub3 ( return EFI_SUCCESS; } + /** * GetNextVariableName without enough VariableNameSize. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1773,18 +1770,18 @@ GetNextVariableNameConfTestSub3 ( */ EFI_STATUS GetNextVariableNameConfTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - UINTN VariableNameSize; - CHAR16 VariableName[MAX_BUFFER_SIZE]; - EFI_GUID VendorGuid; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; + UINTN VariableNameSize; + CHAR16 VariableName[MAX_BUFFER_SIZE]; + EFI_GUID VendorGuid; // // Trace ... @@ -1811,7 +1808,7 @@ GetNextVariableNameConfTestSub4 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1838,13 +1835,13 @@ GetNextVariableNameConfTestSub4 ( // GetNextVariableName should not succeed when VariableNameSize is 2 // (The size of each variable should larger than 2.) // - VariableName[0] = L'\0'; + VariableName[0] = L'\0'; VariableNameSize = 2; - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - VariableName, // VariableName - &VendorGuid // VendorGuid - ); + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + VariableName, // VariableName + &VendorGuid // VendorGuid + ); if (Status == EFI_BUFFER_TOO_SMALL) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -1862,8 +1859,7 @@ GetNextVariableNameConfTestSub4 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_BUFFER_TOO_SMALL + Status, EFI_BUFFER_TOO_SMALL ); // @@ -1894,6 +1890,7 @@ GetNextVariableNameConfTestSub4 ( return EFI_SUCCESS; } + /** * GetNextVariableName after the entire variable list has been returned. * NOTES: Also check GetNextVariableName will not return deleted variable. @@ -1906,18 +1903,18 @@ GetNextVariableNameConfTestSub4 ( */ EFI_STATUS GetNextVariableNameConfTestSub5 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - UINTN VariableNameSize; - CHAR16 VariableName[MAX_BUFFER_SIZE]; - EFI_GUID VendorGuid; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; + UINTN VariableNameSize; + CHAR16 VariableName[MAX_BUFFER_SIZE]; + EFI_GUID VendorGuid; // // Trace ... @@ -1944,7 +1941,7 @@ GetNextVariableNameConfTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1977,7 +1974,7 @@ GetNextVariableNameConfTestSub5 ( 0, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2004,26 +2001,24 @@ GetNextVariableNameConfTestSub5 ( // Walk through all variables // VariableName[0] = L'\0'; - Result = EFI_TEST_ASSERTION_PASSED; + Result = EFI_TEST_ASSERTION_PASSED; while (TRUE) { VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - VariableName, // VariableName - &VendorGuid // VendorGuid - ); - if (EFI_ERROR (Status)) { + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + VariableName, // VariableName + &VendorGuid // VendorGuid + ); + if (EFI_ERROR(Status)) { if (Status != EFI_NOT_FOUND) { Result = EFI_TEST_ASSERTION_FAILED; } - break; } if ((SctStrCmp (VariableName, L"TestVariable") == 0) && - (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) - { + (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) { Result = EFI_TEST_ASSERTION_FAILED; break; } @@ -2040,8 +2035,7 @@ GetNextVariableNameConfTestSub5 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); // @@ -2061,6 +2055,7 @@ GetNextVariableNameConfTestSub5 ( return EFI_SUCCESS; } + /** * GetNextVariableName when a VariableName buffer on input is not a Null-terminated string. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2072,18 +2067,18 @@ GetNextVariableNameConfTestSub5 ( */ EFI_STATUS GetNextVariableNameConfTestSub6 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - UINTN VariableNameSize; - CHAR16 VariableName[MAX_BUFFER_SIZE]; - EFI_GUID VendorGuid; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; + UINTN VariableNameSize; + CHAR16 VariableName[MAX_BUFFER_SIZE]; + EFI_GUID VendorGuid; // // Trace ... @@ -2110,7 +2105,7 @@ GetNextVariableNameConfTestSub6 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2136,9 +2131,9 @@ GetNextVariableNameConfTestSub6 ( // // Walk through all variables // - VariableName[0] = L'\0'; + VariableName[0] = L'\0'; VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Result = EFI_TEST_ASSERTION_PASSED; + Result = EFI_TEST_ASSERTION_PASSED; while (TRUE) { Status = RT->GetNextVariableName ( @@ -2146,17 +2141,15 @@ GetNextVariableNameConfTestSub6 ( VariableName, // VariableName &VendorGuid // VendorGuid ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { if (Status != EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_FAILED; } - break; } if ((SctStrCmp (VariableName, L"TestVariable") == 0) && - (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) - { + (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) { VariableNameSize = 8; } else { VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); @@ -2174,8 +2167,7 @@ GetNextVariableNameConfTestSub6 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); Status = RT->SetVariable ( @@ -2186,7 +2178,7 @@ GetNextVariableNameConfTestSub6 ( Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2208,7 +2200,6 @@ GetNextVariableNameConfTestSub6 ( return Status; } - // // Trace ... // @@ -2237,18 +2228,18 @@ GetNextVariableNameConfTestSub6 ( */ EFI_STATUS GetNextVariableNameConfTestSub7 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - UINTN VariableNameSize; - CHAR16 VariableName[MAX_BUFFER_SIZE]; - EFI_GUID VendorGuid; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; + UINTN VariableNameSize; + CHAR16 VariableName[MAX_BUFFER_SIZE]; + EFI_GUID VendorGuid; // // Trace ... @@ -2275,7 +2266,7 @@ GetNextVariableNameConfTestSub7 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2302,27 +2293,25 @@ GetNextVariableNameConfTestSub7 ( // Walk through all variables // VariableName[0] = L'\0'; - + Result = EFI_TEST_ASSERTION_PASSED; while (TRUE) { - VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - VariableName, // VariableName - &VendorGuid // VendorGuid - ); - if (EFI_ERROR (Status)) { + VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + VariableName, // VariableName + &VendorGuid // VendorGuid + ); + if (EFI_ERROR(Status)) { if (Status != EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_FAILED; } - break; } if ((SctStrCmp (VariableName, L"TestVariable") == 0) && - (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) - { + (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) { VariableName[8] = L'e'; } } @@ -2338,35 +2327,32 @@ GetNextVariableNameConfTestSub7 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // // Walk through all variables // VariableName[0] = L'\0'; - + Result = EFI_TEST_ASSERTION_PASSED; while (TRUE) { - VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - VariableName, // VariableName - &VendorGuid // VendorGuid - ); - if (EFI_ERROR (Status)) { + VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + VariableName, // VariableName + &VendorGuid // VendorGuid + ); + if (EFI_ERROR(Status)) { if (Status != EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_FAILED; } - break; } if ((SctStrCmp (VariableName, L"TestVariable") == 0) && - (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) - { + (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) { VendorGuid = gTestVendor2Guid; } } @@ -2382,8 +2368,7 @@ GetNextVariableNameConfTestSub7 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); Status = RT->SetVariable ( @@ -2394,7 +2379,7 @@ GetNextVariableNameConfTestSub7 ( Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2416,7 +2401,6 @@ GetNextVariableNameConfTestSub7 ( return Status; } - // // Trace ... // @@ -2434,6 +2418,7 @@ GetNextVariableNameConfTestSub7 ( return EFI_SUCCESS; } + /** * SetVariable when VariableName is an empty string. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2445,15 +2430,15 @@ GetNextVariableNameConfTestSub7 ( */ EFI_STATUS SetVariableConfTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -2497,8 +2482,7 @@ SetVariableConfTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -2518,6 +2502,7 @@ SetVariableConfTestSub1 ( return EFI_SUCCESS; } + /** * SetVariable with invalid combination of attribute bits. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2529,25 +2514,25 @@ SetVariableConfTestSub1 ( */ EFI_STATUS SetVariableConfTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - - UINTN Index; - UINTN SubIndex; - UINTN SubIndex1; - EFI_TPL OldTpl; - EFI_STATUS ReturnedStatus; - UINTN DataSize; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 Attributes; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; + + UINTN Index; + UINTN SubIndex; + UINTN SubIndex1; + EFI_TPL OldTpl; + EFI_STATUS ReturnedStatus; + UINTN DataSize; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 Attributes; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -2593,8 +2578,7 @@ SetVariableConfTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -2628,8 +2612,7 @@ SetVariableConfTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -2648,14 +2631,14 @@ SetVariableConfTestSub2 ( } Attributes = AttributesArray[SubIndex]; - Status = RT->SetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - Attributes, // Attributes - 10, // DataSize - Data // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->SetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + Attributes, // Attributes + 10, // DataSize + Data // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2672,7 +2655,7 @@ SetVariableConfTestSub2 ( for (DataIndex = 0; DataIndex < 10; DataIndex++) { Data[DataIndex] = 10 - (UINT8)DataIndex; - } + } for (SubIndex1 = 0; SubIndex1 < 4; SubIndex1++) { if (Attributes != AttributesArray[SubIndex1]) { @@ -2681,7 +2664,7 @@ SetVariableConfTestSub2 ( ReturnedStatus = RT->SetVariable ( L"TestVariable", // VariableName &gTestVendor1Guid, // VendorGuid - AttributesArray[SubIndex1], // Attributes + AttributesArray[SubIndex1], // Attributes 10, // DataSize Data // Data ); @@ -2694,7 +2677,7 @@ SetVariableConfTestSub2 ( Result = EFI_TEST_ASSERTION_FAILED; } - DataSize = MAX_BUFFER_SIZE; + DataSize = MAX_BUFFER_SIZE; RT->GetVariable ( L"TestVariable", // VariableName &gTestVendor1Guid, // VendorGuid @@ -2709,11 +2692,10 @@ SetVariableConfTestSub2 ( for (DataIndex = 0; DataIndex < 10; DataIndex++) { if (Data[DataIndex] != (UINT8)DataIndex) { Result = EFI_TEST_ASSERTION_FAILED; - break; - } + break; + } } } - // // Record assertion // @@ -2728,6 +2710,7 @@ SetVariableConfTestSub2 ( ReturnedStatus, EFI_INVALID_PARAMETER ); + } } @@ -2740,6 +2723,7 @@ SetVariableConfTestSub2 ( Data // Data ); } + } } @@ -2760,6 +2744,7 @@ SetVariableConfTestSub2 ( return EFI_SUCCESS; } + /** * SetVariable with too large variable. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2771,15 +2756,15 @@ SetVariableConfTestSub2 ( */ EFI_STATUS SetVariableConfTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; if (LoggingLib != NULL) { LoggingLib->EnterFunction ( @@ -2820,8 +2805,7 @@ SetVariableConfTestSub3 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -2852,21 +2836,21 @@ SetVariableConfTestSub3 ( */ EFI_STATUS SetVariableConfTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_STATUS ReturnedStatus; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_STATUS ReturnedStatus; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -2906,7 +2890,7 @@ SetVariableConfTestSub4 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2939,7 +2923,7 @@ SetVariableConfTestSub4 ( // // Delete the variable again to check results // - + Status = RT->SetVariable ( L"TestVariable", // VariableName &gTestVendor1Guid, // VendorGuid @@ -2951,9 +2935,8 @@ SetVariableConfTestSub4 ( // // Check results // - if ((ReturnedStatus == EFI_SUCCESS) && - (Status == EFI_NOT_FOUND)) - { + if ((ReturnedStatus == EFI_SUCCESS ) && + (Status == EFI_NOT_FOUND)) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -2970,16 +2953,14 @@ SetVariableConfTestSub4 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( StandardLib, EFI_VERBOSE_LEVEL_DEFAULT, L"SetVariable: Status - %r, Expected - %r\n", - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); } } @@ -3007,10 +2988,10 @@ SetVariableConfTestSub4 ( // EFI_STATUS QueryVariableInfoConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -3028,12 +3009,12 @@ QueryVariableInfoConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } // if (FALSE == CheckBBTestCanRunAndRecordAssertion( - // StandardLib, + // StandardLib, // L"RT.QueryVariableInfo_Conf - QueryVariableInfo_Conf it's not Supported in EFI", // __FILE__, // (UINTN)__LINE__ @@ -3042,7 +3023,7 @@ QueryVariableInfoConfTest ( // } RT = (EFI_RUNTIME_SERVICES *)ClientInterface; - #if 0 +#if 0 // // QueryVariableInfo with MaximumVariableStorageSize being NULL // @@ -3057,44 +3038,45 @@ QueryVariableInfoConfTest ( // QueryVariableInfo with MaximumVariableSize being NULL // Status = QueryVariableInfoConfTestSub3 (RT, StandardLib, LoggingLib, SupportHandle); - #endif +#endif // // QueryVariableInfo with Attributes being 0 // Status = QueryVariableInfoConfTestSub4 (RT, StandardLib, LoggingLib, SupportHandle); - + // - // QueryVariableInfo with Attributes being an invalid combination + // QueryVariableInfo with Attributes being an invalid combination // Status = QueryVariableInfoConfTestSub5 (RT, StandardLib, LoggingLib, SupportHandle); return EFI_SUCCESS; } + // // QueryVariableInfo with MaximumVariableStorageSize being NULL // EFI_STATUS QueryVariableInfoConfTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ) { - EFI_STATUS Status; - UINT32 ValidAttributes[] = { - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, - EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_BOOTSERVICE_ACCESS, - 0 - }; - // UINT64 MaximumVariableStorageSize; - UINT64 RemainingVariableStorageSize; - UINT64 MaximumVariableSize; - EFI_TEST_ASSERTION Result; - UINTN Index; + EFI_STATUS Status; + UINT32 ValidAttributes[] = { + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, + EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_BOOTSERVICE_ACCESS, + 0 + }; + //UINT64 MaximumVariableStorageSize; + UINT64 RemainingVariableStorageSize; + UINT64 MaximumVariableSize; + EFI_TEST_ASSERTION Result; + UINTN Index; // // Trace ... @@ -3107,8 +3089,8 @@ QueryVariableInfoConfTestSub1 ( ); } - // if(1) return EFI_SUCCESS; - for (Index = 0; ValidAttributes[Index] != 0; Index++) { +// if(1) return EFI_SUCCESS; + for (Index = 0; ValidAttributes[Index] != 0; Index ++) { Status = RT->QueryVariableInfo ( ValidAttributes[Index], NULL, @@ -3116,7 +3098,7 @@ QueryVariableInfoConfTestSub1 ( &MaximumVariableSize ); - if (Status == EFI_UNSUPPORTED) { + if(Status == EFI_UNSUPPORTED) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3137,6 +3119,7 @@ QueryVariableInfoConfTestSub1 ( EFI_UNSUPPORTED, ValidAttributes[Index] ); + } // @@ -3161,25 +3144,25 @@ QueryVariableInfoConfTestSub1 ( // EFI_STATUS QueryVariableInfoConfTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ) { - EFI_STATUS Status; - UINT32 ValidAttributes[] = { - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, - EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_BOOTSERVICE_ACCESS, - 0 - }; - UINT64 MaximumVariableStorageSize; - // UINT64 RemainingVariableStorageSize; - UINT64 MaximumVariableSize; - EFI_TEST_ASSERTION Result; - UINTN Index; + EFI_STATUS Status; + UINT32 ValidAttributes[] = { + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, + EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_BOOTSERVICE_ACCESS, + 0 + }; + UINT64 MaximumVariableStorageSize; + //UINT64 RemainingVariableStorageSize; + UINT64 MaximumVariableSize; + EFI_TEST_ASSERTION Result; + UINTN Index; // // Trace ... @@ -3192,7 +3175,7 @@ QueryVariableInfoConfTestSub2 ( ); } - for (Index = 0; ValidAttributes[Index] != 0; Index++) { + for (Index = 0; ValidAttributes[Index] != 0; Index ++) { Status = RT->QueryVariableInfo ( ValidAttributes[Index], &MaximumVariableStorageSize, @@ -3200,7 +3183,7 @@ QueryVariableInfoConfTestSub2 ( &MaximumVariableSize ); - if (Status == EFI_UNSUPPORTED) { + if(Status == EFI_UNSUPPORTED) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3221,6 +3204,7 @@ QueryVariableInfoConfTestSub2 ( EFI_UNSUPPORTED, ValidAttributes[Index] ); + } // @@ -3240,30 +3224,31 @@ QueryVariableInfoConfTestSub2 ( return EFI_SUCCESS; } + // // QueryVariableInfo with MaximumVariableSize being NULL // EFI_STATUS QueryVariableInfoConfTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ) { - EFI_STATUS Status; - UINT32 ValidAttributes[] = { - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, - EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_BOOTSERVICE_ACCESS, - 0 - }; - UINT64 MaximumVariableStorageSize; - UINT64 RemainingVariableStorageSize; - // UINT64 MaximumVariableSize; - EFI_TEST_ASSERTION Result; - UINTN Index; + EFI_STATUS Status; + UINT32 ValidAttributes[] = { + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, + EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_BOOTSERVICE_ACCESS, + 0 + }; + UINT64 MaximumVariableStorageSize; + UINT64 RemainingVariableStorageSize; + //UINT64 MaximumVariableSize; + EFI_TEST_ASSERTION Result; + UINTN Index; // // Trace ... @@ -3276,7 +3261,7 @@ QueryVariableInfoConfTestSub3 ( ); } - for (Index = 0; ValidAttributes[Index] != 0; Index++) { + for (Index = 0; ValidAttributes[Index] != 0; Index ++) { Status = RT->QueryVariableInfo ( ValidAttributes[Index], &MaximumVariableStorageSize, @@ -3284,7 +3269,7 @@ QueryVariableInfoConfTestSub3 ( NULL ); - if (Status == EFI_UNSUPPORTED) { + if(Status == EFI_UNSUPPORTED) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3305,6 +3290,7 @@ QueryVariableInfoConfTestSub3 ( EFI_UNSUPPORTED, ValidAttributes[Index] ); + } // @@ -3324,22 +3310,24 @@ QueryVariableInfoConfTestSub3 ( return EFI_SUCCESS; } + + // // QueryVariableInfo with Attributes being 0 // EFI_STATUS QueryVariableInfoConfTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ) { - EFI_STATUS Status; - UINT64 MaximumVariableStorageSize; - UINT64 RemainingVariableStorageSize; - UINT64 MaximumVariableSize; - EFI_TEST_ASSERTION Result; + EFI_STATUS Status; + UINT64 MaximumVariableStorageSize; + UINT64 RemainingVariableStorageSize; + UINT64 MaximumVariableSize; + EFI_TEST_ASSERTION Result; // // Trace ... @@ -3359,7 +3347,7 @@ QueryVariableInfoConfTestSub4 ( &MaximumVariableSize ); - if (Status == EFI_INVALID_PARAMETER) { + if(Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3402,24 +3390,24 @@ QueryVariableInfoConfTestSub4 ( // EFI_STATUS QueryVariableInfoConfTestSub5 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ) { - EFI_STATUS Status; - UINT32 InvalidAttributes[] = { - EFI_VARIABLE_NON_VOLATILE, - EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_RUNTIME_ACCESS, - 0 - }; - UINT64 MaximumVariableStorageSize; - UINT64 RemainingVariableStorageSize; - UINT64 MaximumVariableSize; - EFI_TEST_ASSERTION Result; - UINTN Index; + EFI_STATUS Status; + UINT32 InvalidAttributes[] = { + EFI_VARIABLE_NON_VOLATILE, + EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_RUNTIME_ACCESS, + 0 + }; + UINT64 MaximumVariableStorageSize; + UINT64 RemainingVariableStorageSize; + UINT64 MaximumVariableSize; + EFI_TEST_ASSERTION Result; + UINTN Index; // // Trace ... @@ -3432,7 +3420,8 @@ QueryVariableInfoConfTestSub5 ( ); } - for (Index = 0; InvalidAttributes[Index] != 0; Index++) { + for (Index = 0; InvalidAttributes[Index] != 0; Index ++) { + Status = RT->QueryVariableInfo ( InvalidAttributes[Index], &MaximumVariableStorageSize, @@ -3440,7 +3429,7 @@ QueryVariableInfoConfTestSub5 ( &MaximumVariableSize ); - if (Status == EFI_INVALID_PARAMETER) { + if(Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3461,6 +3450,7 @@ QueryVariableInfoConfTestSub5 ( EFI_INVALID_PARAMETER, InvalidAttributes[Index] ); + } // @@ -3479,17 +3469,16 @@ QueryVariableInfoConfTestSub5 ( // return EFI_SUCCESS; } - #endif #if (EFI_SPECIFICATION_VERSION >= 0x0002000A) EFI_STATUS HardwareErrorRecordConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status, Status2; @@ -3497,39 +3486,40 @@ HardwareErrorRecordConfTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; - - CHAR16 *HwErrRecName = L"HwErrRecSupport"; - UINT16 HwErrRecSupportVariable; - UINTN DataSize; - - UINT32 Attributes = EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS - |EFI_VARIABLE_RUNTIME_ACCESS|EFI_VARIABLE_HARDWARE_ERROR_RECORD; - UINT64 MaximumVariableStorageSize; - UINT64 RemainingVariableStorageSize; - UINT64 MaximumVariableSize; - - CHAR16 HwErrRecVariableName[13]; - CHAR16 HwErrRecVariable[] = L"This is a HwErrRec variable!"; - - CHAR16 GetVariableName[MAX_BUFFER_SIZE]; - UINTN VariableNameSize; - EFI_GUID VendorGuid; - CHAR16 *P = NULL; - - UINTN Num; - UINTN MaxNum = 0; - CHAR16 ErrorNum[5]; - - UINT32 InvalidAttributes[] = { - EFI_VARIABLE_HARDWARE_ERROR_RECORD | EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_HARDWARE_ERROR_RECORD | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, - 0 - }; - - UINTN Index; - - EFI_TEST_ASSERTION AssertionType; - + + CHAR16 *HwErrRecName = L"HwErrRecSupport"; + UINT16 HwErrRecSupportVariable; + UINTN DataSize; + + UINT32 Attributes = EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS + |EFI_VARIABLE_RUNTIME_ACCESS|EFI_VARIABLE_HARDWARE_ERROR_RECORD; + UINT64 MaximumVariableStorageSize; + UINT64 RemainingVariableStorageSize; + UINT64 MaximumVariableSize; + + CHAR16 HwErrRecVariableName[13]; + CHAR16 HwErrRecVariable[] = L"This is a HwErrRec variable!"; + + CHAR16 GetVariableName[MAX_BUFFER_SIZE]; + UINTN VariableNameSize; + EFI_GUID VendorGuid; + CHAR16 *P = NULL; + + UINTN Num; + UINTN MaxNum = 0; + CHAR16 ErrorNum[5]; + + UINT32 InvalidAttributes[] = { + EFI_VARIABLE_HARDWARE_ERROR_RECORD | EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_HARDWARE_ERROR_RECORD | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE, + 0 + }; + + UINTN Index; + + EFI_TEST_ASSERTION AssertionType; + + // // Get test support library interfaces // @@ -3539,7 +3529,7 @@ HardwareErrorRecordConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -3552,203 +3542,198 @@ HardwareErrorRecordConfTest ( L"TDS" ); } - + // // Check if the platform implements support for Hardware Error Record Persistence // - DataSize = sizeof (HwErrRecSupportVariable); + DataSize = sizeof( HwErrRecSupportVariable ); HwErrRecSupportVariable = 0xFFFF; - Status = RT->GetVariable ( - HwErrRecName, - &gGlobalVariableGuid, - NULL, - &DataSize, - &HwErrRecSupportVariable - ); - + Status = RT->GetVariable ( + HwErrRecName, + &gGlobalVariableGuid, + NULL, + &DataSize, + &HwErrRecSupportVariable + ); + StandardLib->RecordMessage ( - StandardLib, - EFI_VERBOSE_LEVEL_DEFAULT, - L"\r\nGetVariable() to get the HwErrRecSupport : %r %d", - Status, - HwErrRecSupportVariable - ); + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nGetVariable() to get the HwErrRecSupport : %r %d", + Status, + HwErrRecSupportVariable + ); - if ((EFI_SUCCESS != Status) || !HwErrRecSupportVariable ) { + + if ( EFI_SUCCESS != Status || !HwErrRecSupportVariable ) { return Status; } - + // // Query the variable info // Status = RT->QueryVariableInfo ( - Attributes, - &MaximumVariableStorageSize, - &RemainingVariableStorageSize, - &MaximumVariableSize - ); + Attributes, + &MaximumVariableStorageSize, + &RemainingVariableStorageSize, + &MaximumVariableSize + ); StandardLib->RecordMessage ( - StandardLib, - EFI_VERBOSE_LEVEL_DEFAULT, - L"\r\n Query the variable info : MaximumVariableStorageSize - %d, RemainingVariableStorageSize - %d, MaximumVariableSize - %d", - MaximumVariableStorageSize, - RemainingVariableStorageSize, - MaximumVariableSize - ); - - if ((Status != EFI_SUCCESS) || (RemainingVariableStorageSize <= 0)) { + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\n Query the variable info : MaximumVariableStorageSize - %d, RemainingVariableStorageSize - %d, MaximumVariableSize - %d", + MaximumVariableStorageSize, + RemainingVariableStorageSize, + MaximumVariableSize + ); + + if ( Status != EFI_SUCCESS || RemainingVariableStorageSize <= 0 ) { return Status; } - + // // Get a useable variable name // GetVariableName[0] = L'\0'; - ErrorNum[4] = L'\0'; - AssertionType = EFI_TEST_ASSERTION_PASSED; + ErrorNum[4] = L'\0'; + AssertionType = EFI_TEST_ASSERTION_PASSED; while (TRUE) { VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - GetVariableName, // VariableName - &VendorGuid // VendorGuid - ); - + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + GetVariableName, // VariableName + &VendorGuid // VendorGuid + ); + StandardLib->RecordMessage ( - StandardLib, - EFI_VERBOSE_LEVEL_DEFAULT, - L"\r\nGetNextVariableName() to get the variable name : %s - %r", - GetVariableName, - Status - ); + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nGetNextVariableName() to get the variable name : %s - %r", + GetVariableName, + Status + ); if ( EFI_SUCCESS != Status ) { break; } - if ((SctStrnCmp (GetVariableName, L"HwErrRec", 8) == 0) && - (SctCompareGuid (&VendorGuid, &gHwErrRecGuid) == 0)) - { + if ( (SctStrnCmp (GetVariableName, L"HwErrRec", 8) == 0) && + (SctCompareGuid (&VendorGuid, &gHwErrRecGuid) == 0) ) { P = GetVariableName; - if (SctStrLen (P) == 12) { - P = GetVariableName; - if ((((P[8] >= '0') && (P[8] <= '9')) || ((P[8] >= 'A') && (P[8] <= 'F')) || ((P[8] >= 'a') && (P[8] <= 'f'))) && - (((P[9] >= '0') && (P[9] <= '9')) || ((P[9] >= 'A') && (P[9] <= 'F')) || ((P[9] >= 'a') && (P[9] <= 'f'))) && - (((P[10] >= '0') && (P[10] <= '9')) || ((P[10] >= 'A') && (P[10] <= 'F')) || ((P[10] >= 'a') && (P[10] <= 'f'))) && - (((P[11] >= '0') && (P[11] <= '9')) || ((P[11] >= 'A') && (P[11] <= 'F')) || ((P[11] >= 'a') && (P[11] <= 'f')))) - { + if (SctStrLen(P) == 12) { + P = GetVariableName; + if (((P[8] >= '0' && P[8] <= '9') || (P[8] >= 'A' && P[8] <= 'F') || (P[8] >= 'a' && P[8] <= 'f')) && + ((P[9] >= '0' && P[9] <= '9') || (P[9] >= 'A' && P[9] <= 'F') || (P[9] >= 'a' && P[9] <= 'f')) && + ((P[10] >= '0' && P[10] <= '9') || (P[10] >= 'A' && P[10] <= 'F') || (P[10] >= 'a' && P[10] <= 'f')) && + ((P[11] >= '0' && P[11] <= '9') || (P[11] >= 'A' && P[11] <= 'F') || (P[11] >= 'a' && P[11] <= 'f'))) { AssertionType = EFI_TEST_ASSERTION_PASSED; - } else { + } else { AssertionType = EFI_TEST_ASSERTION_FAILED; - break; + break; } - } else { + } else { AssertionType = EFI_TEST_ASSERTION_FAILED; break; - } + } - SctStrnCpy (ErrorNum, &GetVariableName[8], 4); + SctStrnCpy (ErrorNum, &GetVariableName[8], 4); Num = SctXtoi (ErrorNum); - if (MaxNum < Num) { + if (MaxNum < Num) MaxNum = Num; - } } } - if (P != NULL) { + if (P != NULL) StandardLib->RecordAssertion ( - StandardLib, - AssertionType, - gHwErrRecBbTestAssertionGuid004, - L"RT.SetVariable - Retrive the Hardware Error Record variables, check the name of them", - L"%a:%d:Status - %r, Expected - %r", - __FILE__, - (UINTN)__LINE__, - Status, - EFI_SUCCESS - ); - } + StandardLib, + AssertionType, + gHwErrRecBbTestAssertionGuid004, + L"RT.SetVariable - Retrive the Hardware Error Record variables, check the name of them", + L"%a:%d:Status - %r, Expected - %r", + __FILE__, + (UINTN)__LINE__, + Status, + EFI_SUCCESS + ); + - if (AssertionType == EFI_TEST_ASSERTION_FAILED) { + if (AssertionType == EFI_TEST_ASSERTION_FAILED) return EFI_SUCCESS; - } MaxNum++; - + HwErrRecVariableName[0] = L'\0'; - SctStrCat (HwErrRecVariableName, L"HwErrRec"); - Myitox (MaxNum, HwErrRecVariableName+8); - + SctStrCat ( HwErrRecVariableName, L"HwErrRec" ); + Myitox( MaxNum, HwErrRecVariableName+8 ); + // // Call SetVariable with invalid attributes // - for ( Index = 0; InvalidAttributes[Index]; Index++ ) { + for ( Index=0; InvalidAttributes[Index]; Index++ ) { Status = RT->SetVariable ( - HwErrRecVariableName, - &gHwErrRecGuid, - InvalidAttributes[Index], - DataSize, - HwErrRecVariable - ); - if ((Status == EFI_INVALID_PARAMETER)) { + HwErrRecVariableName, + &gHwErrRecGuid, + InvalidAttributes[Index], + DataSize, + HwErrRecVariable + ); + if ( (Status == EFI_INVALID_PARAMETER) ) { AssertionType = EFI_TEST_ASSERTION_PASSED; } else { AssertionType = EFI_TEST_ASSERTION_FAILED; } - StandardLib->RecordAssertion ( - StandardLib, - AssertionType, - gHwErrRecBbTestAssertionGuid002, - L"RT.SetVariable - With invalid attributes and attributes has EFI_VARIABLE_HARDWARE_ERROR_RECORD", - L"%a:%d:Status - %r, Expected - %r", - __FILE__, - (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER - ); + StandardLib, + AssertionType, + gHwErrRecBbTestAssertionGuid002, + L"RT.SetVariable - With invalid attributes and attributes has EFI_VARIABLE_HARDWARE_ERROR_RECORD", + L"%a:%d:Status - %r, Expected - %r", + __FILE__, + (UINTN)__LINE__, + Status, EFI_INVALID_PARAMETER + ); } - + // // Set the new HwErrRec variable to the global variable // - DataSize = sizeof (HwErrRecVariable); - Status = RT->SetVariable ( - HwErrRecVariableName, - &gHwErrRecGuid, - Attributes, - DataSize, - HwErrRecVariable - ); - if ( EFI_ERROR (Status)) { + DataSize = sizeof( HwErrRecVariable ); + Status = RT->SetVariable ( + HwErrRecVariableName, + &gHwErrRecGuid, + Attributes, + DataSize, + HwErrRecVariable + ); + if ( EFI_ERROR(Status) ) { return Status; } - + // // Delete the HwErrRecVariable // Status = RT->SetVariable ( - HwErrRecVariableName, - &gHwErrRecGuid, - Attributes, - 0, - HwErrRecVariable - ); + HwErrRecVariableName, + &gHwErrRecGuid, + Attributes, + 0, + HwErrRecVariable + ); // // Delete the HwErrRecVariable again // Status2 = RT->SetVariable ( - HwErrRecVariableName, - &gHwErrRecGuid, - Attributes, - 0, - HwErrRecVariable - ); - - if ((Status == EFI_SUCCESS) && (Status2 == EFI_NOT_FOUND)) { + HwErrRecVariableName, + &gHwErrRecGuid, + Attributes, + 0, + HwErrRecVariable + ); + + if ( (Status == EFI_SUCCESS) && (Status2 == EFI_NOT_FOUND) ) { AssertionType = EFI_TEST_ASSERTION_PASSED; } else { AssertionType = EFI_TEST_ASSERTION_FAILED; @@ -3758,16 +3743,15 @@ HardwareErrorRecordConfTest ( // Record assertion & message // StandardLib->RecordAssertion ( - StandardLib, - AssertionType, - gHwErrRecBbTestAssertionGuid003, - L"RT.SetVariable - With DataSize is 0 and attributes has EFI_VARIABLE_HARDWARE_ERROR_RECORD", - L"%a:%d:Status - %r, Expected - %r", - __FILE__, - (UINTN)__LINE__, - Status2, - EFI_NOT_FOUND - ); + StandardLib, + AssertionType, + gHwErrRecBbTestAssertionGuid003, + L"RT.SetVariable - With DataSize is 0 and attributes has EFI_VARIABLE_HARDWARE_ERROR_RECORD", + L"%a:%d:Status - %r, Expected - %r", + __FILE__, + (UINTN)__LINE__, + Status2, EFI_NOT_FOUND + ); // // Return diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestFunction.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestFunction.c index 76466583aef..7edd8482632 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestFunction.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestFunction.c @@ -5,12 +5,12 @@ 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 + 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. - + **/ /*++ @@ -32,26 +32,26 @@ Module Name: EFI_STATUS GetVariableFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); EFI_STATUS GetNextVariableNameFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); EFI_STATUS SetVariableFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -60,88 +60,88 @@ SetVariableFuncTest ( EFI_STATUS GetVariableFuncTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS GetNextVariableNameFuncTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableFuncTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableFuncTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableFuncTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableFuncTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableFuncTestSub5 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableFuncTestSub6 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS SetVariableFuncTestSub7 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); #if (EFI_SPECIFICATION_VERSION >= 0x00020000) EFI_STATUS QueryVariableInfoFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // -// QueryVariableInfo must succeed with a valid Attributes and +// QueryVariableInfo must succeed with a valid Attributes and // return the proper value when it is in Boot time // EFI_STATUS QueryVariableInfoFuncTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ); #endif @@ -166,10 +166,10 @@ QueryVariableInfoFuncTestSub1 ( */ EFI_STATUS GetVariableFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -187,7 +187,7 @@ GetVariableFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -204,6 +204,7 @@ GetVariableFuncTest ( return EFI_SUCCESS; } + /** * TDS 4.2 - Entry point for RT->GetNextVariableName() Function Test. * @param This A pointer to the EFI_BB_TEST_PROTOCOL instance. @@ -215,10 +216,10 @@ GetVariableFuncTest ( */ EFI_STATUS GetNextVariableNameFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -236,7 +237,7 @@ GetNextVariableNameFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -253,6 +254,7 @@ GetNextVariableNameFuncTest ( return EFI_SUCCESS; } + /** * TDS 4.3 - Entry point for RT->SetVariable() Function Test. * @param This A pointer to the EFI_BB_TEST_PROTOCOL instance. @@ -264,10 +266,10 @@ GetNextVariableNameFuncTest ( */ EFI_STATUS SetVariableFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -275,7 +277,6 @@ SetVariableFuncTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; - // UINTN RecoveryDataSize; // UINT8 *RecoveryData; @@ -288,7 +289,7 @@ SetVariableFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -375,6 +376,7 @@ SetVariableFuncTest ( return EFI_SUCCESS; } + /** * GetVariable when the variable exists. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -386,22 +388,22 @@ SetVariableFuncTest ( */ EFI_STATUS GetVariableFuncTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - UINT32 Attributes; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + UINT32 Attributes; + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -441,7 +443,7 @@ GetVariableFuncTestSub1 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -462,13 +464,13 @@ GetVariableFuncTestSub1 ( OldTpl = gtBS->RaiseTPL (TplArray[Index]); DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - NULL, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + NULL, // Attributes + &DataSize, // DataSize + Data // Data + ); gtBS->RestoreTPL (OldTpl); @@ -476,8 +478,7 @@ GetVariableFuncTestSub1 ( // Check results // if ((Status == EFI_SUCCESS) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -502,8 +503,7 @@ GetVariableFuncTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -511,10 +511,8 @@ GetVariableFuncTestSub1 ( EFI_VERBOSE_LEVEL_DEFAULT, L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - DataSize, - 10, - Data[0], - 0 + DataSize, 10, + Data[0], 0 ); // @@ -523,23 +521,22 @@ GetVariableFuncTestSub1 ( OldTpl = gtBS->RaiseTPL (TplArray[Index]); DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); gtBS->RestoreTPL (OldTpl); // // Check results // - if ((Status == EFI_SUCCESS) && + if ((Status == EFI_SUCCESS ) && (Attributes == AttributesArray[SubIndex]) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -564,8 +561,7 @@ GetVariableFuncTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -574,12 +570,9 @@ GetVariableFuncTestSub1 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 10, - Data[0], - 0 + Attributes, AttributesArray[SubIndex], + DataSize, 10, + Data[0], 0 ); // @@ -612,6 +605,7 @@ GetVariableFuncTestSub1 ( return EFI_SUCCESS; } + /** * GetNextVariableName when the next variable exists. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -623,23 +617,23 @@ GetVariableFuncTestSub1 ( */ EFI_STATUS GetNextVariableNameFuncTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - UINTN VariableNameSize; - CHAR16 VariableName[MAX_BUFFER_SIZE]; - EFI_GUID VendorGuid; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; + UINTN VariableNameSize; + CHAR16 VariableName[MAX_BUFFER_SIZE]; + EFI_GUID VendorGuid; + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -679,7 +673,7 @@ GetNextVariableNameFuncTestSub1 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -698,27 +692,26 @@ GetNextVariableNameFuncTestSub1 ( // Walk through the entire variable list // VariableName[0] = L'\0'; - Result = EFI_TEST_ASSERTION_FAILED; + Result = EFI_TEST_ASSERTION_FAILED; while (TRUE) { OldTpl = gtBS->RaiseTPL (TplArray[Index]); VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - VariableName, // VariableName - &VendorGuid // VendorGuid - ); + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + VariableName, // VariableName + &VendorGuid // VendorGuid + ); gtBS->RestoreTPL (OldTpl); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { break; } if ((SctStrCmp (VariableName, L"TestVariable") == 0) && - (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) - { + (SctCompareGuid (&VendorGuid, &gTestVendor1Guid) == 0)) { Result = EFI_TEST_ASSERTION_PASSED; break; } @@ -770,6 +763,7 @@ GetNextVariableNameFuncTestSub1 ( return EFI_SUCCESS; } + /** * SetVariable when the variable does not exist. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -781,25 +775,25 @@ GetNextVariableNameFuncTestSub1 ( */ EFI_STATUS SetVariableFuncTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_STATUS ReturnedStatus; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - UINTN DataSize2; - UINT8 Data2[MAX_BUFFER_SIZE]; - UINT32 Attributes; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_STATUS ReturnedStatus; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + UINTN DataSize2; + UINT8 Data2[MAX_BUFFER_SIZE]; + UINT32 Attributes; + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -839,7 +833,7 @@ SetVariableFuncTestSub1 ( 20, // DataSize Data2 // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -877,14 +871,14 @@ SetVariableFuncTestSub1 ( // Get the variable to check results // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -903,14 +897,14 @@ SetVariableFuncTestSub1 ( // Get the variable with GUID2 to check results // DataSize2 = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor2Guid, // VendorGuid - NULL, // Attributes - &DataSize2, // DataSize - Data2 // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor2Guid, // VendorGuid + NULL, // Attributes + &DataSize2, // DataSize + Data2 // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -928,11 +922,10 @@ SetVariableFuncTestSub1 ( // // Check the results // - if ((ReturnedStatus == EFI_SUCCESS) && + if ((ReturnedStatus == EFI_SUCCESS ) && (Attributes == AttributesArray[SubIndex]) && - (DataSize == 10) && - (DataSize2 == 20)) - { + (DataSize == 10 ) && + (DataSize2 == 20 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -964,8 +957,7 @@ SetVariableFuncTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -974,12 +966,9 @@ SetVariableFuncTestSub1 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 10, - Data[0], - 0 + Attributes, AttributesArray[SubIndex], + DataSize, 10, + Data[0], 0 ); // @@ -992,7 +981,7 @@ SetVariableFuncTestSub1 ( 0, // DataSize Data // Data ); - + Status = RT->SetVariable ( L"TestVariable", // VariableName &gTestVendor2Guid, // VendorGuid @@ -1000,6 +989,7 @@ SetVariableFuncTestSub1 ( 0, // DataSize Data // Data ); + } } @@ -1020,6 +1010,7 @@ SetVariableFuncTestSub1 ( return EFI_SUCCESS; } + /** * SetVariable when the variable exists. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1031,23 +1022,23 @@ SetVariableFuncTestSub1 ( */ EFI_STATUS SetVariableFuncTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_STATUS ReturnedStatus; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - UINT32 Attributes; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_STATUS ReturnedStatus; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + UINT32 Attributes; + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -1087,7 +1078,7 @@ SetVariableFuncTestSub2 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1125,14 +1116,14 @@ SetVariableFuncTestSub2 ( // Get the variable to check results // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1150,10 +1141,9 @@ SetVariableFuncTestSub2 ( // // Check the results // - if ((ReturnedStatus == EFI_SUCCESS) && + if ((ReturnedStatus == EFI_SUCCESS ) && (Attributes == AttributesArray[SubIndex]) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -1178,8 +1168,7 @@ SetVariableFuncTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -1188,12 +1177,9 @@ SetVariableFuncTestSub2 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 10, - Data[0], - 0 + Attributes, AttributesArray[SubIndex], + DataSize, 10, + Data[0], 0 ); // @@ -1219,14 +1205,14 @@ SetVariableFuncTestSub2 ( // Get the variable to check results // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1244,10 +1230,9 @@ SetVariableFuncTestSub2 ( // // Check the results // - if ((ReturnedStatus == EFI_SUCCESS) && + if ((ReturnedStatus == EFI_SUCCESS ) && (Attributes == AttributesArray[SubIndex]) && - (DataSize == 20)) - { + (DataSize == 20 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 20; DataIndex++) { @@ -1272,8 +1257,7 @@ SetVariableFuncTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -1282,12 +1266,9 @@ SetVariableFuncTestSub2 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 20, - Data[0], - 1 + Attributes, AttributesArray[SubIndex], + DataSize, 20, + Data[0], 1 ); // @@ -1313,14 +1294,14 @@ SetVariableFuncTestSub2 ( // Get the variable to check results // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1338,10 +1319,9 @@ SetVariableFuncTestSub2 ( // // Check the results // - if ((ReturnedStatus == EFI_SUCCESS) && + if ((ReturnedStatus == EFI_SUCCESS ) && (Attributes == AttributesArray[SubIndex]) && - (DataSize == 5)) - { + (DataSize == 5 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 5; DataIndex++) { @@ -1366,8 +1346,7 @@ SetVariableFuncTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -1376,12 +1355,9 @@ SetVariableFuncTestSub2 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 5, - Data[0], - 0 + Attributes, AttributesArray[SubIndex], + DataSize, 5, + Data[0], 0 ); // @@ -1414,6 +1390,7 @@ SetVariableFuncTestSub2 ( return EFI_SUCCESS; } + /** * SetVariable when the similar variable exists. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1425,23 +1402,23 @@ SetVariableFuncTestSub2 ( */ EFI_STATUS SetVariableFuncTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_STATUS ReturnedStatus; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - UINT32 Attributes; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_STATUS ReturnedStatus; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + UINT32 Attributes; + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -1481,7 +1458,7 @@ SetVariableFuncTestSub3 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1510,7 +1487,7 @@ SetVariableFuncTestSub3 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1548,14 +1525,14 @@ SetVariableFuncTestSub3 ( // Get the variable to check results // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1573,10 +1550,9 @@ SetVariableFuncTestSub3 ( // // Check results // - if ((ReturnedStatus == EFI_SUCCESS) && + if ((ReturnedStatus == EFI_SUCCESS ) && (Attributes == AttributesArray[SubIndex]) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -1601,8 +1577,7 @@ SetVariableFuncTestSub3 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -1611,26 +1586,23 @@ SetVariableFuncTestSub3 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 10, - Data[0], - 0 + Attributes, AttributesArray[SubIndex], + DataSize, 10, + Data[0], 0 ); // // Get the similar variable to check results ("TestVariable" + A) // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariableA", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->GetVariable ( + L"TestVariableA", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1649,8 +1621,7 @@ SetVariableFuncTestSub3 ( // Check results // if ((Attributes == AttributesArray[SubIndex]) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -1683,26 +1654,23 @@ SetVariableFuncTestSub3 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 10, - Data[0], - 1 + Attributes, AttributesArray[SubIndex], + DataSize, 10, + Data[0], 1 ); // // Get the similar variable to check results ("TestVariable" - e) // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariabl", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); - if (EFI_ERROR (Status)) { + Status = RT->GetVariable ( + L"TestVariabl", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1721,8 +1689,7 @@ SetVariableFuncTestSub3 ( // Check results // if ((Attributes == AttributesArray[SubIndex]) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -1755,12 +1722,9 @@ SetVariableFuncTestSub3 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 10, - Data[0], - 2 + Attributes, AttributesArray[SubIndex], + DataSize, 10, + Data[0], 2 ); // @@ -1809,6 +1773,7 @@ SetVariableFuncTestSub3 ( return EFI_SUCCESS; } + /** * SetVariable when the DataSize is 0. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1820,23 +1785,23 @@ SetVariableFuncTestSub3 ( */ EFI_STATUS SetVariableFuncTestSub4 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_STATUS ReturnedStatus; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - UINT32 Attributes; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_STATUS ReturnedStatus; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + UINT32 Attributes; + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -1876,7 +1841,7 @@ SetVariableFuncTestSub4 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1910,20 +1875,19 @@ SetVariableFuncTestSub4 ( // Get the variable to check results // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); // // Check results // - if ((ReturnedStatus == EFI_SUCCESS) && - (Status == EFI_NOT_FOUND)) - { + if ((ReturnedStatus == EFI_SUCCESS ) && + (Status == EFI_NOT_FOUND)) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -1941,16 +1905,14 @@ SetVariableFuncTestSub4 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( StandardLib, EFI_VERBOSE_LEVEL_DEFAULT, L"GetVariable: Status - %r, Expected - %r\n", - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); } } @@ -1972,6 +1934,7 @@ SetVariableFuncTestSub4 ( return EFI_SUCCESS; } + /** * SetVariable when the Attributes is 0. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1983,23 +1946,23 @@ SetVariableFuncTestSub4 ( */ EFI_STATUS SetVariableFuncTestSub5 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_STATUS ReturnedStatus; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - UINT32 Attributes; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_STATUS Status; + EFI_STATUS ReturnedStatus; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + UINT32 Attributes; + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -2039,7 +2002,7 @@ SetVariableFuncTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2069,24 +2032,24 @@ SetVariableFuncTestSub5 ( gtBS->RestoreTPL (OldTpl); + // // Get the variable to check results // DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); // // Check results // - if ((ReturnedStatus == EFI_SUCCESS) && - (Status == EFI_NOT_FOUND)) - { + if ((ReturnedStatus == EFI_SUCCESS ) && + (Status == EFI_NOT_FOUND)) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -2104,16 +2067,14 @@ SetVariableFuncTestSub5 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( StandardLib, EFI_VERBOSE_LEVEL_DEFAULT, L"GetVariable: Status - %r, Expected - %r\n", - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); } } @@ -2135,6 +2096,7 @@ SetVariableFuncTestSub5 ( return EFI_SUCCESS; } + /** * Non-volatile variable exists after system reset. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2148,26 +2110,26 @@ SetVariableFuncTestSub5 ( */ EFI_STATUS SetVariableFuncTestSub6 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - CHAR16 *VariableName; - UINT32 Attributes; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + CHAR16 *VariableName; + UINT32 Attributes; // UINTN RecoveryDataSize; // UINT8 *RecoveryData; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS }; @@ -2235,7 +2197,7 @@ SetVariableFuncTestSub6 ( // Insert a variable // VariableName = SctPoolPrint (L"TestVariable_%d_%d", Index, SubIndex); - OldTpl = gtBS->RaiseTPL (TplArray[Index]); + OldTpl = gtBS->RaiseTPL (TplArray[Index]); for (DataIndex = 0; DataIndex < 10; DataIndex++) { Data[DataIndex] = (UINT8)DataIndex; @@ -2255,7 +2217,7 @@ SetVariableFuncTestSub6 ( // // Check results // - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2305,21 +2267,20 @@ SetVariableFuncTestSub6 ( VariableName = SctPoolPrint (L"TestVariable_%d_%d", Index, SubIndex); DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - VariableName, // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + VariableName, // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); // // Check results // - if ((Status == EFI_SUCCESS) && + if ((Status == EFI_SUCCESS ) && (Attributes == AttributesArray[SubIndex]) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -2344,8 +2305,7 @@ SetVariableFuncTestSub6 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -2354,12 +2314,9 @@ SetVariableFuncTestSub6 ( L"Attributes=0x%x, Expected=0x%x\n" L"DataSize=%d, Expected=%d\n" L"Data[0]=0x%x, Expected=0x%x\n", - Attributes, - AttributesArray[SubIndex], - DataSize, - 10, - Data[0], - 0 + Attributes, AttributesArray[SubIndex], + DataSize, 10, + Data[0], 0 ); // @@ -2400,6 +2357,7 @@ SetVariableFuncTestSub6 ( return EFI_SUCCESS; } + /** * Volatile variable does not exist after system reset. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2413,26 +2371,26 @@ SetVariableFuncTestSub6 ( */ EFI_STATUS SetVariableFuncTestSub7 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN SubIndex; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - CHAR16 *VariableName; - UINT32 Attributes; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN SubIndex; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + CHAR16 *VariableName; + UINT32 Attributes; // UINTN RecoveryDataSize; // UINT8 *RecoveryData; - EFI_TPL OldTpl; - EFI_TPL TplArray[] = { TPL_APPLICATION, TPL_CALLBACK }; - UINT32 AttributesArray[] = { + EFI_TPL OldTpl; + EFI_TPL TplArray[] = {TPL_APPLICATION, TPL_CALLBACK}; + UINT32 AttributesArray[] = { EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS }; @@ -2500,7 +2458,7 @@ SetVariableFuncTestSub7 ( // Insert a variable // VariableName = SctPoolPrint (L"TestVariable_%d_%d", Index, SubIndex); - OldTpl = gtBS->RaiseTPL (TplArray[Index]); + OldTpl = gtBS->RaiseTPL (TplArray[Index]); for (DataIndex = 0; DataIndex < 10; DataIndex++) { Data[DataIndex] = (UINT8)DataIndex; @@ -2520,7 +2478,7 @@ SetVariableFuncTestSub7 ( // // Check results // - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2568,13 +2526,13 @@ SetVariableFuncTestSub7 ( VariableName = SctPoolPrint (L"TestVariable_%d_%d", Index, SubIndex); DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - VariableName, // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + VariableName, // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); // // Check results @@ -2597,8 +2555,7 @@ SetVariableFuncTestSub7 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); gtBS->FreePool (VariableName); @@ -2634,7 +2591,7 @@ SetVariableFuncTestSub7 ( // UINT32 UnicodeStrLength ( - IN CHAR16 *String + IN CHAR16 *String ) { UINT32 Count; @@ -2654,10 +2611,10 @@ UnicodeStrLength ( EFI_STATUS QueryVariableInfoFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -2675,12 +2632,12 @@ QueryVariableInfoFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } // if (FALSE == CheckBBTestCanRunAndRecordAssertion( - // StandardLib, + // StandardLib, // L"RT.QueryVariableInfo_Func - QueryVariableInfo_Func it's not Supported in EFI", // __FILE__, // (UINTN)__LINE__ @@ -2696,37 +2653,37 @@ QueryVariableInfoFuncTest ( } // -// QueryVariableInfo must succeed with a valid Attributes and +// QueryVariableInfo must succeed with a valid Attributes and // return the proper value when it is in Boot time // EFI_STATUS QueryVariableInfoFuncTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, - IN EFI_HANDLE SupportHandle + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib, + IN EFI_HANDLE SupportHandle ) { - EFI_STATUS QueryVarStatus[3]; + EFI_STATUS QueryVarStatus[3]; // EFI_STATUS SetVarStatus; - UINT32 ValidAttributes[] = { - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, - EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, - EFI_VARIABLE_BOOTSERVICE_ACCESS, - 0 - }; - UINT64 MaximumVariableStorageSize[3]; - UINT64 RemainingVariableStorageSize[3]; - UINT64 MaximumVariableSize[3]; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINT8 DataBuf[MAX_DATA_SIZE]; - UINT32 DataIndex; - UINT32 SubIndex; - EFI_GUID TestVendorGuid = QUERYVAR_GUID1; - UINT32 ErrorCode; - + UINT32 ValidAttributes[] = { + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, + EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_BOOTSERVICE_ACCESS, + 0 + }; + UINT64 MaximumVariableStorageSize[3]; + UINT64 RemainingVariableStorageSize[3]; + UINT64 MaximumVariableSize[3]; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINT8 DataBuf[MAX_DATA_SIZE]; + UINT32 DataIndex; + UINT32 SubIndex; + EFI_GUID TestVendorGuid = QUERYVAR_GUID1; + UINT32 ErrorCode; + // // Trace ... // @@ -2737,8 +2694,8 @@ QueryVariableInfoFuncTestSub1 ( L"TDS 4.4.2.1" ); } - - for (Index = 0; ValidAttributes[Index] != 0; Index++) { + + for (Index = 0; ValidAttributes[Index] != 0; Index ++) { // // QueryVariableInfo 1 // @@ -2753,7 +2710,7 @@ QueryVariableInfoFuncTestSub1 ( // Call SetVariable to insert a variable // for (DataIndex = 0; DataIndex < MAX_DATA_SIZE; DataIndex++) { - DataBuf[DataIndex] = (UINT8)(DataIndex + 1); + DataBuf[DataIndex] = (UINT8)(DataIndex + 1); } RT->SetVariable ( @@ -2773,7 +2730,7 @@ QueryVariableInfoFuncTestSub1 ( &RemainingVariableStorageSize[1], &MaximumVariableSize[1] ); - + // // Call SetVariable service to delete the variable inserted just now // @@ -2787,7 +2744,7 @@ QueryVariableInfoFuncTestSub1 ( // // QueryVariableInfo 3 - // + // QueryVarStatus[2] = RT->QueryVariableInfo ( ValidAttributes[Index], &MaximumVariableStorageSize[2], @@ -2796,39 +2753,37 @@ QueryVariableInfoFuncTestSub1 ( ); // QueryVarStatus[0] QueryVarStatus[1] QueryVarStatus[2] being EFI_SUCCESS or EFI_UNSUPPORTED - Result = EFI_TEST_ASSERTION_PASSED; + Result = EFI_TEST_ASSERTION_PASSED; ErrorCode = 0; for (SubIndex = 0; SubIndex < 3; SubIndex++) { if (QueryVarStatus[SubIndex] == EFI_UNSUPPORTED) { - Result = EFI_TEST_ASSERTION_WARNING; + Result = EFI_TEST_ASSERTION_WARNING; ErrorCode = 0; goto LoopEnd; } - - if (QueryVarStatus[SubIndex] != EFI_SUCCESS) { - Result = EFI_TEST_ASSERTION_FAILED; + if(QueryVarStatus[SubIndex] != EFI_SUCCESS) { + Result = EFI_TEST_ASSERTION_FAILED; ErrorCode = 1; goto LoopEnd; - } + } } - + for (SubIndex = 0; SubIndex < 3; SubIndex++) { - if (MaximumVariableStorageSize[SubIndex] != MaximumVariableStorageSize[0]) { - Result = EFI_TEST_ASSERTION_FAILED; + if(MaximumVariableStorageSize[SubIndex] != MaximumVariableStorageSize[0]) { + Result = EFI_TEST_ASSERTION_FAILED; ErrorCode = 2; goto LoopEnd; + } + } +/* + for (SubIndex = 0; SubIndex < 3; SubIndex++) { + if (MaximumVariableSize[SubIndex] != MaximumVariableSize[0]) { + Result = EFI_TEST_ASSERTION_FAILED; + ErrorCode = 3; + goto LoopEnd; } } - - /* - for (SubIndex = 0; SubIndex < 3; SubIndex++) { - if (MaximumVariableSize[SubIndex] != MaximumVariableSize[0]) { - Result = EFI_TEST_ASSERTION_FAILED; - ErrorCode = 3; - goto LoopEnd; - } - } - */ +*/ LoopEnd: // // Record assertion @@ -2870,16 +2825,16 @@ QueryVariableInfoFuncTestSub1 ( // return EFI_SUCCESS; } - #endif + #if (EFI_SPECIFICATION_VERSION >= 0x0002000A) EFI_STATUS HardwareErrorRecordFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -2887,35 +2842,36 @@ HardwareErrorRecordFuncTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; - + // UINTN RecoveryDataSize; // UINT8 *RecoveryData; - - CHAR16 *HwErrRecName = L"HwErrRecSupport"; - UINT16 HwErrRecSupportVariable; - UINTN DataSize; - - UINT32 Attributes = EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS - |EFI_VARIABLE_RUNTIME_ACCESS|EFI_VARIABLE_HARDWARE_ERROR_RECORD; - UINT64 MaximumVariableStorageSize; - UINT64 RemainingVariableStorageSize; - UINT64 MaximumVariableSize; - - CHAR16 HwErrRecVariableName[HW_ERR_REC_VARIABLE_NAME_LEN]; - CHAR16 HwErrRecVariable[] = L"This is a HwErrRec variable!"; - - CHAR16 GetVariableName[MAX_BUFFER_SIZE]; - UINTN VariableNameSize; - EFI_GUID VendorGuid; - - UINTN Num; - UINTN MaxNum = 0; - CHAR16 ErrorNum[HW_ERR_REC_VARIABLE_NAME_INDEX_LEN + 1]; - - CHAR16 HwErrRecGetVariable[255]; - - EFI_TEST_ASSERTION AssertionType; - + + CHAR16 *HwErrRecName = L"HwErrRecSupport"; + UINT16 HwErrRecSupportVariable; + UINTN DataSize; + + UINT32 Attributes = EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS + |EFI_VARIABLE_RUNTIME_ACCESS|EFI_VARIABLE_HARDWARE_ERROR_RECORD; + UINT64 MaximumVariableStorageSize; + UINT64 RemainingVariableStorageSize; + UINT64 MaximumVariableSize; + + CHAR16 HwErrRecVariableName[HW_ERR_REC_VARIABLE_NAME_LEN]; + CHAR16 HwErrRecVariable[] = L"This is a HwErrRec variable!"; + + CHAR16 GetVariableName[MAX_BUFFER_SIZE]; + UINTN VariableNameSize; + EFI_GUID VendorGuid; + + UINTN Num; + UINTN MaxNum = 0; + CHAR16 ErrorNum[HW_ERR_REC_VARIABLE_NAME_INDEX_LEN + 1]; + + CHAR16 HwErrRecGetVariable[255]; + + EFI_TEST_ASSERTION AssertionType; + + // // Get test support library interfaces // @@ -2925,7 +2881,7 @@ HardwareErrorRecordFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -2938,7 +2894,7 @@ HardwareErrorRecordFuncTest ( L"TDS" ); } - + // // Allocate memory for recovery data // @@ -2954,7 +2910,7 @@ HardwareErrorRecordFuncTest ( // // Try to read reset record from the RecoveryData, - // and the magic num is saved in the RecoveryData[0]. + // and the magic num is saved in the RecoveryData[0]. // When the status is EFI_SUCCESS and magic num is 2, // it means useful data has been saved before the reset // and the date should be retrived goto particular process @@ -2972,116 +2928,116 @@ HardwareErrorRecordFuncTest ( // goto step3; // } // } - + // // Check if the platform implements support for Hardware Error Record Persistence // - DataSize = sizeof (HwErrRecSupportVariable); + DataSize = sizeof( HwErrRecSupportVariable ); HwErrRecSupportVariable = 0xFFFF; - Status = RT->GetVariable ( - HwErrRecName, - &gGlobalVariableGuid, - NULL, - &DataSize, - &HwErrRecSupportVariable - ); - + Status = RT->GetVariable ( + HwErrRecName, + &gGlobalVariableGuid, + NULL, + &DataSize, + &HwErrRecSupportVariable + ); + StandardLib->RecordMessage ( - StandardLib, - EFI_VERBOSE_LEVEL_DEFAULT, - L"\r\nGetVariable() to get the HwErrRecSupport : %r %d", - Status, - HwErrRecSupportVariable - ); - - if ((EFI_SUCCESS != Status) || !HwErrRecSupportVariable ) { + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nGetVariable() to get the HwErrRecSupport : %r %d", + Status, + HwErrRecSupportVariable + ); + + + if ( EFI_SUCCESS != Status || !HwErrRecSupportVariable ) { // gtBS->FreePool (RecoveryData); return Status; } - + // // Query the variable info // Status = RT->QueryVariableInfo ( - Attributes, - &MaximumVariableStorageSize, - &RemainingVariableStorageSize, - &MaximumVariableSize - ); + Attributes, + &MaximumVariableStorageSize, + &RemainingVariableStorageSize, + &MaximumVariableSize + ); StandardLib->RecordMessage ( - StandardLib, - EFI_VERBOSE_LEVEL_DEFAULT, - L"\r\n Query the variable info : MaximumVariableStorageSize - %d, RemainingVariableStorageSize - %d", - MaximumVariableStorageSize, - RemainingVariableStorageSize - ); - - if ((Status != EFI_SUCCESS) || (RemainingVariableStorageSize <= 0)) { + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\n Query the variable info : MaximumVariableStorageSize - %d, RemainingVariableStorageSize - %d", + MaximumVariableStorageSize, + RemainingVariableStorageSize + ); + + if ( Status != EFI_SUCCESS || RemainingVariableStorageSize <= 0 ) { // gtBS->FreePool (RecoveryData); return Status; } - + // // Get a useable variable name // - GetVariableName[0] = L'\0'; + GetVariableName[0] = L'\0'; ErrorNum[HW_ERR_REC_VARIABLE_NAME_INDEX_LEN] = L'\0'; + while (TRUE) { VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - Status = RT->GetNextVariableName ( - &VariableNameSize, // VariableNameSize - GetVariableName, // VariableName - &VendorGuid // VendorGuid - ); - + Status = RT->GetNextVariableName ( + &VariableNameSize, // VariableNameSize + GetVariableName, // VariableName + &VendorGuid // VendorGuid + ); + StandardLib->RecordMessage ( - StandardLib, - EFI_VERBOSE_LEVEL_DEFAULT, - L"\r\nGetNextVariableName() to get the variable name : %s - %r", - GetVariableName, - Status - ); + StandardLib, + EFI_VERBOSE_LEVEL_DEFAULT, + L"\r\nGetNextVariableName() to get the variable name : %s - %r", + GetVariableName, + Status + ); if ( EFI_SUCCESS != Status ) { break; } - if ((SctStrnCmp (GetVariableName, L"HwErrRec", HW_ERR_REC_VARIABLE_NAME_PREFIX_LEN) == 0) && - (SctCompareGuid (&VendorGuid, &gHwErrRecGuid) == 0)) - { + if ( (SctStrnCmp (GetVariableName, L"HwErrRec", HW_ERR_REC_VARIABLE_NAME_PREFIX_LEN) == 0) && + (SctCompareGuid (&VendorGuid, &gHwErrRecGuid) == 0) ) { SctStrnCpy (ErrorNum, &GetVariableName[HW_ERR_REC_VARIABLE_NAME_PREFIX_LEN], HW_ERR_REC_VARIABLE_NAME_INDEX_LEN); Num = SctXtoi (ErrorNum); - if (MaxNum < Num) { + if (MaxNum < Num) MaxNum = Num; - } } } MaxNum++; - + HwErrRecVariableName[0] = L'\0'; - SctStrCat (HwErrRecVariableName, L"HwErrRec"); - Myitox (MaxNum, HwErrRecVariableName + HW_ERR_REC_VARIABLE_NAME_PREFIX_LEN); + SctStrCat ( HwErrRecVariableName, L"HwErrRec" ); + Myitox( MaxNum, HwErrRecVariableName + HW_ERR_REC_VARIABLE_NAME_PREFIX_LEN ); HwErrRecVariableName[HW_ERR_REC_VARIABLE_NAME_LEN - 1] = L'\0'; - + // // Set the new HwErrRec variable to the global variable // - DataSize = sizeof (HwErrRecVariable); - Status = RT->SetVariable ( - HwErrRecVariableName, - &gHwErrRecGuid, - Attributes, - DataSize, - HwErrRecVariable - ); - if ( EFI_ERROR (Status)) { + DataSize = sizeof( HwErrRecVariable ); + Status = RT->SetVariable ( + HwErrRecVariableName, + &gHwErrRecGuid, + Attributes, + DataSize, + HwErrRecVariable + ); + if ( EFI_ERROR(Status) ) { // gtBS->FreePool (RecoveryData); return Status; } - + // // Before the reset, test writes magic num 2 in RecoveryData[0] // and writes the useful data - HwErrRecVariableName - to RecoveryData[2] @@ -3089,7 +3045,7 @@ HardwareErrorRecordFuncTest ( // RecoveryData[0] = 2; // SctStrnCpy ( (CHAR16*)(&RecoveryData[2]), HwErrRecVariableName, HW_ERR_REC_VARIABLE_NAME_LEN - 1 ); // RecoveryLib->WriteResetRecord( RecoveryLib, HW_ERR_REC_VARIABLE_NAME_LEN * sizeof(CHAR16) + 2, RecoveryData ); - + // // Prompt the user about the cold reset and reset the system // @@ -3097,7 +3053,7 @@ HardwareErrorRecordFuncTest ( // gtBS->Stall (1000000); // gtRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); - + // // The particular process after the reset // retrive the useful data - HwErrRecVariableName - from RecoveryData[2] @@ -3107,46 +3063,46 @@ HardwareErrorRecordFuncTest ( // HwErrRecVariableName[HW_ERR_REC_VARIABLE_NAME_LEN - 1] = L'\0'; // SctStrnCpy ( HwErrRecVariableName, (CHAR16*)(RecoveryData+2), HW_ERR_REC_VARIABLE_NAME_LEN - 1 ); Status = RT->GetVariable ( - HwErrRecVariableName, - &gHwErrRecGuid, - NULL, - &DataSize, - HwErrRecGetVariable - ); - if ( EFI_ERROR (Status)) { + HwErrRecVariableName, + &gHwErrRecGuid, + NULL, + &DataSize, + HwErrRecGetVariable + ); + if ( EFI_ERROR(Status) ) { // gtBS->FreePool (RecoveryData); return Status; } - - if ( SctStrCmp (HwErrRecGetVariable, HwErrRecVariable)) { + + if ( SctStrCmp ( HwErrRecGetVariable, HwErrRecVariable ) ) { AssertionType = EFI_TEST_ASSERTION_FAILED; } else { AssertionType = EFI_TEST_ASSERTION_PASSED; } - + // // Compare the result // StandardLib->RecordAssertion ( - StandardLib, - AssertionType, - gHwErrRecBbTestAssertionGuid001, - L"HwErrRec varuable test.", - L"%a:%d", - __FILE__, - (UINTN)__LINE__ - ); - + StandardLib, + AssertionType, + gHwErrRecBbTestAssertionGuid001, + L"HwErrRec varuable test.", + L"%a:%d", + __FILE__, + (UINTN)__LINE__ + ); + // // Delete the HwErrRecVariable // Status = RT->SetVariable ( - HwErrRecVariableName, - &gHwErrRecGuid, - Attributes, - 0, - HwErrRecVariable - ); + HwErrRecVariableName, + &gHwErrRecGuid, + Attributes, + 0, + HwErrRecVariable + ); // // Free resources diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestMain.h b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestMain.h index 3c070805f74..54b666af2c5 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestMain.h +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestMain.h @@ -5,12 +5,12 @@ 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 + 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. - + **/ /*++ @@ -28,19 +28,19 @@ Module Name: // // Includes // - #include - #include "Guid.h" +#include +#include "Guid.h" // // Definitions // -#define VARIABLE_SERVICES_BB_TEST_REVISION 0x00010000 +#define VARIABLE_SERVICES_BB_TEST_REVISION 0x00010000 #define VARIABLE_SERVICES_BB_TEST_GUID \ { 0xD6844631, 0x0A1E, 0x42d1, {0xA5, 0x94, 0x60, 0x35, 0x48, 0x47, 0xB6, 0x76 }} -#define MAX_BUFFER_SIZE 256 +#define MAX_BUFFER_SIZE 256 #define TEST_VENDOR1_GUID \ { 0xF6FAB04F, 0xACAF, 0x4af3, { 0xB9, 0xFA, 0xDC, 0xF9, 0x7F, 0xB4, 0x42, 0x6F } } @@ -69,7 +69,7 @@ Module Name: // // For QueryVariableInfo // - #if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) #define QUERY_VAR_CASE6_GUID1 \ { 0x5d1f058c, 0x08ae, 0x4f71, {0x9e, 0x81, 0xa6, 0x78, 0x30, 0x33, 0xa5, 0xed }} @@ -85,23 +85,24 @@ Module Name: #define QUERYVAR_GUID2 \ { 0xcc648ba7, 0x1be7, 0x4262, {0xa8, 0xcb, 0x47, 0x08, 0x51, 0x6d, 0x86, 0xe8 }} - #if ((ALIGNMENT == 0) || (ALIGNMENT == 1)) -#define GET_PAD_SIZE(a) (0) - #else -#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1)) - #endif +#if ((ALIGNMENT == 0) || (ALIGNMENT == 1)) +#define GET_PAD_SIZE(a) (0) +#else +#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1)) +#endif -#define MAX_DATA_SIZE 20 - #endif +#define MAX_DATA_SIZE 20 +#endif - #if (EFI_SPECIFICATION_VERSION >= 0x0002000A) + +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) #define HARDWARE_ERROR_RECORD_FUNC_TEST_GUID \ { 0xefaba332, 0x13e8, 0x4730, {0x97, 0xcb, 0x48, 0xce, 0x9f, 0x8, 0x26, 0xc5 }} #define HARDWARE_ERROR_RECORD_CONF_TEST_GUID \ { 0xcf94f695, 0x7917, 0x4f78, {0xa0, 0xa8, 0xf0, 0xb5, 0x9, 0x9, 0x92, 0x97 }} -#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 #define EFI_HARDWARE_ERROR_VARIABLE \ { 0x414E6BDD, 0xE47B, 0x47cc, {0xB2, 0x44, 0xBB, 0x61, 0x02, 0x0C, 0xF5, 0x16 }} @@ -114,25 +115,25 @@ Module Name: #define EFI_AUTHVARIABLE_DER_CONF_TEST_GUID \ { 0x28155531, 0x80c5, 0x4ad0, {0x84, 0x71, 0xa5, 0xe2, 0xae, 0xcf, 0x23, 0x6c }} - #endif +#endif // -// The Variable Name of Hardware Error Record Variables +// The Variable Name of Hardware Error Record Variables // defined in the UEFI Spec is HwErrRec####. For example, // HwErrRec0001, HwErrRec0002, HwErrRecF31A, etc. // The prefix length is 8, index length is 4. // Consider the tail of string, the name length is 13. // -#define HW_ERR_REC_VARIABLE_NAME_LEN 13 -#define HW_ERR_REC_VARIABLE_NAME_PREFIX_LEN 8 -#define HW_ERR_REC_VARIABLE_NAME_INDEX_LEN 4 +#define HW_ERR_REC_VARIABLE_NAME_LEN 13 +#define HW_ERR_REC_VARIABLE_NAME_PREFIX_LEN 8 +#define HW_ERR_REC_VARIABLE_NAME_INDEX_LEN 4 // // Global Variables // -extern EFI_GUID gTestVendor1Guid; -extern EFI_GUID gTestVendor2Guid; +extern EFI_GUID gTestVendor1Guid; +extern EFI_GUID gTestVendor2Guid; // // Prototypes @@ -143,10 +144,10 @@ extern EFI_GUID gTestVendor2Guid; // EFI_STATUS GetVariableConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -154,10 +155,10 @@ GetVariableConfTest ( // EFI_STATUS GetNextVariableNameConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -165,51 +166,51 @@ GetNextVariableNameConfTest ( // EFI_STATUS SetVariableConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); - #if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) // // TDS 3.4 // EFI_STATUS QueryVariableInfoConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); EFI_STATUS AuthVariableDERConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); EFI_STATUS AuthVariableDERFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); - #endif +#endif // // TDS 4.1 // EFI_STATUS GetVariableFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -217,10 +218,10 @@ GetVariableFuncTest ( // EFI_STATUS GetNextVariableNameFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -228,51 +229,51 @@ GetNextVariableNameFuncTest ( // EFI_STATUS SetVariableFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); - #if (EFI_SPECIFICATION_VERSION >= 0x00020000) +#if (EFI_SPECIFICATION_VERSION >= 0x00020000) // // TDS 4.4 // EFI_STATUS QueryVariableInfoFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); EFI_STATUS HardwareErrorRecordFuncTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); - + EFI_STATUS HardwareErrorRecordConfTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); - - #endif + +#endif // // TDS 5.1 // EFI_STATUS MultipleStressTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -280,10 +281,10 @@ MultipleStressTest ( // EFI_STATUS OverflowStressTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -296,14 +297,13 @@ GetTestSupportLibrary ( OUT EFI_TEST_RECOVERY_LIBRARY_PROTOCOL **RecoveryLib, OUT EFI_TEST_LOGGING_LIBRARY_PROTOCOL **LoggingLib ); - #endif -#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) +#if (EFI_SPECIFICATION_VERSION >= 0x0002000A) EFI_STATUS Myitox ( - IN UINTN Num, - OUT CHAR16 *StringNum + IN UINTN Num, + OUT CHAR16 *StringNum ); #endif diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestStress.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestStress.c index d2bf58c547a..eeb751718db 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestStress.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestStress.c @@ -5,12 +5,12 @@ 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 + 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. - + **/ /*++ @@ -24,7 +24,7 @@ Module Name: #include "VariableServicesBBTestMain.h" -#define MULTIPLE_TEST_TIMES 50 +#define MULTIPLE_TEST_TIMES 50 // // Prototypes (external) @@ -32,18 +32,18 @@ Module Name: EFI_STATUS MultipleStressTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); EFI_STATUS OverflowStressTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ); // @@ -52,31 +52,31 @@ OverflowStressTest ( EFI_STATUS MultipleStressTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS MultipleStressTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS MultipleStressTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); EFI_STATUS OverflowStressTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ); // @@ -94,10 +94,10 @@ OverflowStressTestSub1 ( */ EFI_STATUS MultipleStressTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -115,7 +115,7 @@ MultipleStressTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -142,6 +142,7 @@ MultipleStressTest ( return EFI_SUCCESS; } + /** * TDS 5.2 - Entry point for Variable Overflow Stress Test. * @param This A pointer to the EFI_BB_TEST_PROTOCOL instance. @@ -153,10 +154,10 @@ MultipleStressTest ( */ EFI_STATUS OverflowStressTest ( - IN EFI_BB_TEST_PROTOCOL *This, - IN VOID *ClientInterface, - IN EFI_TEST_LEVEL TestLevel, - IN EFI_HANDLE SupportHandle + IN EFI_BB_TEST_PROTOCOL *This, + IN VOID *ClientInterface, + IN EFI_TEST_LEVEL TestLevel, + IN EFI_HANDLE SupportHandle ) { EFI_STATUS Status; @@ -164,7 +165,6 @@ OverflowStressTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; - // UINTN RecoveryDataSize; // UINT8 *RecoveryData; @@ -177,7 +177,7 @@ OverflowStressTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -219,6 +219,7 @@ OverflowStressTest ( // step2: Status = OverflowStressTestSub1 (RT, StandardLib, RecoveryLib, LoggingLib); + // // Free resources // @@ -231,6 +232,7 @@ OverflowStressTest ( return EFI_SUCCESS; } + /** * Multiple test for GetVariable. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -242,18 +244,18 @@ OverflowStressTest ( */ EFI_STATUS MultipleStressTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN DataIndex; - UINTN DataSize; - UINT8 Data[MAX_BUFFER_SIZE]; - UINT32 Attributes; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN DataIndex; + UINTN DataSize; + UINT8 Data[MAX_BUFFER_SIZE]; + UINT32 Attributes; // // Trace ... @@ -280,7 +282,7 @@ MultipleStressTestSub1 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -308,13 +310,13 @@ MultipleStressTestSub1 ( // for (Index = 0; Index < MULTIPLE_TEST_TIMES; Index++) { DataSize = MAX_BUFFER_SIZE; - Status = RT->GetVariable ( - L"TestVariable", // VariableName - &gTestVendor1Guid, // VendorGuid - &Attributes, // Attributes - &DataSize, // DataSize - Data // Data - ); + Status = RT->GetVariable ( + L"TestVariable", // VariableName + &gTestVendor1Guid, // VendorGuid + &Attributes, // Attributes + &DataSize, // DataSize + Data // Data + ); if (Status == EFI_SUCCESS) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -333,8 +335,7 @@ MultipleStressTestSub1 ( __FILE__, (UINTN)__LINE__, Index, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); } @@ -366,6 +367,7 @@ MultipleStressTestSub1 ( return EFI_SUCCESS; } + /** * Multiple test for GetNextVariableName. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -377,19 +379,19 @@ MultipleStressTestSub1 ( */ EFI_STATUS MultipleStressTestSub2 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - UINTN VariableNameSize; - CHAR16 VariableName[MAX_BUFFER_SIZE]; - EFI_GUID VendorGuid; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; + UINTN VariableNameSize; + CHAR16 VariableName[MAX_BUFFER_SIZE]; + EFI_GUID VendorGuid; // // Trace ... @@ -416,7 +418,7 @@ MultipleStressTestSub2 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -443,13 +445,14 @@ MultipleStressTestSub2 ( // Get the next variable name multiple times // for (Index = 0; Index < MULTIPLE_TEST_TIMES; Index++) { + VariableNameSize = MAX_BUFFER_SIZE * sizeof (CHAR16); - VariableName[0] = L'\0'; - Status = RT->GetNextVariableName ( - &VariableNameSize, - VariableName, - &VendorGuid - ); + VariableName[0] = L'\0'; + Status = RT->GetNextVariableName ( + &VariableNameSize, + VariableName, + &VendorGuid + ); if (Status == EFI_SUCCESS) { Result = EFI_TEST_ASSERTION_PASSED; } else { @@ -468,8 +471,7 @@ MultipleStressTestSub2 ( __FILE__, (UINTN)__LINE__, Index, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); } @@ -501,6 +503,7 @@ MultipleStressTestSub2 ( return EFI_SUCCESS; } + /** * Multiple test for SetVariable. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -512,16 +515,16 @@ MultipleStressTestSub2 ( */ EFI_STATUS MultipleStressTestSub3 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - EFI_TEST_ASSERTION Result; - UINTN Index; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; + EFI_STATUS Status; + EFI_TEST_ASSERTION Result; + UINTN Index; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; // // Trace ... @@ -570,8 +573,7 @@ MultipleStressTestSub3 ( __FILE__, (UINTN)__LINE__, Index, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); } @@ -611,8 +613,7 @@ MultipleStressTestSub3 ( __FILE__, (UINTN)__LINE__, Index, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); } @@ -644,6 +645,7 @@ MultipleStressTestSub3 ( return EFI_SUCCESS; } + /** * Reclaim test with system reset. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -657,18 +659,17 @@ MultipleStressTestSub3 ( */ EFI_STATUS OverflowStressTestSub1 ( - IN EFI_RUNTIME_SERVICES *RT, - IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, - IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, - IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib + IN EFI_RUNTIME_SERVICES *RT, + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib, + IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib, + IN EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib ) { - EFI_STATUS Status; - UINTN Index; - CHAR16 *VariableName; - UINTN DataIndex; - UINT8 Data[MAX_BUFFER_SIZE]; - + EFI_STATUS Status; + UINTN Index; + CHAR16 *VariableName; + UINTN DataIndex; + UINT8 Data[MAX_BUFFER_SIZE]; // UINTN RecoveryDataSize; // UINT8 *RecoveryData; @@ -744,7 +745,7 @@ OverflowStressTestSub1 ( gtBS->FreePool (VariableName); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { break; } } @@ -789,7 +790,7 @@ OverflowStressTestSub1 ( gtBS->FreePool (VariableName); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { break; } } diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/SctShim.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/SctShim.c new file mode 100644 index 00000000000..09e111a6cd5 --- /dev/null +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/SctShim.c @@ -0,0 +1,357 @@ +/** @file + Helper functions and shim defintions for missing + SCT components. + +Copyright (c) Microsoft Corporation. +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +#include "VariableServicesBBTestMain.h" +#include "SctShim.h" + +EFI_GUID gTestVendor1Guid = TEST_VENDOR1_GUID; +EFI_GUID gTestVendor2Guid = TEST_VENDOR2_GUID; +EFI_GUID gTestGenericFailureGuid = TEST_GENERIC_FAILURE_GUID; + +EFI_BOOT_SERVICES *gtBS = NULL; + +CHAR16 * +EFIAPI +UnsafeStrnCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ) +{ + // NOTE: This is *VERY* unsafe. But it's just a test... so... + StrnCpyS (Destination, (UINTN)-1, Source, Length); + return Destination; +} + +CHAR16 * +EFIAPI +UnsafeStrCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ) +{ + // NOTE: This is *VERY* unsafe. But it's just a test... so... + StrCatS (Destination, (UINTN)-1, Source); + return Destination; +} + +INTN +SctCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ) +{ + INT32 *g1, *g2, r; + + // + // Compare 32 bits at a time + // + + g1 = (INT32 *)Guid1; + g2 = (INT32 *)Guid2; + + r = g1[0] - g2[0]; + r |= g1[1] - g2[1]; + r |= g1[2] - g2[2]; + r |= g1[3] - g2[3]; + + return r; +} + +UINTN +SctXtoi ( + CHAR16 *str + ) +{ + UINTN u; + CHAR16 c; + + // skip preceeding white space + while (*str && *str == ' ') { + str += 1; + } + + // skip preceeding zeros + while (*str && *str == '0') { + str += 1; + } + + // skip preceeding white space + if (*str && ((*str == 'x') || (*str == 'X'))) { + str += 1; + } + + // convert hex digits + u = 0; + c = *(str++); + while (c) { + if ((c >= 'a') && (c <= 'f')) { + c -= 'a' - 'A'; + } + + if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'))) { + u = (u << 4) | (c - (c >= 'A' ? 'A'-10 : '0')); + } else { + break; + } + + c = *(str++); + } + + return u; +} + +CHAR16 * +SctPoolPrint ( + IN CONST CHAR16 *Fmt, + ... + ) +{ + UINTN Count; + VA_LIST Args; + CHAR16 *Output; + + VA_START (Args, Fmt); + Count = SPrintLength (Fmt, Args); + VA_END (Args); + + Output = AllocatePool (Count); + + if (Output != NULL) { + VA_START (Args, Fmt); + UnicodeVSPrint (Output, Count, Fmt, Args); + VA_END (Args); + } + + return Output; +} + +EFI_STATUS +Myitox ( + IN UINTN Num, + OUT CHAR16 *StringNum + ) +{ + UINTN CurrentNum; + UINTN CurrentPos; + const UINTN Times = 4; + + for ( CurrentPos = 0; CurrentPos < Times; CurrentPos++ ) { + CurrentNum = Num % 16; + Num /= 16; + + if ( CurrentNum < 10 ) { + StringNum[Times-CurrentPos-1] = (CHAR16)(L'0' + CurrentNum); + } else { + StringNum[Times-CurrentPos-1] = (CHAR16)(L'A' + (CurrentNum - 10)); + } + } + + StringNum[Times] = '\0'; + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +HostTestRecordAssertion ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *This, + IN EFI_TEST_ASSERTION Type, + IN EFI_GUID EventId, + IN CHAR16 *Description, + IN CHAR16 *Detail, + ... + ) + +/*++ + +Routine Description: + + Records the test result. + +Arguments: + + This - Standard test library protocol instance. + Type - Test result. + EventId - GUID for the checkpoint. + Description - Simple description for the checkpoint. + Detail - Format string for the detail test information. + +Returns: + + EFI_SUCCESS - record the assertion successfully. + EFI_BAD_BUFFER_SIZE - the Description string is too long. + EFI_INVALID_PARAMETER - invalid Type. + +--*/ +{ + VA_LIST Marker; + CHAR8 AsciiBuffer[EFI_MAX_PRINT_BUFFER]; + CHAR16 AssertionDetail[EFI_MAX_PRINT_BUFFER]; + CHAR16 AssertionType[10]; + UINTN LogLevel; + SCT_HOST_TEST_PRIVATE_DATA *Private; + + Private = SCT_HOST_TEST_PRIVATE_DATA_FROM_STSL (This); + + // + // Check the parameter + // + if (StrnLenS (Description, EFI_MAX_PRINT_BUFFER) + 14 > EFI_MAX_PRINT_BUFFER) { + return EFI_BAD_BUFFER_SIZE; + } + + // + // Build assertion detail string + // + VA_START (Marker, Detail); + UnicodeVSPrint (AssertionDetail, EFI_MAX_PRINT_BUFFER, Detail, Marker); + VA_END (Marker); + + if ( StrnLenS (AssertionDetail, EFI_MAX_PRINT_BUFFER) + 5 < EFI_MAX_PRINT_BUFFER) { + StrCatS (AssertionDetail, EFI_MAX_PRINT_BUFFER, L"\r\n"); + } + + // + // Write log file detail data + // + switch (Type) { + case EFI_TEST_ASSERTION_PASSED: + StrCpyS (AssertionType, EFI_MAX_PRINT_BUFFER, L"PASS"); + LogLevel = UNIT_TEST_LOG_LEVEL_VERBOSE; + break; + case EFI_TEST_ASSERTION_WARNING: + StrCpyS (AssertionType, EFI_MAX_PRINT_BUFFER, L"WARNING"); + LogLevel = UNIT_TEST_LOG_LEVEL_WARN; + break; + case EFI_TEST_ASSERTION_FAILED: + StrCpyS (AssertionType, EFI_MAX_PRINT_BUFFER, L"FAILURE"); + *Private->ReturnStatus = UNIT_TEST_ERROR_TEST_FAILED; + LogLevel = UNIT_TEST_LOG_LEVEL_ERROR; + break; + default: + return EFI_INVALID_PARAMETER; + break; + } + + AsciiSPrintUnicodeFormat ( + AsciiBuffer, + EFI_MAX_PRINT_BUFFER, + L"%s -- %s\n" + L"%g\n" + L"%s\n", + Description, + AssertionType, + &EventId, + AssertionDetail + ); + UnitTestLog (LogLevel, AsciiBuffer); + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI +HostTestRecordMessage ( + IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *This, + IN EFI_VERBOSE_LEVEL VerboseLevel, + IN CHAR16 *Message, + ... + ) + +/*++ + +Routine Description: + + Records the test message. + +Arguments: + + This - Standard test library protocol instance. + VerboseLevel - Minimal verbose level to record this message. For example, + EFI_VERBOSE_LEVEL_QUIET means this message should be recorded + even the test is run in QUIET mode. On the contrary, + EFI_VERBOSE_LEVEL_EXHAUSTIVE means this message will only be + recorded when the test is run in EXHAUSTIVE mode. + Message - Format string for the detail test information. + +Returns: + + EFI_SUCCESS - record the message successfully. + +--*/ +{ + EFI_STATUS Status; + VA_LIST Marker; + CHAR8 AsciiBuffer[EFI_MAX_PRINT_BUFFER]; + + Status = EFI_SUCCESS; + + if (VerboseLevel <= EFI_TEST_LEVEL_MINIMAL) { + VA_START (Marker, Message); + AsciiVSPrintUnicodeFormat (AsciiBuffer, EFI_MAX_PRINT_BUFFER, Message, Marker); + VA_END (Marker); + + if ( AsciiStrnLenS (AsciiBuffer, EFI_MAX_PRINT_BUFFER) + 3 < EFI_MAX_PRINT_BUFFER ) { + AsciiStrCatS (AsciiBuffer, EFI_MAX_PRINT_BUFFER, "\r\n"); + } + + UnitTestLog (UNIT_TEST_LOG_LEVEL_VERBOSE, AsciiBuffer); + } + + return Status; +} + +EFI_STATUS +GetTestSupportLibrary ( + IN EFI_HANDLE SupportHandle, + OUT EFI_STANDARD_TEST_LIBRARY_PROTOCOL **StandardLib, + OUT EFI_TEST_RECOVERY_LIBRARY_PROTOCOL **RecoveryLib, + OUT EFI_TEST_LOGGING_LIBRARY_PROTOCOL **LoggingLib + ) +{ + SCT_HOST_TEST_PRIVATE_DATA *PrivateData; + + PrivateData = (SCT_HOST_TEST_PRIVATE_DATA *)SupportHandle; + *StandardLib = &PrivateData->StandardTest; + *RecoveryLib = NULL; + *LoggingLib = NULL; + + return EFI_SUCCESS; +} + +VOID +InitSctShim ( + IN EFI_BOOT_SERVICES *BS, + IN EFI_RUNTIME_SERVICES *RT + ) +{ + gtBS = BS; +} + +EFI_STATUS +InitSctPrivateData ( + IN OUT UNIT_TEST_STATUS *TestResult, + OUT SCT_HOST_TEST_PRIVATE_DATA *PrivateData + ) +{ + ZeroMem (PrivateData, sizeof (*PrivateData)); + PrivateData->Signature = SCT_HOST_TEST_PRIVATE_DATA_SIGNATURE; + PrivateData->ReturnStatus = TestResult; + PrivateData->StandardTest.RecordAssertion = HostTestRecordAssertion; + PrivateData->StandardTest.RecordMessage = HostTestRecordMessage; + return EFI_SUCCESS; +} diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/SctShim.h b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/SctShim.h new file mode 100644 index 00000000000..12d48be889e --- /dev/null +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/SctShim.h @@ -0,0 +1,184 @@ +/** @file +Helper functions and shim defintions for missing +SCT components. + +Copyright (c) Microsoft Corporation. +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef SCT_SHIM_H_ +#define SCT_SHIM_H_ + +#include +#include +#include +#include +#include + +#include +#include + +#define EFI_BB_TEST_PROTOCOL VOID +#define EFI_TEST_RECOVERY_LIBRARY_PROTOCOL VOID +#define SctStrCmp StrCmp +#define SctStrnCmp StrnCmp +#define SctStrLen StrLen +#define SctStrCat UnsafeStrCat +#define SctStrnCpy UnsafeStrnCpy +#define gHwErrRecGuid gEfiHardwareErrorVariableGuid +#define gGlobalVariableGuid gEfiGlobalVariableGuid + +#define EFI_MAX_PRINT_BUFFER 1024 + +#define SCT_HOST_TEST_PRIVATE_DATA_SIGNATURE SIGNATURE_32('H','T','P','D') +typedef struct _SCT_HOST_TEST_PRIVATE_DATA SCT_HOST_TEST_PRIVATE_DATA; + +// +// Generic Failure GUID is designed for the test environment issues or +// the walking-on issues. It will be recorded in the log files, but will not be +// summarized in the test report by the EFI SCT Suite. +// +#define TEST_GENERIC_FAILURE_GUID \ + { 0x6a8caa83, 0xb9da, 0x46c7, { 0x98, 0xf6, 0xd4, 0x96, 0x9d, 0xab, 0xda, 0xa0 }} + +extern EFI_GUID gTestGenericFailureGuid; + +// +// Dummy GUID is designed as a temporary GUID that will be replaced with a +// formal GUID later. It will be easy to use this GUID in prototype phase, +// and then use a tool to do the replacement. +// +#define TEST_DUMMY_GUID \ + { 0xece4bdd5, 0x8177, 0x448b, { 0x82, 0x03, 0x2d, 0x11, 0x0c, 0x1c, 0x20, 0xb8 }} + +extern EFI_GUID gTestDummyGuid; + +// +// Global variables for the services tables +// + +extern EFI_SYSTEM_TABLE *gtST; +extern EFI_BOOT_SERVICES *gtBS; +extern EFI_RUNTIME_SERVICES *gtRT; + +/** + [ATTENTION] This function is deprecated for security reason. + + Copies up to a specified length from one Null-terminated Unicode string to + another Null-terminated Unicode string and returns the new Unicode string. + + This function copies the contents of the Unicode string Source to the Unicode + string Destination, and returns Destination. At most, Length Unicode + characters are copied from Source to Destination. If Length is 0, then + Destination is returned unmodified. If Length is greater that the number of + Unicode characters in Source, then Destination is padded with Null Unicode + characters. If Source and Destination overlap, then the results are + undefined. + + If Length > 0 and Destination is NULL, then ASSERT(). + If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Length > 0 and Source is NULL, then ASSERT(). + If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Length is greater than + PcdMaximumUnicodeStringLength, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator, + then ASSERT(). + + @param Destination The pointer to a Null-terminated Unicode string. + @param Source The pointer to a Null-terminated Unicode string. + @param Length The maximum number of Unicode characters to copy. + + @return Destination. + +**/ +CHAR16 * +EFIAPI +UnsafeStrnCpy ( + OUT CHAR16 *Destination, + IN CONST CHAR16 *Source, + IN UINTN Length + ); + +/** + [ATTENTION] This function is deprecated for security reason. + + Concatenates one Null-terminated Unicode string to another Null-terminated + Unicode string, and returns the concatenated Unicode string. + + This function concatenates two Null-terminated Unicode strings. The contents + of Null-terminated Unicode string Source are concatenated to the end of + Null-terminated Unicode string Destination. The Null-terminated concatenated + Unicode String is returned. If Source and Destination overlap, then the + results are undefined. + + If Destination is NULL, then ASSERT(). + If Destination is not aligned on a 16-bit boundary, then ASSERT(). + If Source is NULL, then ASSERT(). + If Source is not aligned on a 16-bit boundary, then ASSERT(). + If Source and Destination overlap, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Destination contains more + than PcdMaximumUnicodeStringLength Unicode characters, not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and Source contains more than + PcdMaximumUnicodeStringLength Unicode characters, not including the + Null-terminator, then ASSERT(). + If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination + and Source results in a Unicode string with more than + PcdMaximumUnicodeStringLength Unicode characters, not including the + Null-terminator, then ASSERT(). + + @param Destination The pointer to a Null-terminated Unicode string. + @param Source The pointer to a Null-terminated Unicode string. + + @return Destination. + +**/ +CHAR16 * +EFIAPI +UnsafeStrCat ( + IN OUT CHAR16 *Destination, + IN CONST CHAR16 *Source + ); + +INTN +SctCompareGuid ( + IN EFI_GUID *Guid1, + IN EFI_GUID *Guid2 + ); + +UINTN +SctXtoi ( + CHAR16 *str + ); + +CHAR16 * +SctPoolPrint ( + IN CONST CHAR16 *Fmt, + ... + ); + +VOID +InitSctShim ( + IN EFI_BOOT_SERVICES *BS, + IN EFI_RUNTIME_SERVICES *RT + ); + +EFI_STATUS +InitSctPrivateData ( + IN OUT UNIT_TEST_STATUS *TestResult, + OUT SCT_HOST_TEST_PRIVATE_DATA *PrivateData + ); + +struct _SCT_HOST_TEST_PRIVATE_DATA { + UINT32 Signature; + EFI_STANDARD_TEST_LIBRARY_PROTOCOL StandardTest; + UNIT_TEST_STATUS *ReturnStatus; +}; + +#define SCT_HOST_TEST_PRIVATE_DATA_FROM_STSL(a) \ + CR(a, SCT_HOST_TEST_PRIVATE_DATA, StandardTest, SCT_HOST_TEST_PRIVATE_DATA_SIGNATURE) + +#endif // SCT_SHIM_H_ diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.c index af2ff557bb8..a0e47d61053 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.c @@ -13,6 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include "../Variable.h" +#include "BlackBoxTest/VariableServicesBBTestMain.h" #define UNIT_TEST_NAME "RuntimeVariableDxe Host-Based Unit Test" #define UNIT_TEST_VERSION "1.0" @@ -364,6 +365,41 @@ DummyTest ( return TestResult; } +#define SCT_TEST_WRAPPER_FUNCTION(TestName) \ + UNIT_TEST_STATUS \ + EFIAPI \ + TestName##Wrapper ( \ + IN UNIT_TEST_CONTEXT Context \ + ) \ + { \ + UNIT_TEST_STATUS Result; \ + SCT_HOST_TEST_PRIVATE_DATA TestData; \ + \ + Result = UNIT_TEST_PASSED; \ + \ + UT_ASSERT_NOT_EFI_ERROR( InitSctPrivateData( &Result, &TestData ) ); \ + TestName (NULL, \ + (VOID*)gRT, \ + EFI_TEST_LEVEL_DEFAULT, \ + (EFI_HANDLE)&TestData); \ + \ + UT_ASSERT_EQUAL(Result, UNIT_TEST_PASSED); \ + return Result; \ + } + +SCT_TEST_WRAPPER_FUNCTION (GetVariableConfTest) +SCT_TEST_WRAPPER_FUNCTION (GetNextVariableNameConfTest) +SCT_TEST_WRAPPER_FUNCTION (SetVariableConfTest) +SCT_TEST_WRAPPER_FUNCTION (QueryVariableInfoConfTest) +SCT_TEST_WRAPPER_FUNCTION (GetVariableFuncTest) +SCT_TEST_WRAPPER_FUNCTION (GetNextVariableNameFuncTest) +SCT_TEST_WRAPPER_FUNCTION (SetVariableFuncTest) +SCT_TEST_WRAPPER_FUNCTION (QueryVariableInfoFuncTest) +SCT_TEST_WRAPPER_FUNCTION (HardwareErrorRecordConfTest) +SCT_TEST_WRAPPER_FUNCTION (HardwareErrorRecordFuncTest) +SCT_TEST_WRAPPER_FUNCTION (MultipleStressTest) +SCT_TEST_WRAPPER_FUNCTION (OverflowStressTest) + EFI_STATUS EFIAPI VarCheckPolicyLibConstructor ( @@ -417,6 +453,10 @@ UefiTestMain ( EFI_STATUS Status; UNIT_TEST_FRAMEWORK_HANDLE Framework; UNIT_TEST_SUITE_HANDLE GenericTests; + UNIT_TEST_SUITE_HANDLE SctConformanceTests; + UNIT_TEST_SUITE_HANDLE SctFunctionalTests; + UNIT_TEST_SUITE_HANDLE SctHwErrTests; + UNIT_TEST_SUITE_HANDLE SctStressTests; Framework = NULL; @@ -443,6 +483,62 @@ UefiTestMain ( AddTestCase (GenericTests, "Dummy Test", "Dummy", DummyTest, NULL, NULL, NULL); + // + // Populate the SCT Conformance TDS 3.1-3.4 Unit Test Suite + // + Status = CreateUnitTestSuite (&SctConformanceTests, Framework, "SCT Conformance Tests Suite", "SctConformance", NULL, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SctConformanceTests\n")); + Status = EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + AddTestCase (SctConformanceTests, "GetVariableConf Test", "GetVariableConf", GetVariableConfTestWrapper, NULL, NULL, NULL); + AddTestCase (SctConformanceTests, "GetNextVariableNameConf Test", "GetNextVariableNameConf", GetNextVariableNameConfTestWrapper, NULL, NULL, NULL); + AddTestCase (SctConformanceTests, "SetVariableConf Test", "SetVariableConf", SetVariableConfTestWrapper, NULL, NULL, NULL); + AddTestCase (SctConformanceTests, "QueryVariableInfoConf Test", "QueryVariableInfoConf", QueryVariableInfoConfTestWrapper, NULL, NULL, NULL); + + // + // Populate the SCT Functional TDS 4.1-4.4 Unit Test Suite + // + Status = CreateUnitTestSuite (&SctFunctionalTests, Framework, "SCT Functional Tests Suite", "SctFunctional", NULL, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SctFunctionalTests\n")); + Status = EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + AddTestCase (SctFunctionalTests, "GetVariableFunc Test", "GetVariableFunc", GetVariableFuncTestWrapper, NULL, NULL, NULL); + AddTestCase (SctFunctionalTests, "GetNextVariableNameFunc Test", "GetNextVariableNameFunc", GetNextVariableNameFuncTestWrapper, NULL, NULL, NULL); + AddTestCase (SctFunctionalTests, "SetVariableFunc Test", "SetVariableFunc", SetVariableFuncTestWrapper, NULL, NULL, NULL); + AddTestCase (SctFunctionalTests, "QueryVariableInfoFunc Test", "QueryVariableInfoFunc", QueryVariableInfoFuncTestWrapper, NULL, NULL, NULL); + + // + // Populate the SCT HwErrRecord Unit Test Suite + // + Status = CreateUnitTestSuite (&SctHwErrTests, Framework, "SCT HwErrRecord Tests Suite", "SctHwErr", NULL, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SctHwErrTests\n")); + Status = EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + AddTestCase (SctHwErrTests, "HardwareErrorRecordConf Test", "HardwareErrorRecordConf", HardwareErrorRecordConfTestWrapper, NULL, NULL, NULL); + AddTestCase (SctHwErrTests, "HardwareErrorRecordFunc Test", "HardwareErrorRecordFunc", HardwareErrorRecordFuncTestWrapper, NULL, NULL, NULL); + + // + // Populate the SCT Stress TDS 5.1-5.2 Test Suite + // + Status = CreateUnitTestSuite (&SctStressTests, Framework, "SCT Stress Tests Suite", "SctStress", NULL, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SctStressTests\n")); + Status = EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + AddTestCase (SctStressTests, "MultipleStress Test", "MultipleStress", MultipleStressTestWrapper, NULL, NULL, NULL); + AddTestCase (SctStressTests, "OverflowStress Test", "OverflowStress", OverflowStressTestWrapper, NULL, NULL, NULL); + InitVariableDriver (); Status = RunAllTestSuites (Framework); diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.inf index f1b21bb9b4e..eef404240c4 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableRuntimeDxeUnitTest.inf @@ -23,10 +23,20 @@ [Sources] # Test Harness + SctShim.c + SctShim.h TestData.c VariableRuntimeDxeUnitTest.c VariableRuntimeDxeUnitTest.h VariableTestDataHelpers.c + BlackBoxTest/Guid.c + BlackBoxTest/Guid.h + BlackBoxTest/VariableServicesBBTestConformance.c + BlackBoxTest/VariableServicesBBTestFunction.c + BlackBoxTest/VariableServicesBBTestMain.h + BlackBoxTest/VariableServicesBBTestStress.c + SctInclude/StandardTestLibrary.h + SctInclude/TestLoggingLibrary.h # Files Under Test ../Measurement.c @@ -68,6 +78,7 @@ VariablePolicyLib VariablePolicyHelperLib VariableFlashInfoLib + PrintLib [Protocols] @@ -76,6 +87,7 @@ [Guids] gVariableFlashInfoHobGuid + gEfiHardwareErrorVariableGuid ## SOMETIMES_CONSUMES ## GUID # Signature of Variable store header ## SOMETIMES_PRODUCES ## GUID # Signature of Variable store header