Re: [edk2] [PATCH] uefi-sct/SctPkg:Implement the iSCSI devicepath to text

2018-10-16 Thread Supreeth Venkatesh




On 10/14/2018 03:25 AM, Eric Jin wrote:

Cc: Supreeth Venkatesh 
Cc: Jiaxin Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Jin 
---
  .../DevicePathToTextBBTestCoverage.c  | 43 ++-
  .../BlackBoxTest/DevicePathToTextBBTestMain.c | 26 +--
  .../DevicePathToText/BlackBoxTest/Guid.c  |  1 +
  .../DevicePathToText/BlackBoxTest/Guid.h  |  7 +++
  4 files changed, 73 insertions(+), 4 deletions(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
index c30af434..14c4c460 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
@@ -2202,7 +2202,48 @@ DevicePathToTextConvertDeviceNodeToTextCoverageTest (
  SctFreePool (Text);
}
  
-

+  //
+  // iSCSI(Name,0x12AB,0x00567800,CRC32C,None,CHAP_BI,TCP)
+  //
+  pDeviceNode1 = DevicePathUtilities->CreateDeviceNode (0x3, 0x13, sizeof 
(ISCSI_DEVICE_PATH_WITH_NAME) + 4);

Why 0x03, 0x13 and + 4? - Magic Numbers.
  
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->NetworkProtocol = 0x0;  //TCP

+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->LoginOption = 0x0002;

Magic Number 2.

+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->Lun = 0x00785600;

Magic Number

+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->TargetPortalGroupTag = 0x12AB;

Magic Number.

+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[0] = 'N';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[1] = 'a';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[2] = 'm';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[3] = 'e';
+
+  Text = DevicePathToText->ConvertDeviceNodeToText (pDeviceNode1, FALSE, 
FALSE);
+  pDeviceNode2 = SctConvertTextToDeviceNode(Text);
+
+  if ((pDeviceNode2 != NULL) && (SctCompareMem (pDeviceNode2, pDeviceNode1, 
SctDevicePathNodeLength(pDeviceNode1)) == 0)) {
+AssertionType = EFI_TEST_ASSERTION_PASSED;
+  } else {
+AssertionType = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+StandardLib,
+AssertionType,
+gDevicePathToTextBBTestFunctionAssertionGuid135,
+L"EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL - ConvertDeviceNodeToText must 
correctly recover the converting ConvertTextToDeviceNode has acted on the device node 
string",
+L"%a:%d: Convert result: %s - 
Expected:iSCSI(MyTargetName,0x12AB,0x00567800,CRC32C,None,CHAP_BI,TCP)",

Magic Numbers.

+__FILE__,
+(UINTN)__LINE__,
+Text
+);
+  if (pDeviceNode1 != NULL) {
+SctFreePool (pDeviceNode1);
+  }
+  if (pDeviceNode2 != NULL) {
+SctFreePool (pDeviceNode2);
+  }
+  if (Text != NULL) {
+SctFreePool (Text);
+  }
+
return EFI_SUCCESS;
  }
  
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c

