From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.31020.1628816589890709310 for ; Thu, 12 Aug 2021 18:03:11 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Fri, 13 Aug 2021 09:03:03 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Wu, Hao A'" , "'Wenyi Xie'" , Cc: , "'Wang, Jian J'" References: <1628663739-122023-1-git-send-email-xiewenyi2@huawei.com> <1628663739-122023-2-git-send-email-xiewenyi2@huawei.com> In-Reply-To: Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0ggRURLMiB2MyAxLzFdIE1kZU1vZHVsZVBrZy9VZWZpU29ydExpYjpBZGQgVWVmaVNvcnRMaWIgdW5pdCB0ZXN0?= Date: Fri, 13 Aug 2021 09:03:05 +0800 Message-ID: <012f01d78fde$f9581510$ec083f30$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQG8L0nHheE5iLnwYoQUpSEvO7GnpAFr+/fMAUwlQHurkZ3S0A== Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Hao: I think this patch can be merged for this stable tag. It passes code review before soft feature freeze. ECC issue can be regarded as bug fix. = Bug fix is still allowed in soft feature freeze. Can you merge this patch = before hard feature freeze? Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Wu, Hao A > =B7=A2=CB=CD=CA=B1=BC=E4: 2021=C4=EA8=D4=C211=C8=D5 16:33 > =CA=D5=BC=FE=C8=CB: Liming Gao ; Wenyi Xie > ; devel@edk2.groups.io > =B3=AD=CB=CD: songdongkuang@huawei.com; Wang, Jian J = > =D6=F7=CC=E2: RE: [PATCH EDK2 v3 1/1] MdeModulePkg/UefiSortLib:Add = UefiSortLib > unit test >=20 > > -----Original Message----- > > From: Wenyi Xie > > Sent: Wednesday, August 11, 2021 2:36 PM > > To: devel@edk2.groups.io; Wang, Jian J ; Wu, = Hao > A > > > > Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com > > Subject: [PATCH EDK2 v3 1/1] MdeModulePkg/UefiSortLib:Add = UefiSortLib > > unit test > > > > Adding two unit test case for UefiSortLib. One is a test on sorting = an array of > > UINT32 by using PerformQuickSort, another is a test on comparing the same > > buffer by using StringCompare. > > Add 'main' function name to ECC exception list to avoid ECC error. >=20 >=20 > Reviewed-by: Hao A Wu >=20 > Hello Liming, >=20 > Since the patch looks more like a feature than a bugfix to me, I would like to > confirm that can I merge this change now? > I already gave my 'R-b' tag for the V2 patch on 29th July, but met = some ECC > check issues during previous merging attempt. > I verified that the latest patch can pass the merging test > (https://github.com/tianocore/edk2/pull/1892). >=20 > Best Regards, > Hao Wu >=20 >=20 > > > > Cc: Jian J Wang > > Cc: Hao A Wu > > Signed-off-by: Wenyi Xie > > --- > > MdeModulePkg/Test/MdeModulePkgHostTest.dsc > | 6 + > > MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf | > 32 > > +++ > > MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c | > 207 > > ++++++++++++++++++++ > > MdeModulePkg/MdeModulePkg.ci.yaml > | 1 + > > 4 files changed, 246 insertions(+) > > > > diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc > > b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc > > index 4da4692c8451..c9ec835df65d 100644 > > --- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc > > +++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc > > @@ -41,3 +41,9 @@ [Components] > > > > > > gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDis > > able|TRUE > > } > > + > > + MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf = { > > + > > + UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf > > + > > + = DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf > > + } > > diff --git > > a/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf > > b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf > > new file mode 100644 > > index 000000000000..85d8dcd69619 > > --- /dev/null > > +++ = b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf > > @@ -0,0 +1,32 @@ > > +## @file > > +# This is a unit test for the UefiSortLib. > > +# > > +# Copyright (C) Huawei Technologies Co., Ltd. All rights reserved # > > +SPDX-License-Identifier: BSD-2-Clause-Patent ## > > + > > +[Defines] > > + INF_VERSION =3D 0x00010017 > > + BASE_NAME =3D UefiSortLibUnitTest > > + FILE_GUID =3D 271337A3-0D79-BA3E-BC03-714E518E3B1B > > + VERSION_STRING =3D 1.0 > > + MODULE_TYPE =3D HOST_APPLICATION > > + > > +# > > +# The following information is for reference only and not required = by the > > build tools. > > +# > > +# VALID_ARCHITECTURES =3D IA32 X64 > > +# > > + > > +[Sources] > > + UefiSortLibUnitTest.c > > + > > +[Packages] > > + MdePkg/MdePkg.dec > > + MdeModulePkg/MdeModulePkg.dec > > + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec > > + > > +[LibraryClasses] > > + UnitTestLib > > + DebugLib > > + UefiSortLib > > diff --git > > a/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > > b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > > new file mode 100644 > > index 000000000000..4f44a02c5b5d > > --- /dev/null > > +++ = b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > > @@ -0,0 +1,207 @@ > > +/** @file > > + Unit tests of the UefiSortLib > > + > > + Copyright (C) Huawei Technologies Co., Ltd. All rights reserved > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > + > > +#define UNIT_TEST_APP_NAME "UefiSortLib Unit Tests" > > +#define UNIT_TEST_APP_VERSION "1.0" > > + > > +#define TEST_ARRAY_SIZE_9 9 > > + > > +/** > > + The function is called by PerformQuickSort to compare int values. > > + > > + @param[in] Left The pointer to first buffer. > > + @param[in] Right The pointer to second buffer. > > + > > + @retval 0 Buffer1 equal to Buffer2. > > + @return <0 Buffer1 is less than Buffer2. > > + @return >0 Buffer1 is greater than Buffer2. > > + > > +**/ > > +INTN > > +EFIAPI > > +TestCompareFunction ( > > + IN CONST VOID *Left, > > + IN CONST VOID *Right > > + ) > > +{ > > + if (*(UINT32*)Right > *(UINT32*)Left) { > > + return 1; > > + } else if (*(UINT32*)Right < *(UINT32*)Left) { > > + return -1; > > + } > > + > > + return 0; > > +} > > + > > +/** > > + Unit test for PerformQuickSort () API of the UefiSortLib. > > + > > + @param[in] Context [Optional] An optional parameter that > enables: > > + 1) test-case reuse with varied parameters > and > > + 2) test-case re-entry for Target tests = that > need a > > + reboot. This parameter is a VOID* and it > is the > > + responsibility of the test author to = ensure > that the > > + contents are well understood by all test > cases that may > > + consume it. > > + > > + @retval UNIT_TEST_PASSED The Unit test has > completed and the > > test > > + case was successful. > > + @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has > failed. > > +**/ > > +UNIT_TEST_STATUS > > +EFIAPI > > +SortUINT32ArrayShouldSucceed ( > > + IN UNIT_TEST_CONTEXT Context > > + ) > > +{ > > + UINTN TestCount; > > + UINT32 Index; > > + UINT32 TestBuffer[TEST_ARRAY_SIZE_9]; > > + UINT32 TestResult[TEST_ARRAY_SIZE_9]; > > + > > + TestCount =3D TEST_ARRAY_SIZE_9; > > + for (Index =3D 0; Index < TEST_ARRAY_SIZE_9; Index++) { > > + TestBuffer[Index] =3D Index + 1; > > + TestResult[Index] =3D TEST_ARRAY_SIZE_9 - Index; } > > + > > + PerformQuickSort (TestBuffer, TestCount, sizeof (UINT32), > > + (SORT_COMPARE)TestCompareFunction); > > + UT_ASSERT_MEM_EQUAL (TestBuffer, TestResult, sizeof (UINT32) * > > + TEST_ARRAY_SIZE_9); > > + > > + return UNIT_TEST_PASSED; > > +} > > + > > +/** > > + Unit test for StringCompare () API of the UefiSortLib. > > + > > + @param[in] Context [Optional] An optional parameter that > enables: > > + 1) test-case reuse with varied parameters > and > > + 2) test-case re-entry for Target tests = that > need a > > + reboot. This parameter is a VOID* and it > is the > > + responsibility of the test author to = ensure > that the > > + contents are well understood by all test > cases that may > > + consume it. > > + > > + @retval UNIT_TEST_PASSED The Unit test has > completed and the > > test > > + case was successful. > > + @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has > failed. > > +**/ > > +UNIT_TEST_STATUS > > +EFIAPI > > +CompareSameBufferShouldSucceed ( > > + IN UNIT_TEST_CONTEXT Context > > + ) > > +{ > > + INTN retval; > > + CONST CHAR16* TestBuffer[] =3D { L"abcdefg" }; > > + > > + retval =3D StringCompare (TestBuffer, TestBuffer); = UT_ASSERT_TRUE > > + (retval =3D=3D 0); > > + > > + return UNIT_TEST_PASSED; > > +} > > + > > +/** > > + Initialze the unit test framework, suite, and unit tests for the > > + UefiSortLib and run the UefiSortLib unit test. > > + > > + @retval EFI_SUCCESS All test cases were dispatched. > > + @retval EFI_OUT_OF_RESOURCES There are not enough resources > > available to > > + initialize the unit tests. > > +**/ > > +STATIC > > +EFI_STATUS > > +EFIAPI > > +UnitTestingEntry ( > > + VOID > > + ) > > +{ > > + EFI_STATUS Status; > > + UNIT_TEST_FRAMEWORK_HANDLE Framework; > > + UNIT_TEST_SUITE_HANDLE SortTests; > > + > > + Framework =3D NULL; > > + > > + DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, > > + UNIT_TEST_APP_VERSION )); > > + > > + // > > + // Start setting up the test framework for running the tests. > > + // > > + Status =3D InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME, > > + gEfiCallerBaseName, UNIT_TEST_APP_VERSION); if (EFI_ERROR = (Status)) > { > > + DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status > > =3D %r\n", Status)); > > + goto EXIT; > > + } > > + > > + // > > + // Populate the UefiSortLib Unit Test Suite. > > + // > > + Status =3D CreateUnitTestSuite (&SortTests, Framework, = "UefiSortLib > > + Sort Tests", "UefiSortLib.SortLib", NULL, NULL); if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for > UefiSortLib > > API Tests\n")); > > + Status =3D EFI_OUT_OF_RESOURCES; > > + goto EXIT; > > + } > > + > > + // > > + // > > + = --------------Suite--------Description------------Name--------------Fu > > + nction----------------Pre---Post---Context----------- > > + // > > + AddTestCase (SortTests, "Sort the Array", "Sort", > > SortUINT32ArrayShouldSucceed, NULL, NULL, NULL); > > + AddTestCase (SortTests, "Compare the Buffer", "Compare", > > CompareSameBufferShouldSucceed, NULL, NULL, NULL); > > + > > + // > > + // Execute the tests. > > + // > > + Status =3D RunAllTestSuites (Framework); > > + > > +EXIT: > > + if (Framework) { > > + FreeUnitTestFramework (Framework); > > + } > > + > > + return Status; > > +} > > + > > +/// > > +/// Avoid ECC error for function name that starts with lower case > > +letter /// #define UefiSortLibUnitTestMain main > > + > > +/** > > + Standard POSIX C entry point for host based unit test execution. > > + > > + @param[in] Argc Number of arguments > > + @param[in] Argv Array of pointers to arguments > > + > > + @retval 0 Success > > + @retval other Error > > +**/ > > +INT32 > > +UefiSortLibUnitTestMain ( > > + IN INT32 Argc, > > + IN CHAR8 *Argv[] > > + ) > > +{ > > + UnitTestingEntry (); > > + return 0; > > +} > > diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml > > b/MdeModulePkg/MdeModulePkg.ci.yaml > > index 8e01caf94cbf..aa304f2ccd5c 100644 > > --- a/MdeModulePkg/MdeModulePkg.ci.yaml > > +++ b/MdeModulePkg/MdeModulePkg.ci.yaml > > @@ -19,6 +19,7 @@ > > "ExceptionList": [ > > "8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.UID", > > "8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.HID", > > + "8001", "UefiSortLibUnitTestMain", > > ], > > ## Both file path and directory path are accepted. > > "IgnoreFiles": [ > > -- > > 2.20.1.windows.1