public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 2/2] uefi-sct/SctPkg: Correct BBTestEraseBlocks behavior (EFI_BLOCK_IO_PROTOCOL)
@ 2020-11-02  9:59 Chen, ArvinX
  2020-11-11 20:56 ` [edk2-devel] " Samer El-Haj-Mahmoud
  0 siblings, 1 reply; 8+ messages in thread
From: Chen, ArvinX @ 2020-11-02  9:59 UTC (permalink / raw)
  To: devel; +Cc: G Edhaya Chandran, Eric Jin

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3022

The storage device erase behavior may have two possibilities:
 1.Write all data into "0"
 2.Write all data into "1"
but now tool behavior can only check case 1 (Write all data into "0"),
so we need add the other case into SCT tool to correct the test behavior.

Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>
Cc: Eric Jin <eric.jin@intel.com>
Signed-off-by: ArvinX Chen <arvinx.chen@intel.com>
---
 .../BlackBoxTest/EraseBlockBBTestFunction.c   | 55 +++++++++++++++----
 1 file changed, 43 insertions(+), 12 deletions(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
index cbf43e1d..dbbb70c6 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
@@ -71,6 +71,7 @@ BBTestEraseBlocksFunctionTest (
   UINT64                                Index;
   UINTN                                 Index1;
   UINTN                                 Remainder;
+  UINT64                                EraseCounter;
 
   EFI_ERASE_BLOCK_TOKEN                 Token;
   EFI_BLOCK_IO2_TOKEN                   BlockIo2Token;
@@ -223,26 +224,41 @@ BBTestEraseBlocksFunctionTest (
         // Read the data with 0, the first/last block should not be erased
         ReadStatus = BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer2);
         if (ReadStatus == EFI_SUCCESS) {
-          for (Index1 = 0; Index1 < BlockSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = 0, EraseCounter = 0; Index1 < BlockSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero1 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
+            IsZero1 = FALSE;
+          }
 
-          for (Index1 = BlockSize; Index1 < BufferSize - BlockSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = BlockSize, EraseCounter = 0; Index1 < BufferSize - BlockSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero2 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=(BufferSize - (BlockSize*2))) {
+            IsZero2 = FALSE;
+          }
 
-          for (Index1 = BufferSize - BlockSize; Index1 < BufferSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = BufferSize - BlockSize, EraseCounter = 0; Index1 < BufferSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero3 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
+            IsZero3 = FALSE;
+          }
 
           if ((EraseStatus == EFI_SUCCESS) && (IsZero1 == FALSE) && (IsZero2 == TRUE) && ((IsZero3 == FALSE)))
             AssertionType = EFI_TEST_ASSERTION_PASSED;
@@ -492,26 +508,41 @@ BlockIo2:
         // Read the data with 0, the first/last block should not be erased
         ReadStatus = BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer2);
         if (ReadStatus == EFI_SUCCESS) {
-          for (Index1 = 0; Index1 < BlockSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = 0, EraseCounter = 0; Index1 < BlockSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero1 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
+            IsZero1 = FALSE;
+          }
 
-          for (Index1 = BlockSize; Index1 < BufferSize - BlockSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = BlockSize, EraseCounter = 0; Index1 < BufferSize - BlockSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero2 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=(BufferSize - (BlockSize*2))) {
+            IsZero2 = FALSE;
+          }
 
-          for (Index1 = BufferSize - BlockSize; Index1 < BufferSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = BufferSize - BlockSize, EraseCounter = 0; Index1 < BufferSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero3 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
+            IsZero3 = FALSE;
+          }
 
           if ((EraseStatus == EFI_SUCCESS) && (IsZero1 == FALSE) && (IsZero2 == TRUE) && ((IsZero3 == FALSE)))
             AssertionType = EFI_TEST_ASSERTION_PASSED;
-- 
2.26.2.windows.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH 2/2] uefi-sct/SctPkg: Correct BBTestEraseBlocks behavior (EFI_BLOCK_IO_PROTOCOL)
@ 2020-10-27  6:17 Chen, ArvinX
  0 siblings, 0 replies; 8+ messages in thread
From: Chen, ArvinX @ 2020-10-27  6:17 UTC (permalink / raw)
  To: devel; +Cc: Eric Jin

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3022

The storage device erase behavior may have two possibilities:
 1.Write all data into "0"
 2.Write all data into "1"
but now tool behavior can only check case 1 (Write all data into "0"),
so we need add the other case into SCT tool to correct the test behavior.

Cc: Eric Jin <eric.jin@intel.com>
Signed-off-by: ArvinX Chen <arvinx.chen@intel.com>
---
 .../BlackBoxTest/EraseBlockBBTestFunction.c   | 55 +++++++++++++++----
 1 file changed, 43 insertions(+), 12 deletions(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
index cbf43e1d..dbbb70c6 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
@@ -71,6 +71,7 @@ BBTestEraseBlocksFunctionTest (
   UINT64                                Index;
   UINTN                                 Index1;
   UINTN                                 Remainder;
+  UINT64                                EraseCounter;
 
   EFI_ERASE_BLOCK_TOKEN                 Token;
   EFI_BLOCK_IO2_TOKEN                   BlockIo2Token;
@@ -223,26 +224,41 @@ BBTestEraseBlocksFunctionTest (
         // Read the data with 0, the first/last block should not be erased
         ReadStatus = BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer2);
         if (ReadStatus == EFI_SUCCESS) {
-          for (Index1 = 0; Index1 < BlockSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = 0, EraseCounter = 0; Index1 < BlockSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero1 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
+            IsZero1 = FALSE;
+          }
 
-          for (Index1 = BlockSize; Index1 < BufferSize - BlockSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = BlockSize, EraseCounter = 0; Index1 < BufferSize - BlockSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero2 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=(BufferSize - (BlockSize*2))) {
+            IsZero2 = FALSE;
+          }
 
-          for (Index1 = BufferSize - BlockSize; Index1 < BufferSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = BufferSize - BlockSize, EraseCounter = 0; Index1 < BufferSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero3 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
+            IsZero3 = FALSE;
+          }
 
           if ((EraseStatus == EFI_SUCCESS) && (IsZero1 == FALSE) && (IsZero2 == TRUE) && ((IsZero3 == FALSE)))
             AssertionType = EFI_TEST_ASSERTION_PASSED;
@@ -492,26 +508,41 @@ BlockIo2:
         // Read the data with 0, the first/last block should not be erased
         ReadStatus = BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer2);
         if (ReadStatus == EFI_SUCCESS) {
-          for (Index1 = 0; Index1 < BlockSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = 0, EraseCounter = 0; Index1 < BlockSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero1 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
+            IsZero1 = FALSE;
+          }
 
-          for (Index1 = BlockSize; Index1 < BufferSize - BlockSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = BlockSize, EraseCounter = 0; Index1 < BufferSize - BlockSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero2 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=(BufferSize - (BlockSize*2))) {
+            IsZero2 = FALSE;
+          }
 
-          for (Index1 = BufferSize - BlockSize; Index1 < BufferSize; Index1++) {
-            if (Buffer2[Index1] != 0) {
+          for (Index1 = BufferSize - BlockSize, EraseCounter = 0; Index1 < BufferSize; Index1++) {
+            if (Buffer2[Index1] != 0x00 && Buffer2[Index1] != 0xFF) {
               IsZero3 = FALSE;
               break;
+            } else if (Buffer2[Index1] == 0x00) {
+              EraseCounter++;
             }
           }
+          if (EraseCounter!=0 && EraseCounter!=BlockSize) {
+            IsZero3 = FALSE;
+          }
 
           if ((EraseStatus == EFI_SUCCESS) && (IsZero1 == FALSE) && (IsZero2 == TRUE) && ((IsZero3 == FALSE)))
             AssertionType = EFI_TEST_ASSERTION_PASSED;
-- 
2.26.2.windows.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-12-07  9:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-02  9:59 [PATCH 2/2] uefi-sct/SctPkg: Correct BBTestEraseBlocks behavior (EFI_BLOCK_IO_PROTOCOL) Chen, ArvinX
2020-11-11 20:56 ` [edk2-devel] " Samer El-Haj-Mahmoud
2020-11-17  5:51   ` 回覆: " Chen, ArvinX
2020-11-17 13:53     ` Samer El-Haj-Mahmoud
2020-11-24  5:47       ` 回覆: " Chen, ArvinX
2020-11-24  5:49         ` G Edhaya Chandran
2020-12-07  9:49   ` G Edhaya Chandran
  -- strict thread matches above, loose matches on Subject: below --
2020-10-27  6:17 Chen, ArvinX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox