From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mx.groups.io with SMTP id smtpd.web10.6165.1628064299527645452 for ; Wed, 04 Aug 2021 01:05:00 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.187, mailfrom: xiewenyi2@huawei.com) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GfkhZ1yZqzZtrk for ; Wed, 4 Aug 2021 16:01:18 +0800 (CST) Received: from dggpemm000003.china.huawei.com (7.185.36.128) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 4 Aug 2021 16:04:51 +0800 Received: from [10.174.253.58] (10.174.253.58) by dggpemm000003.china.huawei.com (7.185.36.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 4 Aug 2021 16:04:51 +0800 Subject: Re: [edk2-devel] [PATCH EDK2 v2 1/1] MdeModulePkg/UefiSortLib:Add UefiSortLib unit test To: "Wu, Hao A" , "devel@edk2.groups.io" CC: "songdongkuang@huawei.com" , "Wang, Jian J" References: <1627545672-84944-1-git-send-email-xiewenyi2@huawei.com> <1627545672-84944-2-git-send-email-xiewenyi2@huawei.com> From: "wenyi,xie" Message-ID: Date: Wed, 4 Aug 2021 16:04:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.0.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.174.253.58] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm000003.china.huawei.com (7.185.36.128) X-CFilter-Loop: Reflected Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit On 2021/8/2 9:56, Wu, Hao A wrote: >> -----Original Message----- >> From: devel@edk2.groups.io On Behalf Of Wu, Hao >> A >> Sent: Thursday, July 29, 2021 4:26 PM >> To: Wenyi Xie ; devel@edk2.groups.io; Wang, Jian >> J >> Cc: songdongkuang@huawei.com >> Subject: Re: [edk2-devel] [PATCH EDK2 v2 1/1] >> MdeModulePkg/UefiSortLib:Add UefiSortLib unit test >> >>> -----Original Message----- >>> From: Wenyi Xie >>> Sent: Thursday, July 29, 2021 4:01 PM >>> To: devel@edk2.groups.io; Wang, Jian J ; Wu, >>> Hao A >>> Cc: songdongkuang@huawei.com; xiewenyi2@huawei.com >>> Subject: [PATCH EDK2 v2 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. >> >> >> Thanks. >> Reviewed-by: Hao A Wu > > > Sorry, I found that there are a couple of coding format style check failures when merging the patch. > Could you help to resolve them and then create a test pull request on the GitHub for verification? Thanks in advance. > (I think you can take the case under MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/ for reference.) > Hi, Wu Hao I try to deal with the coding format style check failures, and meet a failure which I am not sure how to solve. I take the case you told for reference, but still there's a failure said the define should be capital letters. but if change it to capital letters, there will be another error Function name does not follow the rules: 1. First character should be upper case 2. Must contain lower case characters 3. No white space characters #define Main main INT32 Main ( IN INT32 Argc, IN CHAR8 *Argv[] ) { UnitTestingEntry (); return 0; } Thanks Wenyi > Error details: > 2021-08-02T01:09:28.5955820Z ##[section]Starting: Build and Test MdeModulePkg IA32,X64,ARM,AARCH64,RISCV64 > 2021-08-02T01:09:28.5960733Z ============================================================================== > 2021-08-02T01:09:28.5961018Z Task : Command Line > 2021-08-02T01:09:28.5961258Z Description : Run a command line with arguments > 2021-08-02T01:09:28.5961502Z Version : 1.1.3 > 2021-08-02T01:09:28.5961897Z Author : Microsoft Corporation > 2021-08-02T01:09:28.5962259Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735) > 2021-08-02T01:09:28.5962678Z ============================================================================== > 2021-08-02T01:09:29.3504946Z (node:3659) Warning: Use Cipheriv for counter mode of aes-256-ctr > 2021-08-02T01:09:29.3510020Z (node:3659) Warning: Use Cipheriv for counter mode of aes-256-ctr > 2021-08-02T01:09:29.3511551Z (node:3659) Warning: Use Cipheriv for counter mode of aes-256-ctr > 2021-08-02T01:09:29.3513605Z (node:3659) Warning: Use Cipheriv for counter mode of aes-256-ctr > 2021-08-02T01:09:29.3516798Z (node:3659) Warning: Use Cipheriv for counter mode of aes-256-ctr > 2021-08-02T01:09:29.3517536Z (node:3659) Warning: Use Cipheriv for counter mode of aes-256-ctr > 2021-08-02T01:09:29.3518178Z (node:3659) Warning: Use Cipheriv for counter mode of aes-256-ctr > 2021-08-02T01:09:29.3545461Z [command]/opt/hostedtoolcache/Python/3.8.11/x64/bin/stuart_ci_build -c .pytool/CISettings.py -p MdeModulePkg -t RELEASE,NO-TARGET -a IA32,X64,ARM,AARCH64,RISCV64 TOOL_CHAIN_TAG=GCC5 > 2021-08-02T01:09:29.3546707Z SECTION - Init SDE > 2021-08-02T01:09:29.3547571Z WARNING - Using Pip Tools based BaseTools > 2021-08-02T01:09:29.3548395Z SECTION - Loading Plugins > 2021-08-02T01:09:29.3549212Z SECTION - Start Invocable Tool > 2021-08-02T01:09:29.3550018Z SECTION - Getting Environment > 2021-08-02T01:09:29.3550794Z SECTION - Loading plugins > 2021-08-02T01:09:29.3551675Z SECTION - Building MdeModulePkg Package > 2021-08-02T01:09:29.3552693Z PROGRESS - --Running MdeModulePkg: EccCheck Test NO-TARGET -- > 2021-08-02T01:09:33.0697006Z ERROR - > 2021-08-02T01:09:33.0698018Z ERROR - EFI coding style error > 2021-08-02T01:09:33.0698748Z ERROR - *Error code: 5007 > 2021-08-02T01:09:33.0700631Z ERROR - *There should be no initialization of a variable as part of its declaration > 2021-08-02T01:09:33.0702675Z ERROR - *file: //home/vsts/work/1/s/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > 2021-08-02T01:09:33.0703421Z ERROR - *Line number: 77 > 2021-08-02T01:09:33.0703929Z ERROR - *Variable Name: TestCount > 2021-08-02T01:09:33.0715684Z ERROR - > 2021-08-02T01:09:33.0716634Z ERROR - EFI coding style error > 2021-08-02T01:09:33.0717372Z ERROR - *Error code: 5007 > 2021-08-02T01:09:33.0718214Z ERROR - *There should be no initialization of a variable as part of its declaration > 2021-08-02T01:09:33.0719195Z ERROR - *file: //home/vsts/work/1/s/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > 2021-08-02T01:09:33.0720631Z ERROR - *Line number: 78 > 2021-08-02T01:09:33.0721451Z ERROR - *Variable Name: TestBuffer > 2021-08-02T01:09:33.0722114Z ERROR - > 2021-08-02T01:09:33.0724953Z ERROR - EFI coding style error > 2021-08-02T01:09:33.0725713Z ERROR - *Error code: 5007 > 2021-08-02T01:09:33.0726562Z ERROR - *There should be no initialization of a variable as part of its declaration > 2021-08-02T01:09:33.0727526Z ERROR - *file: //home/vsts/work/1/s/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > 2021-08-02T01:09:33.0728345Z ERROR - *Line number: 79 > 2021-08-02T01:09:33.0729046Z ERROR - *Variable Name: TestResult > 2021-08-02T01:09:33.0729694Z ERROR - > 2021-08-02T01:09:33.0732496Z ERROR - EFI coding style error > 2021-08-02T01:09:33.0733224Z ERROR - *Error code: 7001 > 2021-08-02T01:09:33.0734114Z ERROR - *There should be no use of int, unsigned, char, void, long in any .c, .h or .asl files > 2021-08-02T01:09:33.0737620Z ERROR - *file: //home/vsts/work/1/s/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > 2021-08-02T01:09:33.0739185Z ERROR - *Line number: 117 > 2021-08-02T01:09:33.0741301Z ERROR - *[main] Return type int > 2021-08-02T01:09:33.0744099Z ERROR - > 2021-08-02T01:09:33.0744829Z ERROR - EFI coding style error > 2021-08-02T01:09:33.0745459Z ERROR - *Error code: 7001 > 2021-08-02T01:09:33.0746821Z ERROR - *There should be no use of int, unsigned, char, void, long in any .c, .h or .asl files > 2021-08-02T01:09:33.0747774Z ERROR - *file: //home/vsts/work/1/s/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > 2021-08-02T01:09:33.0749076Z ERROR - *Line number: 117 > 2021-08-02T01:09:33.0749713Z ERROR - *Parameter argc > 2021-08-02T01:09:33.0750999Z ERROR - > 2021-08-02T01:09:33.0751607Z ERROR - EFI coding style error > 2021-08-02T01:09:33.0754599Z ERROR - *Error code: 7001 > 2021-08-02T01:09:33.0761175Z ERROR - *There should be no use of int, unsigned, char, void, long in any .c, .h or .asl files > 2021-08-02T01:09:33.0762167Z ERROR - *file: //home/vsts/work/1/s/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > 2021-08-02T01:09:33.0763160Z ERROR - *Line number: 117 > 2021-08-02T01:09:33.0763741Z ERROR - *Parameter argv > 2021-08-02T01:09:33.0764290Z ERROR - > 2021-08-02T01:09:33.0764843Z ERROR - EFI coding style error > 2021-08-02T01:09:33.0766810Z ERROR - *Error code: 8006 > 2021-08-02T01:09:33.0767819Z ERROR - *Function name does not follow the rules: 1. First character should be upper case 2. Must contain lower case characters 3. No white space characters > 2021-08-02T01:09:33.0768881Z ERROR - *file: //home/vsts/work/1/s/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > 2021-08-02T01:09:33.0769619Z ERROR - *Line number: 181 > 2021-08-02T01:09:33.0773329Z ERROR - *The function name [main] does not follow the rules > 2021-08-02T01:09:33.0791935Z ERROR - > 2021-08-02T01:09:33.0793865Z ERROR - EFI coding style error > 2021-08-02T01:09:33.0794555Z ERROR - *Error code: 9002 > 2021-08-02T01:09:33.0795350Z ERROR - *The function headers should follow Doxygen special documentation blocks in section 2.3.5 > 2021-08-02T01:09:33.0796271Z ERROR - *file: //home/vsts/work/1/s/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c > 2021-08-02T01:09:33.0796985Z ERROR - *Line number: 178 > 2021-08-02T01:09:33.0797610Z ERROR - *No doxygen tags in comment > 2021-08-02T01:09:33.0798208Z ERROR - > 2021-08-02T01:09:33.0798859Z ERROR - --->Test Failed: EccCheck Test NO-TARGET returned 1 > 2021-08-02T01:09:33.0807351Z PROGRESS - --Running MdeModulePkg: Dsc Complete Check Test NO-TARGET -- > 2021-08-02T01:09:33.1524790Z PROGRESS - --->Test Success: Dsc Complete Check Test NO-TARGET > 2021-08-02T01:09:33.1536004Z PROGRESS - --Running MdeModulePkg: Char Encoding Check Test NO-TARGET -- > 2021-08-02T01:09:33.6280380Z PROGRESS - --->Test Success: Char Encoding Check Test NO-TARGET > 2021-08-02T01:09:33.6289076Z PROGRESS - --Running MdeModulePkg: License Check Test NO-TARGET -- > 2021-08-02T01:09:33.6495642Z PROGRESS - --->Test Success: License Check Test NO-TARGET > 2021-08-02T01:09:33.6508125Z PROGRESS - --Running MdeModulePkg: Compiler Plugin RELEASE -- > 2021-08-02T01:09:33.6785178Z PROGRESS - Start time: 2021-08-02 01:09:33.677952 > 2021-08-02T01:09:33.6787716Z PROGRESS - Setting up the Environment > 2021-08-02T01:09:33.7725244Z PROGRESS - Running Pre Build > 2021-08-02T01:09:33.7740357Z PROGRESS - Running Build RELEASE > 2021-08-02T01:17:18.5479885Z PROGRESS - Running Post Build > 2021-08-02T01:17:18.5511807Z PROGRESS - End time: 2021-08-02 01:17:18.549974 Total time Elapsed: 0:07:44 > 2021-08-02T01:17:18.5512997Z PROGRESS - --->Test Success: Compiler Plugin RELEASE > 2021-08-02T01:17:18.5519284Z PROGRESS - --Running MdeModulePkg: Library Class Check Test NO-TARGET -- > 2021-08-02T01:17:18.5639216Z PROGRESS - --->Test Success: Library Class Check Test NO-TARGET > 2021-08-02T01:17:18.5648791Z PROGRESS - --Running MdeModulePkg: Dependency Check Test NO-TARGET -- > 2021-08-02T01:17:18.7306611Z PROGRESS - --->Test Success: Dependency Check Test NO-TARGET > 2021-08-02T01:17:18.7316162Z PROGRESS - --Running MdeModulePkg: Spell Check Test NO-TARGET -- > 2021-08-02T01:17:23.7922166Z WARNING - --->Test Skipped: in plugin! Spell Check Test NO-TARGET > 2021-08-02T01:17:23.7934112Z PROGRESS - --Running MdeModulePkg: Guid Check Test NO-TARGET -- > 2021-08-02T01:17:27.1928850Z PROGRESS - --->Test Success: Guid Check Test NO-TARGET > 2021-08-02T01:17:27.1939129Z PROGRESS - --Running MdeModulePkg: Host Unit Test Dsc Complete Check Test NO-TARGET -- > 2021-08-02T01:17:27.3703640Z PROGRESS - --->Test Success: Host Unit Test Dsc Complete Check Test NO-TARGET > 2021-08-02T01:17:27.3731676Z ERROR - Overall Build Status: Error > 2021-08-02T01:17:27.3733283Z PROGRESS - There were 1 failures out of 10 attempts > 2021-08-02T01:17:27.3734501Z SECTION - Summary > 2021-08-02T01:17:27.3735613Z ERROR - Error > 2021-08-02T01:17:27.4159842Z ##[error]/opt/hostedtoolcache/Python/3.8.11/x64/bin/stuart_ci_build failed with return code: 1 > 2021-08-02T01:17:27.4173134Z ##[error]/opt/hostedtoolcache/Python/3.8.11/x64/bin/stuart_ci_build failed with error: /opt/hostedtoolcache/Python/3.8.11/x64/bin/stuart_ci_build failed with return code: 1 > 2021-08-02T01:17:27.4178252Z ##[section]Finishing: Build and Test MdeModulePkg IA32,X64,ARM,AARCH64,RISCV64 > > Best Regards, > Hao Wu > > >> >> I will wait a couple days before merging to see if any additional comment >> from other reviewers. >> >> Best Regards, >> Hao Wu >> >> >>> >>> 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 | 188 >>> ++++++++++++++++++++ >>> 3 files changed, 226 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.in >>> +++ f >>> @@ -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 = 0x00010017 >>> + BASE_NAME = UefiSortLibUnitTest >>> + FILE_GUID = 271337A3-0D79-BA3E-BC03-714E518E3B1B >>> + VERSION_STRING = 1.0 >>> + MODULE_TYPE = HOST_APPLICATION >>> + >>> +# >>> +# The following information is for reference only and not required by >>> +the >>> build tools. >>> +# >>> +# VALID_ARCHITECTURES = 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..71f30d8b9f7f >>> --- /dev/null >>> +++ b/MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.c >>> @@ -0,0 +1,188 @@ >>> +/** @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 = TEST_ARRAY_SIZE_9; >>> + UINT32 TestBuffer[TEST_ARRAY_SIZE_9] = {1, 2, 3, 4, 5, 6, 7 ,8, 9}; >>> + UINT32 TestResult[TEST_ARRAY_SIZE_9] = {9, 8, 7, 6, 5, 4, 3, 2, 1}; >>> + >>> + 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[] = { L"abcdefg" }; >>> + >>> + retval = StringCompare (TestBuffer, TestBuffer); UT_ASSERT_TRUE >>> + (retval == 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 = 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 = InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME, >>> + gEfiCallerBaseName, UNIT_TEST_APP_VERSION); if (EFI_ERROR (Status)) >> { >>> + DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status >>> = %r\n", Status)); >>> + goto EXIT; >>> + } >>> + >>> + // >>> + // Populate the UefiSortLib Unit Test Suite. >>> + // >>> + Status = 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 = 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 = RunAllTestSuites (Framework); >>> + >>> +EXIT: >>> + if (Framework) { >>> + FreeUnitTestFramework (Framework); >>> + } >>> + >>> + return Status; >>> +} >>> + >>> +/** >>> + Standard POSIX C entry point for host based unit test execution. >>> +**/ >>> +int >>> +main ( >>> + int argc, >>> + char *argv[] >>> + ) >>> +{ >>> + return UnitTestingEntry (); >>> +} >>> -- >>> 2.20.1.windows.1 >> >> >> >> >> > > . >