/* Check whether a handle is a valid EFI_HANDLE */
EFI_STATUS UnitTestValidateHandle(IN EFI_HANDLE UserHandle)
/* Check whether a handle is a valid EFI_HANDLE */
EFI_STATUS UnitTestValidateHandle(IN EFI_HANDLE UserHandle)
{
  IHANDLE     *Handle;
  LIST_ENTRY  *Link;
  if (UserHandle == NULL) {
    return EFI_INVALID_PARAMETER;
  }
  for (Link = gHandleList.BackLink; Link != &gHandleList; Link = Link->BackLink) {
    Handle = CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
    if (Handle == (IHANDLE *)UserHandle) {
      return EFI_SUCCESS;
    }
  }
  return EFI_INVALID_PARAMETER;
}