From nobody Fri May 3 02:55:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+84201+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84201+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1638351847; cv=none; d=zohomail.com; s=zohoarc; b=LeIb5hEKdOQoJuuyS9NUu9px0IK67VnEGjknssM4ldsJbjb1bhsVUbyvnu0CvQWueJI198T9kRmvo4lKFjN3RWO0hLaoCTDMdJ9xeFX+XVHG3XYxsXbqfWsGEiDPSgD8/KW70sdO8lx+DDqrNnhdO/Pz7/Z2sPtnd4/fd2rH6Kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638351847; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hodJBGwcqssUGXbzhDQ5bpvVCC8cUVstRN9cD5EiyDk=; b=P7rLDAmLgENwdcqa2KMB3T5OnrA414GygGzuZJKIqJDsWJ5T+D3IPBk9tFo1vIGVNbTHc34Jx135h6Bl6iBbmFgrvQp3sDn1mFMY4Y3ohutYkmQSDFv5hHucR5bk/iM5LcK03ZDBeo9+MFK/FYo/T9sZgF7VcCn/ArUB/ftdjbM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84201+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1638351847599376.37431484408967; Wed, 1 Dec 2021 01:44:07 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id KaTlYY1788612xoTkLaKif7S; Wed, 01 Dec 2021 01:44:07 -0800 X-Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mx.groups.io with SMTP id smtpd.web09.90093.1638351845420465253 for ; Wed, 01 Dec 2021 01:44:06 -0800 X-Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4J3vL35fYBzbj7g; Wed, 1 Dec 2021 17:43:55 +0800 (CST) X-Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 1 Dec 2021 17:44:03 +0800 X-Received: from kwephisprg16640.huawei.com (10.247.83.252) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Wed, 1 Dec 2021 17:44:02 +0800 From: "wenyi,xie via groups.io" To: , , , , CC: , Subject: [edk2-devel] [PATCH EDK2 v1 1/1] MdeModulePkg/FrameBufferBltLib:Add unit test Date: Wed, 1 Dec 2021 17:43:57 +0800 Message-ID: <20211201094357.2804827-2-xiewenyi2@huawei.com> In-Reply-To: <20211201094357.2804827-1-xiewenyi2@huawei.com> References: <20211201094357.2804827-1-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.247.83.252] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,xiewenyi2@huawei.com X-Gm-Message-State: pRL6fIZeuJg1mjduy1XXiBUex1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1638351847; bh=2Z5lmVwHBNYpmT4tam+ceKy+dDbZHaGA1UCuheqOZL8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=qOw2W6qYSnQKZ53h8BOGJjymMz2T/HNrOhHsRWB5f6CMFugzMPEHNim+GFjfdfUMbbV 0zH0eCnp1G1XJ4WeHB20HaDahrJjmQnnBEw6AeOqyeLPN15T6/KbfLwpazuqX4xPfpagz OEc2g7gArrMo0APxBOUHfvaE1850NuRVkKw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1638351849299100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add unit test for FrameBufferBltLib. Cc: Jian J Wang Cc: Liming Gao Cc: Zhichao Gao Cc: Ray Ni Signed-off-by: Wenyi Xie --- MdeModulePkg/Test/MdeModulePkgHostTest.dsc = | 5 + MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.= inf | 32 ++++ MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.= c | 174 ++++++++++++++++++++ MdeModulePkg/MdeModulePkg.ci.yaml = | 1 + 4 files changed, 212 insertions(+) diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc b/MdeModulePkg/Test= /MdeModulePkgHostTest.dsc index c9ec835df65d..e08bf7d95fe7 100644 --- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc +++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc @@ -47,3 +47,8 @@ [Components] UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf } + + MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTes= t.inf { + + FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBuffer= BltLib.inf + } diff --git a/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBlt= LibUnitTest.inf b/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBuff= erBltLibUnitTest.inf new file mode 100644 index 000000000000..de32f2d93ba6 --- /dev/null +++ b/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnit= Test.inf @@ -0,0 +1,32 @@ +## @file +# This is a unit test for the FrameBufferBltLib. +# +# Copyright (C) Huawei Technologies Co., Ltd. All rights reserved +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D FrameBufferBltLibUnitTest + FILE_GUID =3D E9E25A30-D34A-8E09-F9D1-40249AB39778 + 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] + FrameBufferBltLibUnitTest.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + UnitTestLib + DebugLib + FrameBufferBltLib diff --git a/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBlt= LibUnitTest.c b/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBuffer= BltLibUnitTest.c new file mode 100644 index 000000000000..0d157f55cb69 --- /dev/null +++ b/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnit= Test.c @@ -0,0 +1,174 @@ +/** @file + Unit tests of the FrameBufferBltLib + + 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 + +#define UNIT_TEST_APP_NAME "FrameBufferBltLib Unit Tests" +#define UNIT_TEST_APP_VERSION "1.0" + +struct FRAME_BUFFER_CONFIGURE { + UINT32 PixelsPerScanLine; + UINT32 BytesPerPixel; + UINT32 Width; + UINT32 Height; + UINT8 *FrameBuffer; + EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; + EFI_PIXEL_BITMASK PixelMasks; + INT8 PixelShl[4]; // R-G-B-Rsvd + INT8 PixelShr[4]; // R-G-B-Rsvd + UINT8 LineBuffer[0]; +}; + +typedef struct { + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION Information; + RETURN_STATUS ExpectedResult; +} BASIC_TEST_CONTEXT; + +static BASIC_TEST_CONTEXT mBasicTestTrue1 =3D { + {0, 1920, 1080, PixelRedGreenBlueReserved8BitPerColor, {0, 0, 0, 0}, 192= 0}, + RETURN_SUCCESS +}; + +static BASIC_TEST_CONTEXT mBasicTestFalse1 =3D { + {0, 1920, 1080, PixelRedGreenBlueReserved8BitPerColor, {0, 0, 0, 0}, 108= 0}, + RETURN_UNSUPPORTED +}; + +/** + Unit test for FrameBufferBltConfigure () API of the FrameBufferBltLib. + + @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 th= at may + consume it. + + @retval UNIT_TEST_PASSED The Unit test has completed and th= e test + case was successful. + @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has failed. +**/ +UNIT_TEST_STATUS +EFIAPI +FrameBufferBltConfigureTest ( + IN UNIT_TEST_CONTEXT Context + ) +{ + RETURN_STATUS Result; + VOID *FrameBuffer; + BASIC_TEST_CONTEXT *BasicContext; + FRAME_BUFFER_CONFIGURE Configure; + UINTN ConfigureSize; + + FrameBuffer =3D NULL; + + //FrameBufferInfoInitial (&FrameBufferInfo); + BasicContext =3D (BASIC_TEST_CONTEXT*)Context; + Result =3D FrameBufferBltConfigure (FrameBuffer, &(BasicContext->Informa= tion), &Configure, &ConfigureSize); + UT_ASSERT_TRUE (Result =3D=3D BasicContext->ExpectedResult); + + return UNIT_TEST_PASSED; +} + +/** + Initialze the unit test framework, suite, and unit tests for the + FrameBufferBltLib and run the FrameBufferBltLib 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_VERSIO= N )); + + // + // Start setting up the test framework for running the tests. + // + Status =3D InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME, gEfiCa= llerBaseName, UNIT_TEST_APP_VERSION); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status =3D %r\n= ", Status)); + goto EXIT; + } + + // + // Populate the FrameBufferBltLib Unit Test Suite. + // + Status =3D CreateUnitTestSuite (&SortTests, Framework, "FrameBufferBltLi= b Tests", "FrameBufferBltLib.Configure", NULL, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for FrameBufferBlt= Lib API Tests\n")); + Status =3D EFI_OUT_OF_RESOURCES; + goto EXIT; + } + + // + // -------------Suite-----------Description----------Name-------------Fu= nction-------------Pre---Post---Context----------- + // + AddTestCase (SortTests, "Create the configuration", "Sort", FrameBufferB= ltConfigureTest, NULL, NULL, &mBasicTestTrue1); + AddTestCase (SortTests, "Create the configuration", "Sort", FrameBufferB= ltConfigureTest, NULL, NULL, &mBasicTestFalse1); + + // + // 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 FrameBufferBltLibUnitTestMain 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 +FrameBufferBltLibUnitTestMain ( + IN INT32 Argc, + IN CHAR8 *Argv[] + ) +{ + UnitTestingEntry (); + return 0; +} diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml b/MdeModulePkg/MdeModulePkg.= ci.yaml index f69989087b4c..58dfc3659718 100644 --- a/MdeModulePkg/MdeModulePkg.ci.yaml +++ b/MdeModulePkg/MdeModulePkg.ci.yaml @@ -20,6 +20,7 @@ "8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.UID", "8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.HID", "8001", "UefiSortLibUnitTestMain", + "8001", "FrameBufferBltLibUnitTestMain", ], ## Both file path and directory path are accepted. "IgnoreFiles": [ --=20 2.20.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#84201): https://edk2.groups.io/g/devel/message/84201 Mute This Topic: https://groups.io/mt/87423993/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-