diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc index 134384b11d..ccd1adac1a 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 00119ea019..94627dc508 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestConformance.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestConformance.c @@ -17,9 +17,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 // @@ -28,26 +29,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 ); // @@ -56,148 +57,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 ); // @@ -205,32 +207,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 ); // @@ -238,10 +243,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 @@ -261,10 +266,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; @@ -282,7 +287,7 @@ GetVariableConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -329,6 +334,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. @@ -340,10 +346,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; @@ -361,7 +367,7 @@ GetNextVariableNameConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -407,6 +413,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. @@ -418,10 +425,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; @@ -439,7 +446,7 @@ SetVariableConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -487,15 +494,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 ... @@ -512,13 +519,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 { @@ -536,8 +543,7 @@ GetVariableConfTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -557,6 +563,7 @@ GetVariableConfTestSub1 ( return EFI_SUCCESS; } + /** * GetVariable when VendorGuid is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -568,15 +575,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 ... @@ -593,13 +600,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 { @@ -617,8 +624,7 @@ GetVariableConfTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -638,6 +644,7 @@ GetVariableConfTestSub2 ( return EFI_SUCCESS; } + /** * GetVariable when DataSize is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -649,15 +656,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 ... @@ -684,7 +691,7 @@ GetVariableConfTestSub3 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -734,8 +741,7 @@ GetVariableConfTestSub3 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -766,6 +772,7 @@ GetVariableConfTestSub3 ( return EFI_SUCCESS; } + /** * GetVariable when Data is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -777,16 +784,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 ... @@ -813,7 +820,7 @@ GetVariableConfTestSub4 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -840,13 +847,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 { @@ -864,8 +871,7 @@ GetVariableConfTestSub4 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -896,6 +902,7 @@ GetVariableConfTestSub4 ( return EFI_SUCCESS; } + /** * GetVariable with nonexistent VariableName. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -907,16 +914,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 ... @@ -943,7 +950,7 @@ GetVariableConfTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -976,7 +983,7 @@ GetVariableConfTestSub5 ( 0, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1003,13 +1010,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 { @@ -1027,8 +1034,7 @@ GetVariableConfTestSub5 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); // @@ -1045,7 +1051,7 @@ GetVariableConfTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1075,7 +1081,7 @@ GetVariableConfTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1102,13 +1108,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 { @@ -1126,8 +1132,7 @@ GetVariableConfTestSub5 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); // @@ -1166,6 +1171,7 @@ GetVariableConfTestSub5 ( return Status; } + /** * GetVariable with nonexistent VendorGuid. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1177,16 +1183,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 ... @@ -1205,7 +1211,6 @@ GetVariableConfTestSub6 ( for (DataIndex = 0; DataIndex < 10; DataIndex++) { Data[DataIndex] = (UINT8)DataIndex; } - Status = RT->SetVariable ( L"TestVariable", // VariableName &gTestVendor2Guid, // VendorGuid @@ -1213,7 +1218,7 @@ GetVariableConfTestSub6 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1240,13 +1245,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 { @@ -1264,8 +1269,7 @@ GetVariableConfTestSub6 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); // @@ -1296,6 +1300,7 @@ GetVariableConfTestSub6 ( return EFI_SUCCESS; } + /** * GetVariable without enough DataSize. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1307,16 +1312,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 ... @@ -1343,7 +1348,7 @@ GetVariableConfTestSub7 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1370,16 +1375,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; @@ -1396,29 +1400,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; @@ -1435,32 +1436,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; @@ -1477,16 +1475,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 ); // @@ -1517,6 +1513,7 @@ GetVariableConfTestSub7 ( return EFI_SUCCESS; } + /** * GetNextVariableName when VariableNameSize is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1528,15 +1525,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 ... @@ -1553,11 +1550,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 { @@ -1575,8 +1572,7 @@ GetNextVariableNameConfTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -1596,6 +1592,7 @@ GetNextVariableNameConfTestSub1 ( return EFI_SUCCESS; } + /** * GetNextVariableName when VariableName is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1607,15 +1604,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 ... @@ -1632,11 +1629,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 { @@ -1654,8 +1651,7 @@ GetNextVariableNameConfTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -1675,6 +1671,7 @@ GetNextVariableNameConfTestSub2 ( return EFI_SUCCESS; } + /** * GetNextVariableName when VendorGuid is NULL. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1686,15 +1683,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 ... @@ -1710,13 +1707,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 { @@ -1734,8 +1731,7 @@ GetNextVariableNameConfTestSub3 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -1755,6 +1751,7 @@ GetNextVariableNameConfTestSub3 ( return EFI_SUCCESS; } + /** * GetNextVariableName without enough VariableNameSize. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1766,18 +1763,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 ... @@ -1804,7 +1801,7 @@ GetNextVariableNameConfTestSub4 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1831,13 +1828,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 { @@ -1855,8 +1852,7 @@ GetNextVariableNameConfTestSub4 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_BUFFER_TOO_SMALL + Status, EFI_BUFFER_TOO_SMALL ); // @@ -1887,6 +1883,7 @@ GetNextVariableNameConfTestSub4 ( return EFI_SUCCESS; } + /** * GetNextVariableName after the entire variable list has been returned. * NOTES: Also check GetNextVariableName will not return deleted variable. @@ -1899,18 +1896,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 ... @@ -1937,7 +1934,7 @@ GetNextVariableNameConfTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1970,7 +1967,7 @@ GetNextVariableNameConfTestSub5 ( 0, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1997,26 +1994,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; } @@ -2033,8 +2028,7 @@ GetNextVariableNameConfTestSub5 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); // @@ -2054,6 +2048,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 @@ -2065,18 +2060,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 ... @@ -2103,7 +2098,7 @@ GetNextVariableNameConfTestSub6 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2129,9 +2124,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 ( @@ -2139,17 +2134,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); @@ -2167,8 +2160,7 @@ GetNextVariableNameConfTestSub6 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); Status = RT->SetVariable ( @@ -2179,7 +2171,7 @@ GetNextVariableNameConfTestSub6 ( Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2201,7 +2193,6 @@ GetNextVariableNameConfTestSub6 ( return Status; } - // // Trace ... // @@ -2230,18 +2221,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 ... @@ -2268,7 +2259,7 @@ GetNextVariableNameConfTestSub7 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2295,27 +2286,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'; } } @@ -2331,35 +2320,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; } } @@ -2375,8 +2361,7 @@ GetNextVariableNameConfTestSub7 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); Status = RT->SetVariable ( @@ -2387,7 +2372,7 @@ GetNextVariableNameConfTestSub7 ( Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2409,7 +2394,6 @@ GetNextVariableNameConfTestSub7 ( return Status; } - // // Trace ... // @@ -2427,6 +2411,7 @@ GetNextVariableNameConfTestSub7 ( return EFI_SUCCESS; } + /** * SetVariable when VariableName is an empty string. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2438,15 +2423,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 ... @@ -2490,8 +2475,7 @@ SetVariableConfTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -2511,6 +2495,7 @@ SetVariableConfTestSub1 ( return EFI_SUCCESS; } + /** * SetVariable with invalid combination of attribute bits. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2522,25 +2507,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, @@ -2586,8 +2571,7 @@ SetVariableConfTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -2621,8 +2605,7 @@ SetVariableConfTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -2641,14 +2624,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, @@ -2665,7 +2648,7 @@ SetVariableConfTestSub2 ( for (DataIndex = 0; DataIndex < 10; DataIndex++) { Data[DataIndex] = 10 - (UINT8)DataIndex; - } + } for (SubIndex1 = 0; SubIndex1 < 4; SubIndex1++) { if (Attributes != AttributesArray[SubIndex1]) { @@ -2674,7 +2657,7 @@ SetVariableConfTestSub2 ( ReturnedStatus = RT->SetVariable ( L"TestVariable", // VariableName &gTestVendor1Guid, // VendorGuid - AttributesArray[SubIndex1], // Attributes + AttributesArray[SubIndex1], // Attributes 10, // DataSize Data // Data ); @@ -2687,7 +2670,7 @@ SetVariableConfTestSub2 ( Result = EFI_TEST_ASSERTION_FAILED; } - DataSize = MAX_BUFFER_SIZE; + DataSize = MAX_BUFFER_SIZE; RT->GetVariable ( L"TestVariable", // VariableName &gTestVendor1Guid, // VendorGuid @@ -2702,11 +2685,10 @@ SetVariableConfTestSub2 ( for (DataIndex = 0; DataIndex < 10; DataIndex++) { if (Data[DataIndex] != (UINT8)DataIndex) { Result = EFI_TEST_ASSERTION_FAILED; - break; - } + break; + } } } - // // Record assertion // @@ -2721,6 +2703,7 @@ SetVariableConfTestSub2 ( ReturnedStatus, EFI_INVALID_PARAMETER ); + } } @@ -2733,6 +2716,7 @@ SetVariableConfTestSub2 ( Data // Data ); } + } } @@ -2753,6 +2737,7 @@ SetVariableConfTestSub2 ( return EFI_SUCCESS; } + /** * SetVariable with too large variable. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2764,15 +2749,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 ( @@ -2813,8 +2798,7 @@ SetVariableConfTestSub3 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_INVALID_PARAMETER + Status, EFI_INVALID_PARAMETER ); // @@ -2845,21 +2829,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, @@ -2899,7 +2883,7 @@ SetVariableConfTestSub4 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2932,7 +2916,7 @@ SetVariableConfTestSub4 ( // // Delete the variable again to check results // - + Status = RT->SetVariable ( L"TestVariable", // VariableName &gTestVendor1Guid, // VendorGuid @@ -2944,9 +2928,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; @@ -2963,16 +2946,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 ); } } @@ -3000,10 +2981,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; @@ -3021,12 +3002,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__ @@ -3035,7 +3016,7 @@ QueryVariableInfoConfTest ( // } RT = (EFI_RUNTIME_SERVICES *)ClientInterface; - #if 0 +#if 0 // // QueryVariableInfo with MaximumVariableStorageSize being NULL // @@ -3050,44 +3031,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 ... @@ -3100,8 +3082,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, @@ -3109,7 +3091,7 @@ QueryVariableInfoConfTestSub1 ( &MaximumVariableSize ); - if (Status == EFI_UNSUPPORTED) { + if(Status == EFI_UNSUPPORTED) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3130,6 +3112,7 @@ QueryVariableInfoConfTestSub1 ( EFI_UNSUPPORTED, ValidAttributes[Index] ); + } // @@ -3154,25 +3137,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 ... @@ -3185,7 +3168,7 @@ QueryVariableInfoConfTestSub2 ( ); } - for (Index = 0; ValidAttributes[Index] != 0; Index++) { + for (Index = 0; ValidAttributes[Index] != 0; Index ++) { Status = RT->QueryVariableInfo ( ValidAttributes[Index], &MaximumVariableStorageSize, @@ -3193,7 +3176,7 @@ QueryVariableInfoConfTestSub2 ( &MaximumVariableSize ); - if (Status == EFI_UNSUPPORTED) { + if(Status == EFI_UNSUPPORTED) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3214,6 +3197,7 @@ QueryVariableInfoConfTestSub2 ( EFI_UNSUPPORTED, ValidAttributes[Index] ); + } // @@ -3233,30 +3217,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 ... @@ -3269,7 +3254,7 @@ QueryVariableInfoConfTestSub3 ( ); } - for (Index = 0; ValidAttributes[Index] != 0; Index++) { + for (Index = 0; ValidAttributes[Index] != 0; Index ++) { Status = RT->QueryVariableInfo ( ValidAttributes[Index], &MaximumVariableStorageSize, @@ -3277,7 +3262,7 @@ QueryVariableInfoConfTestSub3 ( NULL ); - if (Status == EFI_UNSUPPORTED) { + if(Status == EFI_UNSUPPORTED) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3298,6 +3283,7 @@ QueryVariableInfoConfTestSub3 ( EFI_UNSUPPORTED, ValidAttributes[Index] ); + } // @@ -3317,22 +3303,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 ... @@ -3352,7 +3340,7 @@ QueryVariableInfoConfTestSub4 ( &MaximumVariableSize ); - if (Status == EFI_INVALID_PARAMETER) { + if(Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3395,24 +3383,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 ... @@ -3425,7 +3413,8 @@ QueryVariableInfoConfTestSub5 ( ); } - for (Index = 0; InvalidAttributes[Index] != 0; Index++) { + for (Index = 0; InvalidAttributes[Index] != 0; Index ++) { + Status = RT->QueryVariableInfo ( InvalidAttributes[Index], &MaximumVariableStorageSize, @@ -3433,7 +3422,7 @@ QueryVariableInfoConfTestSub5 ( &MaximumVariableSize ); - if (Status == EFI_INVALID_PARAMETER) { + if(Status == EFI_INVALID_PARAMETER) { Result = EFI_TEST_ASSERTION_PASSED; } else { Result = EFI_TEST_ASSERTION_FAILED; @@ -3454,6 +3443,7 @@ QueryVariableInfoConfTestSub5 ( EFI_INVALID_PARAMETER, InvalidAttributes[Index] ); + } // @@ -3472,17 +3462,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; @@ -3490,39 +3479,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 // @@ -3532,7 +3522,7 @@ HardwareErrorRecordConfTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -3545,203 +3535,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; @@ -3751,16 +3736,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 12a07df428..ef7413ee83 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestFunction.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestFunction.c @@ -25,26 +25,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 ); // @@ -53,88 +53,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 @@ -159,10 +159,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; @@ -180,7 +180,7 @@ GetVariableFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -197,6 +197,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. @@ -208,10 +209,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; @@ -229,7 +230,7 @@ GetNextVariableNameFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -246,6 +247,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. @@ -257,10 +259,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; @@ -268,7 +270,6 @@ SetVariableFuncTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; - // UINTN RecoveryDataSize; // UINT8 *RecoveryData; @@ -281,7 +282,7 @@ SetVariableFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -368,6 +369,7 @@ SetVariableFuncTest ( return EFI_SUCCESS; } + /** * GetVariable when the variable exists. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -379,22 +381,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, @@ -434,7 +436,7 @@ GetVariableFuncTestSub1 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -455,13 +457,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); @@ -469,8 +471,7 @@ GetVariableFuncTestSub1 ( // Check results // if ((Status == EFI_SUCCESS) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -495,8 +496,7 @@ GetVariableFuncTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -504,10 +504,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 ); // @@ -516,23 +514,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++) { @@ -557,8 +554,7 @@ GetVariableFuncTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -567,12 +563,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 ); // @@ -605,6 +598,7 @@ GetVariableFuncTestSub1 ( return EFI_SUCCESS; } + /** * GetNextVariableName when the next variable exists. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -616,23 +610,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, @@ -672,7 +666,7 @@ GetNextVariableNameFuncTestSub1 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -691,27 +685,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; } @@ -763,6 +756,7 @@ GetNextVariableNameFuncTestSub1 ( return EFI_SUCCESS; } + /** * SetVariable when the variable does not exist. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -774,25 +768,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, @@ -832,7 +826,7 @@ SetVariableFuncTestSub1 ( 20, // DataSize Data2 // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -870,14 +864,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, @@ -896,14 +890,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, @@ -921,11 +915,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++) { @@ -957,8 +950,7 @@ SetVariableFuncTestSub1 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -967,12 +959,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 ); // @@ -985,7 +974,7 @@ SetVariableFuncTestSub1 ( 0, // DataSize Data // Data ); - + Status = RT->SetVariable ( L"TestVariable", // VariableName &gTestVendor2Guid, // VendorGuid @@ -993,6 +982,7 @@ SetVariableFuncTestSub1 ( 0, // DataSize Data // Data ); + } } @@ -1013,6 +1003,7 @@ SetVariableFuncTestSub1 ( return EFI_SUCCESS; } + /** * SetVariable when the variable exists. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1024,23 +1015,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, @@ -1080,7 +1071,7 @@ SetVariableFuncTestSub2 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1118,14 +1109,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, @@ -1143,10 +1134,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++) { @@ -1171,8 +1161,7 @@ SetVariableFuncTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -1181,12 +1170,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 ); // @@ -1212,14 +1198,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, @@ -1237,10 +1223,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++) { @@ -1265,8 +1250,7 @@ SetVariableFuncTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -1275,12 +1259,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 ); // @@ -1306,14 +1287,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, @@ -1331,10 +1312,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++) { @@ -1359,8 +1339,7 @@ SetVariableFuncTestSub2 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -1369,12 +1348,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 ); // @@ -1407,6 +1383,7 @@ SetVariableFuncTestSub2 ( return EFI_SUCCESS; } + /** * SetVariable when the similar variable exists. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1418,23 +1395,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, @@ -1474,7 +1451,7 @@ SetVariableFuncTestSub3 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1503,7 +1480,7 @@ SetVariableFuncTestSub3 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1541,14 +1518,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, @@ -1566,10 +1543,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++) { @@ -1594,8 +1570,7 @@ SetVariableFuncTestSub3 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - ReturnedStatus, - EFI_SUCCESS + ReturnedStatus, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -1604,26 +1579,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, @@ -1642,8 +1614,7 @@ SetVariableFuncTestSub3 ( // Check results // if ((Attributes == AttributesArray[SubIndex]) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -1676,26 +1647,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, @@ -1714,8 +1682,7 @@ SetVariableFuncTestSub3 ( // Check results // if ((Attributes == AttributesArray[SubIndex]) && - (DataSize == 10)) - { + (DataSize == 10 )) { Result = EFI_TEST_ASSERTION_PASSED; for (DataIndex = 0; DataIndex < 10; DataIndex++) { @@ -1748,12 +1715,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 ); // @@ -1802,6 +1766,7 @@ SetVariableFuncTestSub3 ( return EFI_SUCCESS; } + /** * SetVariable when the DataSize is 0. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1813,23 +1778,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, @@ -1869,7 +1834,7 @@ SetVariableFuncTestSub4 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -1903,20 +1868,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; @@ -1934,16 +1898,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 ); } } @@ -1965,6 +1927,7 @@ SetVariableFuncTestSub4 ( return EFI_SUCCESS; } + /** * SetVariable when the Attributes is 0. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -1976,23 +1939,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, @@ -2032,7 +1995,7 @@ SetVariableFuncTestSub5 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2062,24 +2025,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; @@ -2097,16 +2060,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 ); } } @@ -2128,6 +2089,7 @@ SetVariableFuncTestSub5 ( return EFI_SUCCESS; } + /** * Non-volatile variable exists after system reset. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2141,26 +2103,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 }; @@ -2228,7 +2190,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; @@ -2248,7 +2210,7 @@ SetVariableFuncTestSub6 ( // // Check results // - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2298,21 +2260,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++) { @@ -2337,8 +2298,7 @@ SetVariableFuncTestSub6 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); StandardLib->RecordMessage ( @@ -2347,12 +2307,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 ); // @@ -2393,6 +2350,7 @@ SetVariableFuncTestSub6 ( return EFI_SUCCESS; } + /** * Volatile variable does not exist after system reset. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -2406,26 +2364,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 }; @@ -2493,7 +2451,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; @@ -2513,7 +2471,7 @@ SetVariableFuncTestSub7 ( // // Check results // - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -2561,13 +2519,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 @@ -2590,8 +2548,7 @@ SetVariableFuncTestSub7 ( L"%a:%d:Status - %r, Expected - %r", __FILE__, (UINTN)__LINE__, - Status, - EFI_NOT_FOUND + Status, EFI_NOT_FOUND ); gtBS->FreePool (VariableName); @@ -2627,7 +2584,7 @@ SetVariableFuncTestSub7 ( // UINT32 UnicodeStrLength ( - IN CHAR16 *String + IN CHAR16 *String ) { UINT32 Count; @@ -2647,10 +2604,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; @@ -2668,12 +2625,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__ @@ -2689,37 +2646,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 ... // @@ -2730,8 +2687,8 @@ QueryVariableInfoFuncTestSub1 ( L"TDS 4.4.2.1" ); } - - for (Index = 0; ValidAttributes[Index] != 0; Index++) { + + for (Index = 0; ValidAttributes[Index] != 0; Index ++) { // // QueryVariableInfo 1 // @@ -2746,7 +2703,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 ( @@ -2766,7 +2723,7 @@ QueryVariableInfoFuncTestSub1 ( &RemainingVariableStorageSize[1], &MaximumVariableSize[1] ); - + // // Call SetVariable service to delete the variable inserted just now // @@ -2780,7 +2737,7 @@ QueryVariableInfoFuncTestSub1 ( // // QueryVariableInfo 3 - // + // QueryVarStatus[2] = RT->QueryVariableInfo ( ValidAttributes[Index], &MaximumVariableStorageSize[2], @@ -2789,39 +2746,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 @@ -2863,16 +2818,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; @@ -2880,35 +2835,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 // @@ -2918,7 +2874,7 @@ HardwareErrorRecordFuncTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -2931,7 +2887,7 @@ HardwareErrorRecordFuncTest ( L"TDS" ); } - + // // Allocate memory for recovery data // @@ -2947,7 +2903,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 @@ -2965,116 +2921,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] @@ -3082,7 +3038,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 // @@ -3090,7 +3046,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] @@ -3100,46 +3056,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 b7239de37e..5e50812ee8 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestMain.h +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestMain.h @@ -21,19 +21,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 } } @@ -62,7 +62,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 }} @@ -78,23 +78,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 }} @@ -107,25 +108,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 @@ -136,10 +137,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 ); // @@ -147,10 +148,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 ); // @@ -158,51 +159,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 ); // @@ -210,10 +211,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 ); // @@ -221,51 +222,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 ); // @@ -273,10 +274,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 ); // @@ -289,14 +290,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 6f9d2c999d..0a9c2c9d5c 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestStress.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/BlackBoxTest/VariableServicesBBTestStress.c @@ -17,7 +17,7 @@ Module Name: #include "VariableServicesBBTestMain.h" -#define MULTIPLE_TEST_TIMES 50 +#define MULTIPLE_TEST_TIMES 50 // // Prototypes (external) @@ -25,18 +25,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 ); // @@ -45,31 +45,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 ); // @@ -87,10 +87,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; @@ -108,7 +108,7 @@ MultipleStressTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -135,6 +135,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. @@ -146,10 +147,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; @@ -157,7 +158,6 @@ OverflowStressTest ( EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib; EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *RecoveryLib; EFI_TEST_LOGGING_LIBRARY_PROTOCOL *LoggingLib; - // UINTN RecoveryDataSize; // UINT8 *RecoveryData; @@ -170,7 +170,7 @@ OverflowStressTest ( &RecoveryLib, &LoggingLib ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return Status; } @@ -212,6 +212,7 @@ OverflowStressTest ( // step2: Status = OverflowStressTestSub1 (RT, StandardLib, RecoveryLib, LoggingLib); + // // Free resources // @@ -224,6 +225,7 @@ OverflowStressTest ( return EFI_SUCCESS; } + /** * Multiple test for GetVariable. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -235,18 +237,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 ... @@ -273,7 +275,7 @@ MultipleStressTestSub1 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -301,13 +303,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 { @@ -326,8 +328,7 @@ MultipleStressTestSub1 ( __FILE__, (UINTN)__LINE__, Index, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); } @@ -359,6 +360,7 @@ MultipleStressTestSub1 ( return EFI_SUCCESS; } + /** * Multiple test for GetNextVariableName. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -370,19 +372,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 ... @@ -409,7 +411,7 @@ MultipleStressTestSub2 ( 10, // DataSize Data // Data ); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { StandardLib->RecordAssertion ( StandardLib, EFI_TEST_ASSERTION_WARNING, @@ -436,13 +438,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 { @@ -461,8 +464,7 @@ MultipleStressTestSub2 ( __FILE__, (UINTN)__LINE__, Index, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); } @@ -494,6 +496,7 @@ MultipleStressTestSub2 ( return EFI_SUCCESS; } + /** * Multiple test for SetVariable. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -505,16 +508,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 ... @@ -563,8 +566,7 @@ MultipleStressTestSub3 ( __FILE__, (UINTN)__LINE__, Index, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); } @@ -604,8 +606,7 @@ MultipleStressTestSub3 ( __FILE__, (UINTN)__LINE__, Index, - Status, - EFI_SUCCESS + Status, EFI_SUCCESS ); } @@ -637,6 +638,7 @@ MultipleStressTestSub3 ( return EFI_SUCCESS; } + /** * Reclaim test with system reset. * @param StandardLib A pointer to EFI_STANDARD_TEST_LIBRARY_PROTOCOL @@ -650,18 +652,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; @@ -737,7 +738,7 @@ OverflowStressTestSub1 ( gtBS->FreePool (VariableName); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { break; } } @@ -782,7 +783,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 0000000000..09e111a6cd --- /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 0000000000..12d48be889 --- /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 af2ff557bb..a0e47d6105 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 f1b21bb9b4..eef404240c 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