From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web09.10138.1603779437762011855 for ; Mon, 26 Oct 2020 23:17:17 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: arvinx.chen@intel.com) IronPort-SDR: gViAfLLpPQ6Ax77uOeO5qdAbM0csCa7JzcIRueZOcMqBbG2tfFCo10OD7Kk3E2+/3fQpLBGhiY XaKivMsCJo7w== X-IronPort-AV: E=McAfee;i="6000,8403,9786"; a="155000777" X-IronPort-AV: E=Sophos;i="5.77,422,1596524400"; d="scan'208";a="155000777" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 23:17:16 -0700 IronPort-SDR: LsYcw7ZcBg82PIXVnQldKg2H+l4pHBYCUNpOzWbuQ8C4wq46aEATGPWkiL9ztN0PO6n4JPrDqf rXuPhAC7OlPQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,422,1596524400"; d="scan'208";a="303651085" Received: from unknown (HELO chiena2x-mobl2.gar.corp.intel.com) ([10.5.241.150]) by fmsmga008.fm.intel.com with ESMTP; 26 Oct 2020 23:17:15 -0700 From: "Chen, ArvinX" To: devel@edk2.groups.io Cc: Eric Jin Subject: [PATCH 2/2] uefi-sct/SctPkg: Correct BBTestEraseBlocks behavior (EFI_BLOCK_IO_PROTOCOL) Date: Tue, 27 Oct 2020 14:17:12 +0800 Message-Id: <20201027061712.167-1-arvinx.chen@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3022 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 Signed-off-by: ArvinX Chen --- .../BlackBoxTest/EraseBlockBBTestFunction.c | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBox= Test/EraseBlockBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protoco= l/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c index cbf43e1d..dbbb70c6 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Er= aseBlockBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Er= aseBlockBBTestFunction.c @@ -71,6 +71,7 @@ BBTestEraseBlocksFunctionTest ( UINT64 Index;=0D UINTN Index1;=0D UINTN Remainder;=0D + UINT64 EraseCounter;=0D =0D EFI_ERASE_BLOCK_TOKEN Token;=0D EFI_BLOCK_IO2_TOKEN BlockIo2Token;=0D @@ -223,26 +224,41 @@ BBTestEraseBlocksFunctionTest ( // Read the data with 0, the first/last block should not be erased= =0D ReadStatus =3D BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferS= ize, (VOID*)Buffer2);=0D if (ReadStatus =3D=3D EFI_SUCCESS) {=0D - for (Index1 =3D 0; Index1 < BlockSize; Index1++) {=0D - if (Buffer2[Index1] !=3D 0) {=0D + for (Index1 =3D 0, EraseCounter =3D 0; Index1 < BlockSize; Index= 1++) {=0D + if (Buffer2[Index1] !=3D 0x00 && Buffer2[Index1] !=3D 0xFF) {= =0D IsZero1 =3D FALSE;=0D break;=0D + } else if (Buffer2[Index1] =3D=3D 0x00) {=0D + EraseCounter++;=0D }=0D }=0D + if (EraseCounter!=3D0 && EraseCounter!=3DBlockSize) {=0D + IsZero1 =3D FALSE;=0D + }=0D =0D - for (Index1 =3D BlockSize; Index1 < BufferSize - BlockSize; Inde= x1++) {=0D - if (Buffer2[Index1] !=3D 0) {=0D + for (Index1 =3D BlockSize, EraseCounter =3D 0; Index1 < BufferSi= ze - BlockSize; Index1++) {=0D + if (Buffer2[Index1] !=3D 0x00 && Buffer2[Index1] !=3D 0xFF) {= =0D IsZero2 =3D FALSE;=0D break;=0D + } else if (Buffer2[Index1] =3D=3D 0x00) {=0D + EraseCounter++;=0D }=0D }=0D + if (EraseCounter!=3D0 && EraseCounter!=3D(BufferSize - (BlockSiz= e*2))) {=0D + IsZero2 =3D FALSE;=0D + }=0D =0D - for (Index1 =3D BufferSize - BlockSize; Index1 < BufferSize; Ind= ex1++) {=0D - if (Buffer2[Index1] !=3D 0) {=0D + for (Index1 =3D BufferSize - BlockSize, EraseCounter =3D 0; Inde= x1 < BufferSize; Index1++) {=0D + if (Buffer2[Index1] !=3D 0x00 && Buffer2[Index1] !=3D 0xFF) {= =0D IsZero3 =3D FALSE;=0D break;=0D + } else if (Buffer2[Index1] =3D=3D 0x00) {=0D + EraseCounter++;=0D }=0D }=0D + if (EraseCounter!=3D0 && EraseCounter!=3DBlockSize) {=0D + IsZero3 =3D FALSE;=0D + }=0D =0D if ((EraseStatus =3D=3D EFI_SUCCESS) && (IsZero1 =3D=3D FALSE) &= & (IsZero2 =3D=3D TRUE) && ((IsZero3 =3D=3D FALSE)))=0D AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D @@ -492,26 +508,41 @@ BlockIo2: // Read the data with 0, the first/last block should not be erased= =0D ReadStatus =3D BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba, &Bl= ockIo2Token, BufferSize, (VOID*)Buffer2);=0D if (ReadStatus =3D=3D EFI_SUCCESS) {=0D - for (Index1 =3D 0; Index1 < BlockSize; Index1++) {=0D - if (Buffer2[Index1] !=3D 0) {=0D + for (Index1 =3D 0, EraseCounter =3D 0; Index1 < BlockSize; Index= 1++) {=0D + if (Buffer2[Index1] !=3D 0x00 && Buffer2[Index1] !=3D 0xFF) {= =0D IsZero1 =3D FALSE;=0D break;=0D + } else if (Buffer2[Index1] =3D=3D 0x00) {=0D + EraseCounter++;=0D }=0D }=0D + if (EraseCounter!=3D0 && EraseCounter!=3DBlockSize) {=0D + IsZero1 =3D FALSE;=0D + }=0D =0D - for (Index1 =3D BlockSize; Index1 < BufferSize - BlockSize; Inde= x1++) {=0D - if (Buffer2[Index1] !=3D 0) {=0D + for (Index1 =3D BlockSize, EraseCounter =3D 0; Index1 < BufferSi= ze - BlockSize; Index1++) {=0D + if (Buffer2[Index1] !=3D 0x00 && Buffer2[Index1] !=3D 0xFF) {= =0D IsZero2 =3D FALSE;=0D break;=0D + } else if (Buffer2[Index1] =3D=3D 0x00) {=0D + EraseCounter++;=0D }=0D }=0D + if (EraseCounter!=3D0 && EraseCounter!=3D(BufferSize - (BlockSiz= e*2))) {=0D + IsZero2 =3D FALSE;=0D + }=0D =0D - for (Index1 =3D BufferSize - BlockSize; Index1 < BufferSize; Ind= ex1++) {=0D - if (Buffer2[Index1] !=3D 0) {=0D + for (Index1 =3D BufferSize - BlockSize, EraseCounter =3D 0; Inde= x1 < BufferSize; Index1++) {=0D + if (Buffer2[Index1] !=3D 0x00 && Buffer2[Index1] !=3D 0xFF) {= =0D IsZero3 =3D FALSE;=0D break;=0D + } else if (Buffer2[Index1] =3D=3D 0x00) {=0D + EraseCounter++;=0D }=0D }=0D + if (EraseCounter!=3D0 && EraseCounter!=3DBlockSize) {=0D + IsZero3 =3D FALSE;=0D + }=0D =0D if ((EraseStatus =3D=3D EFI_SUCCESS) && (IsZero1 =3D=3D FALSE) &= & (IsZero2 =3D=3D TRUE) && ((IsZero3 =3D=3D FALSE)))=0D AssertionType =3D EFI_TEST_ASSERTION_PASSED;=0D --=20 2.26.2.windows.1