From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 434829419E7 for ; Thu, 19 Oct 2023 16:53:29 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=chHkghSBUaCWhpkUzS9S3QtMhOhMJs+0srIrygTiniI=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1697734408; v=1; b=geSre0vjtNfhFJfcVE/3s0cTxN6MX/LYvALzMDOf7gXX7JxrZAkxa3p0nhWXrDxqQBnHaLKY ovL1Z9hCk3cDBAeoyoVrBGreFFETFOkmAk7Y1TqOFAeZuiXu1VUO+yr+9TkBZCsMdDL0xfV2ABh 91Mc9X5fagTptjyViZ/roa8E= X-Received: by 127.0.0.2 with SMTP id olbiYY7687511xwtAo3sUElf; Thu, 19 Oct 2023 09:53:28 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.33137.1697734407165227448 for ; Thu, 19 Oct 2023 09:53:27 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="417423216" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="417423216" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 09:53:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="706903513" X-IronPort-AV: E=Sophos;i="6.03,237,1694761200"; d="scan'208";a="706903513" X-Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga003.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 19 Oct 2023 09:53:26 -0700 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Thu, 19 Oct 2023 09:53:25 -0700 X-Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Thu, 19 Oct 2023 09:53:25 -0700 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Thu, 19 Oct 2023 09:53:25 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lOpJ7NVTUXkgKpzGDKEhMiRyLwLHGQaaLZWyO6HACgkeXLeeSGWrtIeQGJSJTGFi4Ifrz9+mci53xZf6HtSeX8YG1P2N/mNqxGZLexKICMzQ591bwR0lCRQ6NkZzx788ThPdunh7cTzc6Z1/4LrXe4HPop8YwYzD2mMmcZXiGeLuwBluKMapVy7QckLsK11HA1Owm3HjEA7KV/QwMP4evhah1pz6T5ETLr3Pa82ReG2BFJvgHXoHPWjRJ5Pniv3DGCBlYsM0EbzKWeM1H7lL7G4OsbaG5H9rFo4H7MoD26zS0zotb3HNfY8e4CvZto/NDgJ1MXazp+Qn2QaJJX9lqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BkM5l8UZUacI83Y88GOEGVjwb2K0b64bb9/KQpgQHLA=; b=RAH9/1YNy1/++NZeVRu1ZviixUzXd4KY5cZr9Fr0Zvcgeu1gK+60gzWBFtYYim45yQDmwpo3YSCH4PncGq7VJBDZdqJu/qo8NJeVIv12YjlKKkc2lAKkl3//zu/4XiXhX0Qq1tCUlRLFmp8X54Z+16tmzpaEEKt+KnzZdju/XxlOBn2dmeerK1fnUjJX3Vf1sADQdCpgeqYAkjAa+5mvV89dCiXk0bSHg5XzyK6GBY4Kg+HaEtl/9A0KVR9B3xGTGi+uhc1okGFBkZFfC6qEU7DU4aU3joZ9APZd5wZiI87ml3k0yq1M8Zc9QufWwiPwd36ZEdYdqFVAYGhfVRwnrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com (2603:10b6:303:6d::19) by BN9PR11MB5418.namprd11.prod.outlook.com (2603:10b6:408:11f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 16:53:20 +0000 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::2ebf:3b09:b169:ee2c]) by CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::2ebf:3b09:b169:ee2c%4]) with mapi id 15.20.6907.022; Thu, 19 Oct 2023 16:53:20 +0000 From: "Michael D Kinney" To: "Albecki, Mateusz" , "devel@edk2.groups.io" CC: "Gao, Liming" , "Liu, Zhiguang" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCHv2 2/2] MdePkg/Test: Add DevicePathLib host test module Thread-Topic: [PATCHv2 2/2] MdePkg/Test: Add DevicePathLib host test module Thread-Index: AQHZ8VqNXQyp9RrTIESO6Zm8ox3Pa7BICTVAgAltksA= Date: Thu, 19 Oct 2023 16:53:20 +0000 Message-ID: References: <20230927155123.1465365-1-mateusz.albecki@intel.com> <20230927155123.1465365-3-mateusz.albecki@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB4929:EE_|BN9PR11MB5418:EE_ x-ms-office365-filtering-correlation-id: 682643da-e185-420b-c5e8-08dbd0c3e66d x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: UBDyomBCCzObbGNL4lpcz7KHlfOiEVFyffP6rJPjeFphBiwqNDrPBFmYCAxmP1h8hoVFEy8XtYlfcmt/1IQ1LnEHK9axtfQsBFRH7iQmyhvvd4fTI6TKR7hecxPExqcnowljI3KiAREGp3Qt/b2PVXScIaIkFVl1SK09S7XplwyEdGiy6VGBoEZ2odoSjsyS2ULkxa0KEqHjzhhm8016ihew/rbpFColMOScZK0mQN4ejuCI6w4Ay0CH2MNY0ZL/R2bR6DupjAL2O8AWTDFJeDFuh+8Npy7S9yVZ22GKPAjXnFJ0UuPyD4KsMDpUS4+wTH5hdxDZy9kJaPGiK2PvT/2M20nID7DqtlFQBxXmzp/nFk7umADJNbCbQlS2DjeUDfF/GyobxUE2YR6fc/bNxi0wDDgug4LsNDZuxR7pjES8tBfwjYaCnpT06yaYe+ka09+pYn6EmySc2DTDV98pqudOHR2mrvkNikTVIzd3x34Tbw68ziaA/13AOVvqUWe5VOJLolFeEi6PMl79ICUJd1OnXDjTIcY8FdKO3PLCg/ifFTxB9OdahLZmYxzSjyGSG8utqpGjrfse7BH+Zd1QcPbwoiX4SQifoPKF2RD2SEA= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?XNfMT/uvC95M1+7TpkM22uxJkrad/k8HS6VZyMsm9EJYnCzbWcBw9sHp6js6?= =?us-ascii?Q?LrSVNX/CocHdMnN3XWWfDNSn8ltg7GGkIUza/gKSt118SB+Igs6oMGKzmzv/?= =?us-ascii?Q?tmlNKNOP+Ky0nl8mbm7an3qm3WwCtRJuLKypr6ee/OipsTkaK4z5+/GHdTFz?= =?us-ascii?Q?C0bFA96alkKsJANgzHWyH4myqRrLjGLcSp+sbNr350ieHQfYxmXmFkF4b/n+?= =?us-ascii?Q?SU1/HkrxEVEPyFZNe2ko6wbxBOypO/2XeMbcHVYNKiOWI/843Q2sbwZkg808?= =?us-ascii?Q?3+j1n9AHuwEnHMarZkqmR4Cat159JRuFt//gL1bOaEwyFkHzJgWVldNo6Mfe?= =?us-ascii?Q?yWqYUSAJ0CEBkzBQgXvfBYT8CCXB0Y7i2dBe3GqSA3K7XiztgfvsG82G3LHq?= =?us-ascii?Q?rMxXZ+xEWjudaUy0SCu/btvOoVPPUK85JDU4tTWZD9ICOQAQ8shCPZsoiKAG?= =?us-ascii?Q?ZYeeC5fdGFlVatTO8lpmaW37DEq7Kzm9SiNTBTyvFyO+klPFRYha1vG50urM?= =?us-ascii?Q?aQSIE+IHirfBZixXwxhyhrdjXPzxYpHRcSYfbav4/2GTa+vDwj9j8jyH04p0?= =?us-ascii?Q?T+/7Xbfxh/px2MktbZx7eIH6O0dunD3sIxZlNkan1B+vST32n4Ff1B/Fn6Eb?= =?us-ascii?Q?VTfB0K8BnZAC8Y+nMXVDd9labivgQTSOWjxUK8LiKIYidtq70Mv5IzGKKAZ5?= =?us-ascii?Q?UVlTPh4cBZ4ll5UV6/rYw7f1X1VL0eBoyp8nGA6RrqvvMnrVIF5ZwdXhcDmI?= =?us-ascii?Q?BmvAqGgrIv4lWbiS70dED/6Lko9UWhnj1cQDpV4bGPQ3u3wBUU9pPsXUkDz+?= =?us-ascii?Q?Ho7LjYqdtLVUDet24nnBGk6WwV78+rYDcdR2Ua7+9hzPXe2AQEmmMmUwp3Ar?= =?us-ascii?Q?fkbAs6E66svcRmQc2SVRtvJbxVwQQYduBngMB+Bfj6UhmBt2fdWA8RYS8VU1?= =?us-ascii?Q?y1skZoBgF4FaGkHP85zn9JxUsQQLP4O/VJ16QVJocCqwVJTD5PYw+/mnSIpZ?= =?us-ascii?Q?F8TUsQP+rGxY91V7cROVXnek3c0VOzbBIDlyirYikHFubFVL91p0enfqnz1I?= =?us-ascii?Q?ksowQT9OKcXGAkusg3UkoCVzoBh8ILa7EJisArAFwD8cUHqyLAGHge/gPB50?= =?us-ascii?Q?hWKE3fmWS+8VfROn8mTD5C6KZOZ3raoljJ5H5/nIfTs2GHJI3ZbSHGOz3Op6?= =?us-ascii?Q?r8otPwppGLIqFSL/hjpz9wzykug2B8sikuzzbwSzs0AOIlWDpKUM4v5S006D?= =?us-ascii?Q?2CrJ0oKoQgThj0JqKAQlE280ZxrOv0qyi0XpHezrCcEfodPpYtuOSREa237K?= =?us-ascii?Q?/6T60wzbJjkI5aHqkPNSTmwfb8mMsd3XJ9K0RxtS37HHjc3zX6WKfx78eYro?= =?us-ascii?Q?LlWjgWaRjJW2VC3UvoLWJPOe0GIx9zWIUUA+zyFPGrh/SBbWU/Z53W+vQrPz?= =?us-ascii?Q?Qg+qVt2J7NTvy0QK2pJcJP8xKKtEMdV9koYLmBInRNCtH5ahZWYfQhKyEPov?= =?us-ascii?Q?EC4wayZ7AHHemOxiunJMWPSEW+2+afQ+jpXVAeBu2I6V89nF9e3vgCvVSKkI?= =?us-ascii?Q?Tn1KEqweDo40stmuOqjSpRQHqnL4fe+KVvbhe7Fo?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4929.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 682643da-e185-420b-c5e8-08dbd0c3e66d X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Oct 2023 16:53:20.6128 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GVenE5BhGPrpuap6S4kzJ77aEvZ2Y8QoTQtMComMO36dzhPfA9M2oPFDeEa8Jx6zNzG6pgDKFFOyEO8giVQ6Z9l5LwOsw92fhrPQ+Wi+0IY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5418 X-OriginatorOrg: intel.com Precedence: Bulk 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,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: X8NG7AdVwOqaowDSgpIABqe6x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=geSre0vj; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Merged: https://github.com/tianocore/edk2/pull/4865 Mike > -----Original Message----- > From: Kinney, Michael D > Sent: Friday, October 13, 2023 9:55 AM > To: Albecki, Mateusz ; devel@edk2.groups.io > Cc: Gao, Liming ; Liu, Zhiguang > ; Kinney, Michael D > > Subject: RE: [PATCHv2 2/2] MdePkg/Test: Add DevicePathLib host test > module >=20 > Reviewed-by: Michael D Kinney >=20 > > -----Original Message----- > > From: Albecki, Mateusz > > Sent: Wednesday, September 27, 2023 8:51 AM > > To: devel@edk2.groups.io > > Cc: Albecki, Mateusz ; Kinney, Michael D > > ; Gao, Liming > ; > > Liu, Zhiguang > > Subject: [PATCHv2 2/2] MdePkg/Test: Add DevicePathLib host test > module > > > > This commit adds host-based unit tests for device path lib. > > > > > > > > Cc: Michael D Kinney > > > > Cc: Liming Gao > > > > Cc: Zhiguang Liu > > > > > > > > Signed-off-by: Mateusz Albecki > > > > --- > > > > MdePkg/MdePkg.ci.yaml | 5 +- > > > > MdePkg/Test/MdePkgHostTest.dsc | 2 + > > > > .../Library/DevicePathLib/TestDevicePathLib.c | 638 > > ++++++++++++++++++ > > > > .../Library/DevicePathLib/TestDevicePathLib.h | 26 + > > > > .../DevicePathLib/TestDevicePathLibHost.inf | 33 + > > > > .../TestDevicePathStringConversions.c | 370 ++++++++++ > > > > 6 files changed, 1073 insertions(+), 1 deletion(-) > > > > create mode 100644 > > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c > > > > create mode 100644 > > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h > > > > create mode 100644 > > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf > > > > create mode 100644 > > > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConvers > > ions.c > > > > > > > > diff --git a/MdePkg/MdePkg.ci.yaml b/MdePkg/MdePkg.ci.yaml > > > > index c3faf4913d..45f4fb537b 100644 > > > > --- a/MdePkg/MdePkg.ci.yaml > > > > +++ b/MdePkg/MdePkg.ci.yaml > > > > @@ -74,7 +74,10 @@ > > > > > > "Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c", > > > > "Library/BaseFdtLib", > > > > "Library/MipiSysTLib/mipi_syst.h", > > > > - "Include/Register/Amd/SmramSaveStateMap.h" > > > > + "Include/Register/Amd/SmramSaveStateMap.h", > > > > + > > "Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c", > > > > + > > "Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h", > > > > + > > > "Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConversions.c > > " > > > > ] > > > > }, > > > > ## options defined ci/Plugin/CompilerPlugin > > > > diff --git a/MdePkg/Test/MdePkgHostTest.dsc > > b/MdePkg/Test/MdePkgHostTest.dsc > > > > index 529ea69024..b92b564d43 100644 > > > > --- a/MdePkg/Test/MdePkgHostTest.dsc > > > > +++ b/MdePkg/Test/MdePkgHostTest.dsc > > > > @@ -21,6 +21,7 @@ > > > > > > > > [LibraryClasses] > > > > SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf > > > > + > > > DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibBase.i > > nf > > > > > > > > [Components] > > > > # > > > > @@ -29,6 +30,7 @@ > > > > > > > MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibHost.inf > > > > MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsHost.inf > > > > > > > MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib > > .inf > > > > + > > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf > > > > > > > > # > > > > # Build HOST_APPLICATION Libraries > > > > diff --git > > a/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c > > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c > > > > new file mode 100644 > > > > index 0000000000..687497278c > > > > --- /dev/null > > > > +++ b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c > > > > @@ -0,0 +1,638 @@ > > > > +/** @file > > > > + UEFI OS based application for unit testing the DevicePathLib. > > > > + > > > > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> > > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > > > +**/ > > > > + > > > > +#include "TestDevicePathLib.h" > > > > + > > > > +#define UNIT_TEST_NAME "DevicePathLib Unit Test Application" > > > > +#define UNIT_TEST_VERSION "0.1" > > > > + > > > > +typedef struct { > > > > + ACPI_HID_DEVICE_PATH AcpiPath; > > > > + PCI_DEVICE_PATH PciPathRootPort; > > > > + PCI_DEVICE_PATH PciPathEndPoint; > > > > + USB_DEVICE_PATH UsbPath; > > > > + EFI_DEVICE_PATH_PROTOCOL End; > > > > +} TEST_COMPLEX_DEVICE_PATH; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED TEST_COMPLEX_DEVICE_PATH > > mComplexDevicePath =3D { > > > > + { // ACPI device path with root bridge EISA_PNP_ID > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), > > > > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0x0A03), > > > > + 0 > > > > + }, > > > > + { // PCI device path - root port (0x2:0x0) > > > > + { > > > > + HARDWARE_DEVICE_PATH, > > > > + HW_PCI_DP, > > > > + { > > > > + (UINT8)(sizeof (PCI_DEVICE_PATH)), > > > > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + 0x2, > > > > + 0x0 > > > > + }, > > > > + { // PCI device path - endpoint (0x0:0x0) > > > > + { > > > > + HARDWARE_DEVICE_PATH, > > > > + HW_PCI_DP, > > > > + { > > > > + (UINT8)(sizeof (PCI_DEVICE_PATH)), > > > > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + 0x0, > > > > + 0x0 > > > > + }, > > > > + { // USB interface > > > > + { > > > > + MESSAGING_DEVICE_PATH, > > > > + MSG_USB_DP, > > > > + { > > > > + (UINT8)(sizeof (USB_DEVICE_PATH)), > > > > + (UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + 0, > > > > + 2 > > > > + }, > > > > + { > > > > + END_DEVICE_PATH_TYPE, > > > > + END_ENTIRE_DEVICE_PATH_SUBTYPE, > > > > + { > > > > + (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)), > > > > + (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8) > > > > + } > > > > + } > > > > +}; > > > > + > > > > +CONST GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 > *mComplexDevicePathString > > =3D L"PciRoot(0x0)/Pci(0x0,0x2)/Pci(0x0,0x0)/USB(0x0,0x2)"; > > > > + > > > > +CONST GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mPciEndPointPathString > =3D > > L"Pci(0x0, 0x0)"; > > > > + > > > > +typedef struct { > > > > + ACPI_HID_DEVICE_PATH AcpiPath; > > > > + EFI_DEVICE_PATH_PROTOCOL End; > > > > +} TEST_SIMPLE_DEVICE_PATH; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED TEST_SIMPLE_DEVICE_PATH > > mSimpleDevicePath =3D { > > > > + { // ACPI device path with root bridge EISA_PNP_ID > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), > > > > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0x0A03), > > > > + 0 > > > > + }, > > > > + { > > > > + END_DEVICE_PATH_TYPE, > > > > + END_ENTIRE_DEVICE_PATH_SUBTYPE, > > > > + { > > > > + (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)), > > > > + (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8) > > > > + } > > > > + } > > > > +}; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED TEST_SIMPLE_DEVICE_PATH > > mInvalidSimpleDevicePath =3D { > > > > + { // ACPI device path with root bridge EISA_PNP_ID > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_DP, > > > > + { > > > > + 0, > > > > + 0 > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0x0A03), > > > > + 0 > > > > + }, > > > > + { > > > > + END_DEVICE_PATH_TYPE, > > > > + END_ENTIRE_DEVICE_PATH_SUBTYPE, > > > > + { > > > > + (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)), > > > > + (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8) > > > > + } > > > > + } > > > > +}; > > > > + > > > > +typedef struct { > > > > + TEST_SIMPLE_DEVICE_PATH *SimpleDevicePath; > > > > + TEST_SIMPLE_DEVICE_PATH *InvalidDevicePath; > > > > + TEST_COMPLEX_DEVICE_PATH *ComplexDevicePath; > > > > +} SIMPLE_TEST_SUITE_CONTEXT; > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestIsDevicePathValid ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + BOOLEAN IsValid; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > > *)TestContext->SimpleDevicePath, sizeof (TEST_SIMPLE_DEVICE_PATH)); > > > > + UT_ASSERT_TRUE (IsValid); > > > > + > > > > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > > *)TestContext->ComplexDevicePath, sizeof > (TEST_COMPLEX_DEVICE_PATH)); > > > > + UT_ASSERT_TRUE (IsValid); > > > > + > > > > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > > *)TestContext->ComplexDevicePath, 0); > > > > + UT_ASSERT_TRUE (IsValid); > > > > + > > > > + // Device path can't be NULL > > > > + IsValid =3D IsDevicePathValid (NULL, 0); > > > > + UT_ASSERT_FALSE (IsValid); > > > > + > > > > + // MaxSize can't be less then the size of the device path > > > > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > > *)TestContext->SimpleDevicePath, sizeof (TEST_SIMPLE_DEVICE_PATH) - > > 1); > > > > + UT_ASSERT_FALSE (IsValid); > > > > + > > > > + // If MaxSize !=3D 0 it must be bigger then > EFI_DEVICE_PATH_PROTOCOL > > > > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > > *)TestContext->SimpleDevicePath, sizeof (EFI_DEVICE_PATH_PROTOCOL) - > > 1); > > > > + UT_ASSERT_FALSE (IsValid); > > > > + > > > > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > > *)TestContext->InvalidDevicePath, 0); > > > > + UT_ASSERT_FALSE (IsValid); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestDevicePathType ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + UINT8 Type; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + // Test 2 types just in case the implementation is returning > > constant value > > > > + // NOTE: passing NULL to this function causes NULL pointer > > dereference. > > > > + Type =3D DevicePathType (&TestContext->ComplexDevicePath- > >AcpiPath); > > > > + UT_ASSERT_EQUAL (Type, ACPI_DEVICE_PATH); > > > > + > > > > + Type =3D DevicePathType (&TestContext->ComplexDevicePath- > > >PciPathRootPort); > > > > + UT_ASSERT_EQUAL (Type, HARDWARE_DEVICE_PATH); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestDevicePathSubType ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + UINT8 SubType; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + // Test 2 sub types just in case the implementation is returning > > constant value > > > > + // NOTE: passing NULL to this function causes NULL pointer > > dereference. > > > > + SubType =3D DevicePathSubType (&TestContext->ComplexDevicePath- > > >AcpiPath); > > > > + UT_ASSERT_EQUAL (SubType, ACPI_DP); > > > > + > > > > + SubType =3D DevicePathSubType (&TestContext->ComplexDevicePath- > > >PciPathRootPort); > > > > + UT_ASSERT_EQUAL (SubType, HW_PCI_DP); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestDevicePathNodeLength ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + UINTN Length; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + // Test 2 nodes just in case the implementation is returning > > constant value > > > > + // NOTE: passing NULL to this function causes NULL pointer > > dereference. > > > > + Length =3D DevicePathNodeLength (&TestContext->ComplexDevicePath- > > >AcpiPath); > > > > + UT_ASSERT_EQUAL (Length, sizeof (ACPI_HID_DEVICE_PATH)); > > > > + > > > > + Length =3D DevicePathNodeLength (&TestContext->ComplexDevicePath- > > >PciPathRootPort); > > > > + UT_ASSERT_EQUAL (Length, sizeof (PCI_DEVICE_PATH)); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestNextDevicePathNode ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + VOID *Node; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + Node =3D &mComplexDevicePath; > > > > + Node =3D NextDevicePathNode (Node); > > > > + UT_ASSERT_MEM_EQUAL (Node, &TestContext->ComplexDevicePath- > > >PciPathRootPort, DevicePathNodeLength (Node)); > > > > + > > > > + Node =3D NextDevicePathNode (Node); > > > > + UT_ASSERT_MEM_EQUAL (Node, &TestContext->ComplexDevicePath- > > >PciPathEndPoint, DevicePathNodeLength (Node)); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestIsDevicePathEndType ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + BOOLEAN IsEndType; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + IsEndType =3D IsDevicePathEndType (&TestContext->ComplexDevicePath- > > >PciPathRootPort); > > > > + UT_ASSERT_FALSE (IsEndType); > > > > + > > > > + IsEndType =3D IsDevicePathEndType (&TestContext->ComplexDevicePath- > > >End); > > > > + UT_ASSERT_TRUE (IsEndType); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestIsDevicePathEnd ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + BOOLEAN IsEnd; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + IsEnd =3D IsDevicePathEnd (&TestContext->ComplexDevicePath- > > >PciPathRootPort); > > > > + UT_ASSERT_FALSE (IsEnd); > > > > + > > > > + IsEnd =3D IsDevicePathEnd (&TestContext->ComplexDevicePath->End); > > > > + UT_ASSERT_TRUE (IsEnd); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestSetDevicePathNodeLength ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL DevPath; > > > > + > > > > + // NOTE: Node =3D=3D NULL or NodeLength >=3D 0x10000 NodeLength < > sizeof > > (EFI_DEVICE_PATH_PROTOCOL) > > > > + // are all invalid parameters. However there are only ASSERTS > added > > to catch them so there is no > > > > + // way to test it. > > > > + SetDevicePathNodeLength (&DevPath, sizeof > > (EFI_DEVICE_PATH_PROTOCOL)); > > > > + UT_ASSERT_EQUAL (DevicePathNodeLength (&DevPath), sizeof > > (EFI_DEVICE_PATH_PROTOCOL)); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestSetDevicePathEndNode ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL EndNode; > > > > + > > > > + SetDevicePathEndNode (&EndNode); > > > > + UT_ASSERT_EQUAL (EndNode.Type, END_DEVICE_PATH_TYPE); > > > > + UT_ASSERT_EQUAL (EndNode.SubType, > END_ENTIRE_DEVICE_PATH_SUBTYPE); > > > > + UT_ASSERT_EQUAL (DevicePathNodeLength (&EndNode), > > END_DEVICE_PATH_LENGTH); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestGetDevicePathSize ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + UINTN Size; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + Size =3D GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext- > > >SimpleDevicePath); > > > > + UT_ASSERT_EQUAL (Size, sizeof (TEST_SIMPLE_DEVICE_PATH)); > > > > + > > > > + Size =3D GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext- > > >ComplexDevicePath); > > > > + UT_ASSERT_EQUAL (Size, sizeof (TEST_COMPLEX_DEVICE_PATH)); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestDuplicateDevicePath ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL *Duplicate; > > > > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; > > > > + > > > > + Duplicate =3D DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL > > *)TestContext->ComplexDevicePath); > > > > + UT_ASSERT_EQUAL (GetDevicePathSize (Duplicate), GetDevicePathSize > > ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->ComplexDevicePath)); > > > > + UT_ASSERT_MEM_EQUAL (Duplicate, TestContext->ComplexDevicePath, > > GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)TestContext- > > >ComplexDevicePath)); > > > > + FreePool (Duplicate); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestAppendDevicePath ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL *Appended; > > > > + EFI_DEVICE_PATH_PROTOCOL *NextNode; > > > > + > > > > + Appended =3D AppendDevicePath ((EFI_DEVICE_PATH_PROTOCOL > > *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL > > *)&mComplexDevicePath); > > > > + NextNode =3D NextDevicePathNode (Appended); > > > > + UT_ASSERT_MEM_EQUAL (NextNode, &mSimpleDevicePath.AcpiPath, > sizeof > > (ACPI_HID_DEVICE_PATH)); > > > > + FreePool (Appended); > > > > + > > > > + // If one of the paths is invalid result device path should be > NULL > > > > + Appended =3D AppendDevicePath ((EFI_DEVICE_PATH_PROTOCOL > > *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL > > *)&mInvalidSimpleDevicePath); > > > > + UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL); > > > > + > > > > + Appended =3D AppendDevicePath (NULL, NULL); > > > > + UT_ASSERT_EQUAL (Appended->Type, END_DEVICE_PATH_TYPE); > > > > + UT_ASSERT_EQUAL (Appended->SubType, > > END_ENTIRE_DEVICE_PATH_SUBTYPE); > > > > + UT_ASSERT_EQUAL (DevicePathNodeLength (Appended), > > END_DEVICE_PATH_LENGTH); > > > > + FreePool (Appended); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestAppendDevicePathNode ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL *Appended; > > > > + EFI_DEVICE_PATH_PROTOCOL *NextNode; > > > > + BOOLEAN IsValid; > > > > + ACPI_HID_DEVICE_PATH AcpiPath =3D > > > > + { > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), > > > > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0x0AAB), > > > > + 0 > > > > + }; > > > > + > > > > + Appended =3D AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL > > *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&AcpiPath); > > > > + NextNode =3D NextDevicePathNode (Appended); > > > > + UT_ASSERT_MEM_EQUAL (NextNode, &AcpiPath, sizeof > > (ACPI_HID_DEVICE_PATH)); > > > > + FreePool (Appended); > > > > + > > > > + Appended =3D AppendDevicePathNode (NULL, (EFI_DEVICE_PATH_PROTOCOL > > *)&AcpiPath); > > > > + UT_ASSERT_MEM_EQUAL (Appended, &AcpiPath, sizeof > > (ACPI_HID_DEVICE_PATH)); > > > > + IsValid =3D IsDevicePathValid (Appended, 0); > > > > + UT_ASSERT_TRUE (IsValid); > > > > + FreePool (Appended); > > > > + > > > > + Appended =3D AppendDevicePathNode (NULL, NULL); > > > > + UT_ASSERT_EQUAL (Appended->Type, END_DEVICE_PATH_TYPE); > > > > + UT_ASSERT_EQUAL (Appended->SubType, > > END_ENTIRE_DEVICE_PATH_SUBTYPE); > > > > + UT_ASSERT_EQUAL (DevicePathNodeLength (Appended), > > END_DEVICE_PATH_LENGTH); > > > > + FreePool (Appended); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestAppendDevicePathInstance ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL *Appended; > > > > + EFI_DEVICE_PATH_PROTOCOL *NextInstance; > > > > + EFI_DEVICE_PATH_PROTOCOL *NextInstanceRet; > > > > + BOOLEAN IsMultiInstance; > > > > + UINTN Size; > > > > + > > > > + Appended =3D AppendDevicePathInstance > > ((EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath, > > (EFI_DEVICE_PATH_PROTOCOL *)&mComplexDevicePath); > > > > + IsMultiInstance =3D IsDevicePathMultiInstance (Appended); > > > > + UT_ASSERT_TRUE (IsMultiInstance); > > > > + UT_ASSERT_MEM_EQUAL (Appended, &mSimpleDevicePath, sizeof > > (ACPI_DEVICE_PATH)); > > > > + NextInstance =3D Appended; > > > > + NextInstanceRet =3D GetNextDevicePathInstance (&NextInstance, > &Size); > > > > + UT_ASSERT_MEM_EQUAL (NextInstance, &mComplexDevicePath, Size); > > > > + FreePool (Appended); > > > > + FreePool (NextInstanceRet); > > > > + > > > > + Appended =3D AppendDevicePathInstance (NULL, > > (EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath); > > > > + UT_ASSERT_MEM_EQUAL (Appended, &mSimpleDevicePath, sizeof > > (TEST_SIMPLE_DEVICE_PATH)); > > > > + FreePool (Appended); > > > > + > > > > + Appended =3D AppendDevicePathInstance (NULL, NULL); > > > > + UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL); > > > > + FreePool (Appended); > > > > + > > > > + Appended =3D AppendDevicePathInstance ((EFI_DEVICE_PATH_PROTOCOL > > *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL > > *)&mInvalidSimpleDevicePath); > > > > + UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL); > > > > + FreePool (Appended); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestDevicePathFromHandle ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_HANDLE Handle; > > > > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; > > > > + UINTN FakeHandle; > > > > + > > > > + Handle =3D NULL; > > > > + DevicePath =3D DevicePathFromHandle (Handle); > > > > + UT_ASSERT_EQUAL ((uintptr_t)DevicePath, (uintptr_t)NULL); > > > > + > > > > + Handle =3D (EFI_HANDLE)&FakeHandle; > > > > + DevicePath =3D DevicePathFromHandle (Handle); > > > > + UT_ASSERT_EQUAL ((uintptr_t)DevicePath, (uintptr_t)NULL); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestCreateDeviceNode ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL *DevNode; > > > > + > > > > + DevNode =3D CreateDeviceNode (HARDWARE_DEVICE_PATH, HW_PCI_DP, > sizeof > > (PCI_DEVICE_PATH)); > > > > + UT_ASSERT_EQUAL (DevNode->Type, HARDWARE_DEVICE_PATH); > > > > + UT_ASSERT_EQUAL (DevNode->SubType, HW_PCI_DP); > > > > + UT_ASSERT_EQUAL (DevicePathNodeLength (DevNode), sizeof > > (PCI_DEVICE_PATH)); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestFileDevicePath ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_HANDLE Handle; > > > > + FILEPATH_DEVICE_PATH *DevicePath; > > > > + CONST CHAR16 *TestFilePath =3D > L"FS0:/Boot/EFI/BootMgr.efi"; > > > > + > > > > + Handle =3D NULL; > > > > + DevicePath =3D (FILEPATH_DEVICE_PATH *)FileDevicePath (Handle, > > TestFilePath); > > > > + UT_ASSERT_NOT_NULL (DevicePath); > > > > + UT_ASSERT_EQUAL (DevicePath->Header.Type, MEDIA_DEVICE_PATH); > > > > + UT_ASSERT_EQUAL (DevicePath->Header.Type, MEDIA_FILEPATH_DP); > > > > + UT_ASSERT_MEM_EQUAL (DevicePath->PathName, TestFilePath, StrSize > > (TestFilePath)); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +/** > > > > + > > > > + Main fuction sets up the unit test environment > > > > + > > > > +**/ > > > > +EFI_STATUS > > > > +EFIAPI > > > > +UefiTestMain ( > > > > + VOID > > > > + ) > > > > +{ > > > > + EFI_STATUS Status; > > > > + UNIT_TEST_FRAMEWORK_HANDLE Framework; > > > > + UNIT_TEST_SUITE_HANDLE DevicePathSimpleTestSuite; > > > > + UNIT_TEST_SUITE_HANDLE DevicePathAppendTestSuite; > > > > + UNIT_TEST_SUITE_HANDLE DevicePathFileTestSuite; > > > > + SIMPLE_TEST_SUITE_CONTEXT SimpleTestContext; > > > > + > > > > + DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_NAME, > > UNIT_TEST_VERSION)); > > > > + > > > > + Framework =3D NULL; > > > > + DevicePathSimpleTestSuite =3D NULL; > > > > + DevicePathAppendTestSuite =3D NULL; > > > > + DevicePathFileTestSuite =3D NULL; > > > > + > > > > + Status =3D InitUnitTestFramework (&Framework, UNIT_TEST_NAME, > > gEfiCallerBaseName, UNIT_TEST_VERSION); > > > > + if (EFI_ERROR (Status)) { > > > > + DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status =3D > > %r\n", Status)); > > > > + goto EXIT; > > > > + } > > > > + > > > > + Status =3D CreateUnitTestSuite (&DevicePathSimpleTestSuite, > > Framework, "Simple device path operations test suite", > > "Common.DevicePath.SimpleOps", NULL, NULL); > > > > + if (EFI_ERROR (Status)) { > > > > + DEBUG ((DEBUG_ERROR, "Failed to create simple device path test > > suite\n")); > > > > + goto EXIT; > > > > + } > > > > + > > > > + SimpleTestContext.SimpleDevicePath =3D &mSimpleDevicePath; > > > > + SimpleTestContext.InvalidDevicePath =3D &mInvalidSimpleDevicePath; > > > > + SimpleTestContext.ComplexDevicePath =3D &mComplexDevicePath; > > > > + > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test IsDevicePathValid", > > "TestIsDevicePathValid", TestIsDevicePathValid, NULL, NULL, > > &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test DevicePathType", > > "TestDevicePathType", TestDevicePathType, NULL, NULL, > > &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test DevicePathSubType", > > "TestDevicePathSubType", TestDevicePathSubType, NULL, NULL, > > &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test > > DevicePathNodeLength", "TestDevicePathNodeLength", > > TestDevicePathNodeLength, NULL, NULL, &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test > NextDevicePathNode", > > "TestNextDevicePathNode", TestNextDevicePathNode, NULL, NULL, > > &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test > IsDevicePathEndType", > > "TestIsDevicePathEndType", TestIsDevicePathEndType, NULL, NULL, > > &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test IsDevicePathEnd", > > "TestIsDevicePathEnd", TestIsDevicePathEnd, NULL, NULL, > > &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test > > SetDevicePathNodeLength", "TestSetDevicePathNodeLength", > > TestSetDevicePathNodeLength, NULL, NULL, &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test GetDevicePathSize", > > "TestGetDevicePathSize", TestGetDevicePathSize, NULL, NULL, > > &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test CreateDeviceNode", > > "TestCreateDeviceNode", TestCreateDeviceNode, NULL, NULL, > > &SimpleTestContext); > > > > + AddTestCase (DevicePathSimpleTestSuite, "Test > > SetDevicePathEndNode", "TestSetDevicePathEndNode", > > TestSetDevicePathEndNode, NULL, NULL, &SimpleTestContext); > > > > + AddTestCase (DevicePathAppendTestSuite, "Test > DuplicateDevicePath", > > "TestDuplicateDevicePath", TestDuplicateDevicePath, NULL, NULL, > > &SimpleTestContext); > > > > + > > > > + Status =3D CreateUnitTestSuite (&DevicePathAppendTestSuite, > > Framework, "Device path append operations test suite", > > "Common.DevicePath.Append", NULL, NULL); > > > > + if (EFI_ERROR (Status)) { > > > > + DEBUG ((DEBUG_ERROR, "Failed to create append device path test > > suite\n")); > > > > + goto EXIT; > > > > + } > > > > + > > > > + AddTestCase (DevicePathAppendTestSuite, "Test AppendDevicePath", > > "TestAppendDevicePath", TestAppendDevicePath, NULL, NULL, NULL); > > > > + AddTestCase (DevicePathAppendTestSuite, "Test > > AppendDevicePathNode", "TestAppendDevicePathNode", > > TestAppendDevicePathNode, NULL, NULL, NULL); > > > > + AddTestCase (DevicePathAppendTestSuite, "Test > > AppendDevicePathInstance", "TestAppendDevicePathInstance", > > TestAppendDevicePathInstance, NULL, NULL, NULL); > > > > + > > > > + Status =3D CreateDevicePathStringConversionsTestSuite (Framework); > > > > + if (EFI_ERROR (Status)) { > > > > + DEBUG ((DEBUG_ERROR, "Failed to create conversions test > > suite\n")); > > > > + goto EXIT; > > > > + } > > > > + > > > > + Status =3D CreateUnitTestSuite (&DevicePathFileTestSuite, > Framework, > > "Device path file operations test suite", > > "Common.DevicePath.FileDevPath", NULL, NULL); > > > > + if (EFI_ERROR (Status)) { > > > > + DEBUG ((DEBUG_ERROR, "Failed to create device path file test > > suite\n")); > > > > + goto EXIT; > > > > + } > > > > + > > > > + AddTestCase (DevicePathFileTestSuite, "Test > DevicePathFromHandle", > > "TestDevicePathFromHandle", TestDevicePathFromHandle, NULL, NULL, > > NULL); > > > > + AddTestCase (DevicePathFileTestSuite, "Test FileDevicePath", > > "TestFileDevicePath", TestFileDevicePath, NULL, NULL, NULL); > > > > + > > > > + Status =3D RunAllTestSuites (Framework); > > > > + > > > > +EXIT: > > > > + if (Framework !=3D NULL) { > > > > + FreeUnitTestFramework (Framework); > > > > + } > > > > + > > > > + return Status; > > > > +} > > > > + > > > > +int > > > > +main ( > > > > + int argc, > > > > + char *argv[] > > > > + ) > > > > +{ > > > > + return UefiTestMain (); > > > > +} > > > > diff --git > > a/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h > > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h > > > > new file mode 100644 > > > > index 0000000000..4a0c3d4c43 > > > > --- /dev/null > > > > +++ b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h > > > > @@ -0,0 +1,26 @@ > > > > +/** @file > > > > + UEFI OS based application for unit testing the DevicePathLib. > > > > + > > > > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> > > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > > > +**/ > > > > + > > > > +#ifndef __TEST_DEVICE_PATH_LIB_H__ > > > > +#define __TEST_DEVICE_PATH_LIB_H__ > > > > + > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > + > > > > +EFI_STATUS > > > > +CreateDevicePathStringConversionsTestSuite ( > > > > + IN UNIT_TEST_FRAMEWORK_HANDLE Framework > > > > + ); > > > > + > > > > +#endif > > > > diff --git > > > a/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf > > > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf > > > > new file mode 100644 > > > > index 0000000000..9f9c36946a > > > > --- /dev/null > > > > +++ > > > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf > > > > @@ -0,0 +1,33 @@ > > > > +## @file > > > > +# Host OS based Application that Unit Tests the UefiDevicePathLib > > > > +# > > > > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
> > > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > > > +## > > > > + > > > > +[Defines] > > > > + INF_VERSION =3D 0x00010005 > > > > + BASE_NAME =3D TestDevicePathLibHost > > > > + MODULE_UNI_FILE =3D TestDevicePathLib.uni > > > > + FILE_GUID =3D F1505A0E-D71F-4431-99BE-736776842E38 > > > > + MODULE_TYPE =3D HOST_APPLICATION > > > > + VERSION_STRING =3D 1.0 > > > > + > > > > +# > > > > +# The following information is for reference only and not required > by > > the build tools. > > > > +# > > > > +# VALID_ARCHITECTURES =3D IA32 X64 > > > > +# > > > > + > > > > +[Sources] > > > > + TestDevicePathLib.c > > > > + TestDevicePathStringConversions.c > > > > + > > > > +[Packages] > > > > + MdePkg/MdePkg.dec > > > > + > > > > +[LibraryClasses] > > > > + BaseLib > > > > + DebugLib > > > > + DevicePathLib > > > > + UnitTestLib > > > > diff --git > > > a/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConve > > rsions.c > > > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConve > > rsions.c > > > > new file mode 100644 > > > > index 0000000000..4ea25ec142 > > > > --- /dev/null > > > > +++ > > > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConve > > rsions.c > > > > @@ -0,0 +1,370 @@ > > > > +/** @file > > > > + UEFI OS based application for unit testing the DevicePathLib. > > > > + > > > > + Copyright (c) 2023, Intel Corporation. All rights reserved.
> > > > + SPDX-License-Identifier: BSD-2-Clause-Patent > > > > + > > > > +**/ > > > > + > > > > +#include "TestDevicePathLib.h" > > > > + > > > > +typedef struct { > > > > + EFI_DEVICE_PATH_PROTOCOL *DevPath; > > > > + CONST CHAR16 *DevPathString; > > > > +} DEVICE_PATH_CONVERSIONS_TEST_CONTEXT; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED PCI_DEVICE_PATH mPciDevicePathNode =3D > > > > +{ > > > > + // PCI device path - root port (0x2:0x0) > > > > + { > > > > + HARDWARE_DEVICE_PATH, > > > > + HW_PCI_DP, > > > > + { > > > > + (UINT8)(sizeof (PCI_DEVICE_PATH)), > > > > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + 0x2, > > > > + 0x0 > > > > +}; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_HID_DEVICE_PATH > > mAcpiPciRootHidDevicePathNode =3D > > > > +{ > > > > + // ACPI PCI root - PciRoot(0x0) > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), > > > > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0x0A03), > > > > + 0 > > > > +}; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_HID_DEVICE_PATH > > mAcpiNonPciRootHidDevicePathNode =3D > > > > +{ > > > > + // Random ACPI device - ACPI(PNPB0C0, 1) > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), > > > > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0xB0C0), > > > > + 1 > > > > +}; > > > > + > > > > +#define HID_STR_SIZE 8 > > > > +#define CID_STR_SIZE 8 > > > > +#define UID_STR_SIZE 8 > > > > + > > > > +typedef struct { > > > > + ACPI_EXTENDED_HID_DEVICE_PATH AcpiEx; > > > > + CHAR8 HidStr[HID_STR_SIZE]; > > > > + CHAR8 CidStr[CID_STR_SIZE]; > > > > + CHAR8 UidStr[UID_STR_SIZE]; > > > > +} ACPI_EXTENDED_HID_DEVICE_PATH_FULL; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_EXTENDED_HID_DEVICE_PATH_FULL > > mAcpiExtendedDevicePathFull =3D > > > > +{ > > > > + // ACPI Extended HID PciRoot device node > > > > + { > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_EXTENDED_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_EXTENDED_HID_DEVICE_PATH_FULL)), > > > > + (UINT8)((sizeof (ACPI_EXTENDED_HID_DEVICE_PATH_FULL)) >> 8) > > > > + } > > > > + }, > > > > + 0, > > > > + 0, > > > > + 0, > > > > + }, > > > > + { 'P', 'N', 'P', 'B', '0', 'C', '0', '\0' }, // HIDSTR > > > > + { 'P', 'N', 'P', '0', '0', '0', '1', '\0' }, // CIDSTR > > > > + { 'U', 'I', 'D', '0', '0', '0', '0', '\0' } // UIDSTR > > > > +}; > > > > + > > > > +typedef struct { > > > > + ACPI_EXTENDED_HID_DEVICE_PATH AcpiEx; > > > > + CHAR8 HidStr[HID_STR_SIZE]; > > > > +} ACPI_EXTENDED_HID_DEVICE_PATH_PARTIAL; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_EXTENDED_HID_DEVICE_PATH_PARTIAL > > mAcpiExtendedDevicePathPartial =3D > > > > +{ > > > > + { > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_EXTENDED_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_EXTENDED_HID_DEVICE_PATH_PARTIAL)), > > > > + (UINT8)((sizeof (ACPI_EXTENDED_HID_DEVICE_PATH_PARTIAL)) >> > > 8) > > > > + } > > > > + }, > > > > + 0, > > > > + 2, > > > > + 0, > > > > + }, > > > > + { 'P', 'N', 'P', 'B', '0', '\0', '\0', '\0' }, // HIDSTR > > > > +}; > > > > + > > > > +typedef struct { > > > > + ACPI_EXTENDED_HID_DEVICE_PATH AcpiEx; > > > > + CHAR8 UidStr[UID_STR_SIZE]; > > > > +} ACPI_EXPANDED_DEVICE_PATH; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_EXPANDED_DEVICE_PATH > > mAcpiExpandedDevicePathUidOnly =3D > > > > +{ > > > > + { > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_EXTENDED_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_EXPANDED_DEVICE_PATH)), > > > > + (UINT8)((sizeof (ACPI_EXPANDED_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0xAAAA), > > > > + 0, > > > > + 0, > > > > + }, > > > > + { '\0', 'U', 'I', 'D', '0', '0', '\0', '\0' } // UIDSTR > > > > +}; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_EXPANDED_DEVICE_PATH > > mAcpiExpandedDevicePathUidOnlyWithCid =3D > > > > +{ > > > > + { > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_EXTENDED_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_EXPANDED_DEVICE_PATH)), > > > > + (UINT8)((sizeof (ACPI_EXPANDED_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0xAAAA), > > > > + 0, > > > > + EISA_PNP_ID (0xAADD), > > > > + }, > > > > + { '\0', 'U', 'I', 'D', '0', '0', '\0', '\0' } // UIDSTR > > > > +}; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_CONVERSIONS_TEST_CONTEXT > > mDevPathNodeToFromTextContext[] =3D { > > > > + { > > > > + (EFI_DEVICE_PATH_PROTOCOL *)&mPciDevicePathNode, > > > > + L"Pci(0x0,0x2)" > > > > + }, > > > > + { > > > > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiPciRootHidDevicePathNode, > > > > + L"PciRoot(0x0)" > > > > + }, > > > > + { > > > > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiNonPciRootHidDevicePathNode, > > > > + L"Acpi(PNPB0C0,0x1)" > > > > + }, > > > > + { > > > > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiExtendedDevicePathFull, > > > > + L"AcpiEx(@@@0000,@@@0000,0x0,PNPB0C0,UID0000,PNP0001)" > > > > + }, > > > > + { > > > > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiExtendedDevicePathPartial, > > > > + L"AcpiEx(@@@0000,@@@0000,0x2,PNPB0,,)" > > > > + }, > > > > + { > > > > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiExpandedDevicePathUidOnly, > > > > + L"AcpiExp(PNPAAAA,0,UID00)" > > > > + }, > > > > + { > > > > + (EFI_DEVICE_PATH_PROTOCOL > > *)&mAcpiExpandedDevicePathUidOnlyWithCid, > > > > + L"AcpiExp(PNPAAAA,PNPAADD,UID00)" > > > > + } > > > > +}; > > > > + > > > > +typedef struct { > > > > + ACPI_HID_DEVICE_PATH AcpiPath; > > > > + PCI_DEVICE_PATH PciPathRootPort; > > > > + PCI_DEVICE_PATH PciPathEndPoint; > > > > + USB_DEVICE_PATH UsbPath; > > > > + EFI_DEVICE_PATH_PROTOCOL End; > > > > +} TEST_CONVERSIONS_DEVICE_PATH; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED TEST_CONVERSIONS_DEVICE_PATH > > mConversionsDevicePath =3D { > > > > + { // ACPI device path with root bridge EISA_PNP_ID > > > > + { > > > > + ACPI_DEVICE_PATH, > > > > + ACPI_DP, > > > > + { > > > > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), > > > > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + EISA_PNP_ID (0x0A03), > > > > + 0 > > > > + }, > > > > + { // PCI device path - root port (0x2:0x0) > > > > + { > > > > + HARDWARE_DEVICE_PATH, > > > > + HW_PCI_DP, > > > > + { > > > > + (UINT8)(sizeof (PCI_DEVICE_PATH)), > > > > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + 0x2, > > > > + 0x0 > > > > + }, > > > > + { // PCI device path - endpoint (0x0:0x0) > > > > + { > > > > + HARDWARE_DEVICE_PATH, > > > > + HW_PCI_DP, > > > > + { > > > > + (UINT8)(sizeof (PCI_DEVICE_PATH)), > > > > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + 0x0, > > > > + 0x0 > > > > + }, > > > > + { // USB interface > > > > + { > > > > + MESSAGING_DEVICE_PATH, > > > > + MSG_USB_DP, > > > > + { > > > > + (UINT8)(sizeof (USB_DEVICE_PATH)), > > > > + (UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8) > > > > + } > > > > + }, > > > > + 0, > > > > + 2 > > > > + }, > > > > + { > > > > + END_DEVICE_PATH_TYPE, > > > > + END_ENTIRE_DEVICE_PATH_SUBTYPE, > > > > + { > > > > + (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)), > > > > + (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8) > > > > + } > > > > + } > > > > +}; > > > > + > > > > +GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_CONVERSIONS_TEST_CONTEXT > > mDevPathToFromTextContext[] =3D { > > > > + { > > > > + (EFI_DEVICE_PATH_PROTOCOL *)&mConversionsDevicePath, > > > > + L"PciRoot(0x0)/Pci(0x0,0x2)/Pci(0x0,0x0)/USB(0x0,0x2)" > > > > + } > > > > +}; > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestConvertDevicePathToText ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + CHAR16 *DevPathString; > > > > + DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *)Context; > > > > + > > > > + DevPathString =3D ConvertDevicePathToText (TestContext->DevPath, > > FALSE, FALSE); > > > > + UT_ASSERT_EQUAL (StrLen (DevPathString), StrLen (TestContext- > > >DevPathString)); > > > > + UT_ASSERT_MEM_EQUAL (DevPathString, TestContext->DevPathString, > > StrLen (TestContext->DevPathString)); > > > > + FreePool (DevPathString); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestConvertTextToDevicePath ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL *ConvertedDevPath; > > > > + DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *)Context; > > > > + > > > > + ConvertedDevPath =3D ConvertTextToDevicePath (TestContext- > > >DevPathString); > > > > + UT_ASSERT_EQUAL (GetDevicePathSize (ConvertedDevPath), > > GetDevicePathSize (TestContext->DevPath)); > > > > + UT_ASSERT_MEM_EQUAL (ConvertedDevPath, TestContext->DevPath, > > GetDevicePathSize (TestContext->DevPath)); > > > > + FreePool (ConvertedDevPath); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestConvertDeviceNodeToText ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + CHAR16 *DevPathNodeString; > > > > + DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *)Context; > > > > + > > > > + DevPathNodeString =3D ConvertDeviceNodeToText (TestContext- > >DevPath, > > FALSE, FALSE); > > > > + UT_ASSERT_EQUAL (StrLen (DevPathNodeString), StrLen (TestContext- > > >DevPathString)); > > > > + UT_ASSERT_MEM_EQUAL (DevPathNodeString, TestContext- > >DevPathString, > > StrLen (TestContext->DevPathString)); > > > > + FreePool (DevPathNodeString); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +UNIT_TEST_STATUS > > > > +EFIAPI > > > > +TestConvertTextToDeviceNode ( > > > > + IN UNIT_TEST_CONTEXT Context > > > > + ) > > > > +{ > > > > + EFI_DEVICE_PATH_PROTOCOL *DevPath; > > > > + DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *TestContext; > > > > + > > > > + TestContext =3D (DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *)Context; > > > > + > > > > + DevPath =3D ConvertTextToDeviceNode (TestContext->DevPathString); > > > > + UT_ASSERT_EQUAL (DevicePathNodeLength (DevPath), > > DevicePathNodeLength (TestContext->DevPath)); > > > > + UT_ASSERT_MEM_EQUAL (DevPath, TestContext->DevPath, > > DevicePathNodeLength (TestContext->DevPath)); > > > > + FreePool (DevPath); > > > > + > > > > + return UNIT_TEST_PASSED; > > > > +} > > > > + > > > > +EFI_STATUS > > > > +CreateDevicePathStringConversionsTestSuite ( > > > > + IN UNIT_TEST_FRAMEWORK_HANDLE Framework > > > > + ) > > > > +{ > > > > + EFI_STATUS Status; > > > > + UNIT_TEST_SUITE_HANDLE DevicePathTextConversionSuite =3D NULL; > > > > + UINTN Index; > > > > + > > > > + Status =3D CreateUnitTestSuite (&DevicePathTextConversionSuite, > > Framework, "Device path text conversion operations test suite", > > "Common.DevicePath.TextConversions", NULL, NULL); > > > > + if (EFI_ERROR (Status)) { > > > > + DEBUG ((DEBUG_ERROR, "Failed to create device path text > > conversions test suite\n")); > > > > + return Status; > > > > + } > > > > + > > > > + for (Index =3D 0; Index < ARRAY_SIZE > (mDevPathNodeToFromTextContext); > > Index++) { > > > > + AddTestCase (DevicePathTextConversionSuite, "Test > > ConvertDeviceNodeToText", "TestConvertDeviceNodeToText", > > TestConvertDeviceNodeToText, NULL, NULL, > > &mDevPathNodeToFromTextContext[Index]); > > > > + } > > > > + > > > > + for (Index =3D 0; Index < ARRAY_SIZE > (mDevPathNodeToFromTextContext); > > Index++) { > > > > + AddTestCase (DevicePathTextConversionSuite, "Test > > ConvertTextToDeviceNode", "TestConvertTextToDeviceNode", > > TestConvertTextToDeviceNode, NULL, NULL, > > &mDevPathNodeToFromTextContext[Index]); > > > > + } > > > > + > > > > + for (Index =3D 0; Index < ARRAY_SIZE (mDevPathToFromTextContext); > > Index++) { > > > > + AddTestCase (DevicePathTextConversionSuite, "Test > > ConvertDevicePathToText", "TestConvertDevicePathToText", > > TestConvertDevicePathToText, NULL, NULL, > > &mDevPathToFromTextContext[Index]); > > > > + } > > > > + > > > > + for (Index =3D 0; Index < ARRAY_SIZE (mDevPathToFromTextContext); > > Index++) { > > > > + AddTestCase (DevicePathTextConversionSuite, "Test > > ConvertTextToDevicePath", "TestConvertTextToDevicePath", > > TestConvertTextToDevicePath, NULL, NULL, > > &mDevPathToFromTextContext[Index]); > > > > + } > > > > + > > > > + return EFI_SUCCESS; > > > > +} > > > > -- > > > > 2.39.2 > > > > -=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 (#109817): https://edk2.groups.io/g/devel/message/109817 Mute This Topic: https://groups.io/mt/101619981/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-