index 41cf217b..d755227c 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
@@ -2437,6 +2437,7 @@ BuildiSCSIDeviceNode (
CHAR16 *LunStr;
UINT16 Options;
UINT64 LunNum;
+  UINT64 TempLunNum;
  
Status = GetNextRequiredParam(, L"TargetName", , );

if ((!EFI_ERROR(Status)) && (ParamIdentifierVal != NULL)) {
@@ -2459,7 +2460,7 @@ BuildiSCSIDeviceNode (
return NULL;
}
  
-  Length = sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (SctStrLen (NameStr) * 2 + 2);

+  Length = sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (SctStrLen 
(NameStr));
iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (0x3, 0x13, 
Length);
if (iSCSI == NULL) {
return NULL;
@@ -2499,7 +2500,7 @@ BuildiSCSIDeviceNode (
  if (SctStrCmp (ParamIdentifierVal, L"CRC32C") == 0) {
Options |= 0x0002;
  }
-   break;
+break;
  
case 1:  // DataDigest

  if (SctStrCmp (ParamIdentifierVal, L"CRC32C") == 0) {
@@ -2514,6 +2515,9 @@ BuildiSCSIDeviceNode (
  if (SctStrCmp (ParamIdentifierVal, L"CHAP_UNI") == 0) {
Options |= 0x1000;
  }
+if (SctStrCmp (ParamIdentifierVal, L"CHAP_BI") == 0) {
+  Options |= 0x;
+}
  break;
  
case 3:  // Protocol

@@ -2533,8 +2537,24 @@ 

Re: [edk2] [PATCH] uefi-sct/SctPkg:Implement the iSCSI devicepath to text

2018-10-15 Thread Supreeth Venkatesh
FYI

On 10/15/2018 03:33 AM, Supreeth Venkatesh wrote:


On 10/14/2018 03:25 AM, Eric Jin wrote:

Cc: Supreeth Venkatesh 

Cc: Jiaxin Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Jin 
---
  .../DevicePathToTextBBTestCoverage.c  | 43 ++-
  .../BlackBoxTest/DevicePathToTextBBTestMain.c | 26 +--
  .../DevicePathToText/BlackBoxTest/Guid.c  |  1 +
  .../DevicePathToText/BlackBoxTest/Guid.h  |  7 +++
  4 files changed, 73 insertions(+), 4 deletions(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
index c30af434..14c4c460 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
@@ -2202,7 +2202,48 @@ DevicePathToTextConvertDeviceNodeToTextCoverageTest (
  SctFreePool (Text);
}
  -
+  //
+  // iSCSI(Name,0x12AB,0x00567800,CRC32C,None,CHAP_BI,TCP)
+  //
+  pDeviceNode1 = DevicePathUtilities->CreateDeviceNode (0x3, 0x13, sizeof 
(ISCSI_DEVICE_PATH_WITH_NAME) + 4);
Why 0x03, 0x13 and + 4? - Magic Numbers.

  +  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->NetworkProtocol = 0x0;  
//TCP
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->LoginOption = 0x0002;
Magic Number 2.

+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->Lun = 0x00785600;
Magic Number

+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->TargetPortalGroupTag = 0x12AB;
Magic Number.

+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[0] = 'N';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[1] = 'a';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[2] = 'm';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[3] = 'e';
+
+  Text = DevicePathToText->ConvertDeviceNodeToText (pDeviceNode1, FALSE, 
FALSE);
+  pDeviceNode2 = SctConvertTextToDeviceNode(Text);
+
+  if ((pDeviceNode2 != NULL) && (SctCompareMem (pDeviceNode2, pDeviceNode1, 
SctDevicePathNodeLength(pDeviceNode1)) == 0)) {
+AssertionType = EFI_TEST_ASSERTION_PASSED;
+  } else {
+AssertionType = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+StandardLib,
+AssertionType,
+gDevicePathToTextBBTestFunctionAssertionGuid135,
+L"EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL - ConvertDeviceNodeToText 
must correctly recover the converting ConvertTextToDeviceNode has acted on the 
device node string",
+L"%a:%d: Convert result: %s - 
Expected:iSCSI(MyTargetName,0x12AB,0x00567800,CRC32C,None,CHAP_BI,TCP)",
Magic Numbers.

+__FILE__,
+(UINTN)__LINE__,
+Text
+);
+  if (pDeviceNode1 != NULL) {
+SctFreePool (pDeviceNode1);
+  }
+  if (pDeviceNode2 != NULL) {
+SctFreePool (pDeviceNode2);
+  }
+  if (Text != NULL) {
+SctFreePool (Text);
+  }
+
return EFI_SUCCESS;
  }
  diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
index 41cf217b..d755227c 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
@@ -2437,6 +2437,7 @@ BuildiSCSIDeviceNode (
CHAR16 *LunStr;
UINT16 Options;
UINT64 LunNum;
+  UINT64 TempLunNum;
  Status = GetNextRequiredParam(, L"TargetName", 
, );
if ((!EFI_ERROR(Status)) && (ParamIdentifierVal != NULL)) {
@@ -2459,7 +2460,7 @@ BuildiSCSIDeviceNode (
return NULL;
}
  -  Length = sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (SctStrLen 
(NameStr) * 2 + 2);
+  Length = sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (SctStrLen 
(NameStr));
iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (0x3, 0x13, 
Length);
if (iSCSI == NULL) {
return NULL;
@@ -2499,7 +2500,7 @@ BuildiSCSIDeviceNode (
  if (SctStrCmp (ParamIdentifierVal, L"CRC32C") == 0) {
Options |= 0x0002;
  }
-break;
+break;
  case 1:  // DataDigest
  if (SctStrCmp (ParamIdentifierVal, L"CRC32C") == 0) {
@@ -2514,6 +2515,9 @@ BuildiSCSIDeviceNode (
  if (SctStrCmp (ParamIdentifierVal, L"CHAP_UNI") == 0) {
Options |= 0x1000;
  }
+if (SctStrCmp (ParamIdentifierVal, L"CHAP_BI") == 

[edk2] [PATCH] uefi-sct/SctPkg:Implement the iSCSI devicepath to text

2018-10-13 Thread Eric Jin
Cc: Supreeth Venkatesh 
Cc: Jiaxin Wu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Jin 
---
 .../DevicePathToTextBBTestCoverage.c  | 43 ++-
 .../BlackBoxTest/DevicePathToTextBBTestMain.c | 26 +--
 .../DevicePathToText/BlackBoxTest/Guid.c  |  1 +
 .../DevicePathToText/BlackBoxTest/Guid.h  |  7 +++
 4 files changed, 73 insertions(+), 4 deletions(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
index c30af434..14c4c460 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestCoverage.c
@@ -2202,7 +2202,48 @@ DevicePathToTextConvertDeviceNodeToTextCoverageTest (
 SctFreePool (Text);
   }
 
-  
+  //
+  // iSCSI(Name,0x12AB,0x00567800,CRC32C,None,CHAP_BI,TCP)
+  //
+  pDeviceNode1 = DevicePathUtilities->CreateDeviceNode (0x3, 0x13, sizeof 
(ISCSI_DEVICE_PATH_WITH_NAME) + 4);  
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->NetworkProtocol = 0x0;  //TCP
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->LoginOption = 0x0002;
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->Lun = 0x00785600;
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->TargetPortalGroupTag = 0x12AB;
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[0] = 'N';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[1] = 'a';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[2] = 'm';
+  ((ISCSI_DEVICE_PATH_WITH_NAME *)pDeviceNode1)->iSCSITargetName[3] = 'e';
+
+  Text = DevicePathToText->ConvertDeviceNodeToText (pDeviceNode1, FALSE, 
FALSE);
+  pDeviceNode2 = SctConvertTextToDeviceNode(Text);
+
+  if ((pDeviceNode2 != NULL) && (SctCompareMem (pDeviceNode2, pDeviceNode1, 
SctDevicePathNodeLength(pDeviceNode1)) == 0)) {
+AssertionType = EFI_TEST_ASSERTION_PASSED;
+  } else {
+AssertionType = EFI_TEST_ASSERTION_FAILED;
+  }
+
+  StandardLib->RecordAssertion (
+StandardLib,
+AssertionType,
+gDevicePathToTextBBTestFunctionAssertionGuid135,
+L"EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL - ConvertDeviceNodeToText 
must correctly recover the converting ConvertTextToDeviceNode has acted on the 
device node string",
+L"%a:%d: Convert result: %s - 
Expected:iSCSI(MyTargetName,0x12AB,0x00567800,CRC32C,None,CHAP_BI,TCP)",
+__FILE__,
+(UINTN)__LINE__,
+Text
+);
+  if (pDeviceNode1 != NULL) {
+SctFreePool (pDeviceNode1);
+  }
+  if (pDeviceNode2 != NULL) {
+SctFreePool (pDeviceNode2);
+  }
+  if (Text != NULL) {
+SctFreePool (Text);
+  }
+
   return EFI_SUCCESS;
 }
 
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
index 41cf217b..d755227c 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/DevicePathToText/BlackBoxTest/DevicePathToTextBBTestMain.c
@@ -2437,6 +2437,7 @@ BuildiSCSIDeviceNode (
   CHAR16 *LunStr;
   UINT16 Options;
   UINT64 LunNum;
+  UINT64 TempLunNum;
 
   Status = GetNextRequiredParam(, L"TargetName", 
, );
   if ((!EFI_ERROR(Status)) && (ParamIdentifierVal != NULL)) {
@@ -2459,7 +2460,7 @@ BuildiSCSIDeviceNode (
return NULL;
   }
 
-  Length = sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (SctStrLen 
(NameStr) * 2 + 2);
+  Length = sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (SctStrLen 
(NameStr));
   iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode (0x3, 0x13, Length);
   if (iSCSI == NULL) {
return NULL;
@@ -2499,7 +2500,7 @@ BuildiSCSIDeviceNode (
 if (SctStrCmp (ParamIdentifierVal, L"CRC32C") == 0) {
   Options |= 0x0002;
 }
-   break;
+break;
 
   case 1:  // DataDigest
 if (SctStrCmp (ParamIdentifierVal, L"CRC32C") == 0) {
@@ -2514,6 +2515,9 @@ BuildiSCSIDeviceNode (
 if (SctStrCmp (ParamIdentifierVal, L"CHAP_UNI") == 0) {
   Options |= 0x1000;
 }
+if (SctStrCmp (ParamIdentifierVal, L"CHAP_BI") == 0) {
+  Options |= 0x;
+}  
 break;
 
   case 3:  // Protocol
@@ -2533,8 +2537,24 @@ BuildiSCSIDeviceNode (
 
   SctUnicodeToAscii (iSCSI->iSCSITargetName, NameStr, SctStrLen (NameStr));
   iSCSI->TargetPortalGroupTag = (UINT16) SctStrToUInt (PortalGroupStr);
-  SctStrToUInt64