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 E9CD5941D96 for ; Fri, 13 Oct 2023 16:55:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Kw8iqydBs5/0B6sUFhRrEYpXTgoZ2kp6K2e7wROSE2Q=; 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=1697216115; v=1; b=xBIB20PhmsPdGa/j9M1fp8Z+pJDfqjql9phN6xe+xcOdM1xKOXXVHMr91juk+Tp53LMtpZcD QJpxyz5n/lORfvGzH2SfMj6uw5YQh86Yhq7LUVPi8RpO4QxhXJjVYC0uL0UWhIaD+E95QmdvExc GmbgfBAieBIAJ871Rauq9JO8= X-Received: by 127.0.0.2 with SMTP id sh4TYY7687511xtYQHzZw8Hx; Fri, 13 Oct 2023 09:55:15 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.43967.1697216114690447718 for ; Fri, 13 Oct 2023 09:55:15 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10862"; a="370288813" X-IronPort-AV: E=Sophos;i="6.03,222,1694761200"; d="scan'208";a="370288813" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2023 09:54:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10862"; a="878596614" X-IronPort-AV: E=Sophos;i="6.03,222,1694761200"; d="scan'208";a="878596614" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga004.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 13 Oct 2023 09:54:53 -0700 X-Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 13 Oct 2023 09:54:52 -0700 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Fri, 13 Oct 2023 09:54:52 -0700 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Fri, 13 Oct 2023 09:54:52 -0700 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Fri, 13 Oct 2023 09:54:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hhXx+XSMuiLCbMoeT06K6UY03CYIpsLklqSfKfYb9nNcygJsTLQa/DNZilaK9uVeAjFXDifo/F4nEBomssQPyzKbKSsr6XWDzD9fh+YcDJ/9SVBHlBMdTxYIprfpMEMqYfr0QDSjQAbGU4N4VWqKigVSNkCiK166Fdypkr+bULcloqjSLArDYwRvBVxpSN8vYVteuD+m27KGtFbsgIPvJtkjMLlLphgF+3oy2bQFb8PL+mSxinweVzfhfHteeix1uy5yJgpmRNNMk0pUnlxiLfr3DmIbk34S+EUkyW12/fS/L/XtOW9VV66RYyFQNw659cIZru9DPfdluvzJldHY4Q== 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=NdYiMZRuG6hnrMrAag+lFQrWB3pxOvJmbriUMi+xCZo=; b=Urd+qlKpI18CbmvSPQvG27xMJUye2sU2dZ5BlhTQEDXKEnmtESkokr2FGXRqbj9Zr/Fd1wgivaGN5BY49bJEIArxKdSwuP7zgDSByublmqYpDqQxyIfQOSUtQrZ6bbceT4sZ7ajlwlRwW+MdcXWmVoWd6Q1dvskZiaXxXLpR2Ij1OvfE47LK5hxpCxhdw0RGTE0RdShoVSA6tQkNaJIXJssEnwPowigCF1LYIAkdg96gEj34NsdhMsAaJH+6gmWoRmNORG2Z0r0uSsQwCejk2fXoVnCr/yr/CGITfCRkMzWW/oRgSuL8sDM5Rve9fgkC9cFMVLZ6V72h5y/fAuAP3Q== 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 PH7PR11MB5766.namprd11.prod.outlook.com (2603:10b6:510:130::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.44; Fri, 13 Oct 2023 16:54:46 +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.6863.043; Fri, 13 Oct 2023 16:54:46 +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: AQHZ8VqNXQyp9RrTIESO6Zm8ox3Pa7BICTVA Date: Fri, 13 Oct 2023 16:54:46 +0000 Message-ID: References: <20230927155123.1465365-1-mateusz.albecki@intel.com> <20230927155123.1465365-3-mateusz.albecki@intel.com> In-Reply-To: <20230927155123.1465365-3-mateusz.albecki@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB4929:EE_|PH7PR11MB5766:EE_ x-ms-office365-filtering-correlation-id: ab20799d-5ded-4bc0-6e79-08dbcc0d1b38 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: tVfPkdEpxF/KwmalCr3c380N0+7XFpsKTJkCi0zaI8mSpMrv0HLnvAoWfH0Y2VoOdNwq5CM8JzvzZ1AZXo6nfHmZe4lkp5t7UDMASM4MEEtUin42bG5OlFaoMsa3NUL6s0rDK1apA/NTFp7I1qVn1OykuyrajRxRMK2WMAuP6tq1TyG8Sr51aTbx8qbjiz14kwtz1hM42clv4zbOliQqPPWSajLNZsgVPrbS18/U9hckgtOB4bwSkikd9kgUCUcOPn1cPGyu87Q+Ror+7mdJxN6v/RzVGNNsoCJ8qU+IJ6yUq0qzEgbeUL8DynYm5xyrMVSSH2L8iZI54ibNTeCqeRXh5gSH8KlJBPEzihVxl6qUW/mruRkUFFQV+uvyX5bljX5Q9YHWzGOw94LDD9zwOqOTrm0RCSwjllnQ4cY1veQ0W1V/bHRtGqxZPkQ3K+l7yO0puez1XkpZiatlDv+BO9gC2KKlDM5eBUj3sEyvridGliHp9fx2hd4cf3vrAyvH6tef1fgqxN3xVZ9RsDF0xLqNK2Wzg5kJngqHZV6GfrwHpx7Lucp95kCBkZznziGZylhixd3JnGc3ewoCXIX+2DlX8/YTnUY8twbpzD1tqXaErWGU0iJVPpk08edCqAOG x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?MHGtArmEFv8lULOphL8xzz1T1yES6FQ5JihRH40eftwdAaCtZEDIzBlNYhPV?= =?us-ascii?Q?/9Qf71eZrydYI2VXw0yhjY1fXQCKd3tAGzGCEB1JGLTdxv7dz4EOCkx+HUxl?= =?us-ascii?Q?zZQG0mYBVFAG6W4bfkhHC+1u+0I1gbAQhNUCt2Ok33bfsYRHA3//xR1eTqP0?= =?us-ascii?Q?TztuwMPJmKKfhJl0Xj7iDo6mqhARwPpluPAuzgQwPGmaTm+WVQZw2TJiwzV0?= =?us-ascii?Q?7Lx7D5RmTYswUZFoAcfpLF2h0EwZj6kVCyCqS/Gddin0SZNA+EQeZUvP3Xb3?= =?us-ascii?Q?jRZuN7o+GpCZEBsXqMrCoBid6cptNmciECmz5JUb/ePGjeK1TAXncBVHcsyq?= =?us-ascii?Q?NpLsnK4YrgXq36RX2YriBNOr0qWssiVoogSb4D9zMuPThkfJJso/9k9F+Qq6?= =?us-ascii?Q?oCX2neuThdpHP+N8z4r2uoJqVTD0A0JGoCTq/j91Csnfl85JHBzaNif2Sms9?= =?us-ascii?Q?78bCyXznFWBGNRPibykeE5W9RZz3okLITyLCPq5D8KEPuteMCSghaeXJOHQ1?= =?us-ascii?Q?PArpjMPQRGB+HJRkXMpZFqHtJLouUrvEi2/Yjs6qBM8agyeDcX1PMfVIvZNh?= =?us-ascii?Q?9yuPeTu5YTAjMZn8Zg3RoToRxeOPI/dvA1E2ij37KHkAHJg+oYCdwo1xhAEm?= =?us-ascii?Q?xjI4PuIjhLz8mW5nb0VG4i5JCqnKHmFWHswZ89o0/Ma4CABNeAxjV93Qjrrt?= =?us-ascii?Q?rkOX1/ST+BY7qpJFhkeE1yE39G8WOkfui0ZEs/a64VonIMtIq2dgdp0oeg/w?= =?us-ascii?Q?G9horpKp2mwtr5BIPddN0+8eO5D3CHzlDrSdjuB42fNqCKsHkk8Rp4lBkneb?= =?us-ascii?Q?6rz45aoZIt1mIYfej1+V7b3XNZuKcF0GQreBK0U8p/uIaDVUjMBRC4F6JQn+?= =?us-ascii?Q?OKCUaGZ6kFE0ipu9eP86vgYB5w/JXC85BCmbmbBdBt4Js8iWT0pI8UEocKK/?= =?us-ascii?Q?ZhbvcVxMT7wcaoQRPG/7NfRfIUx5M/AaS+l+YOZalgv9/eU685NiXLQoyxAb?= =?us-ascii?Q?wNoGicWyTMfY2Ip/sBSDVjGw5ptxmlbw+ibvJQ/UfeW/vq6nZHQN5ZQv1S2b?= =?us-ascii?Q?eSV45y2QCNzJSkW/IaonUg/9naW1a61ofCymlard6kDOioDS40/RNiKSm4aA?= =?us-ascii?Q?3ufL3rutV3XpjuBYzyaQQCGAwBLU8H4i3t/cvdZNJLVoxf+OhUkYnvQtSsSp?= =?us-ascii?Q?pHjmhNsRGJl4kGYsMsZfCU3uw8fQVEzUSk696iO85zbfiyB+UQRoUp1vWpas?= =?us-ascii?Q?6DQe57HkP2WrP4wKdYeJVYLoLBokmU0AsIVSt4W3qYOu7xKqYju597s6mqeU?= =?us-ascii?Q?spCSSdS6gEMXOR8XcqdDDevYKlgDue3Hhe61nwrFQvf/nUC9+2PIVdP4diEj?= =?us-ascii?Q?qJgJmB5bXNtLLSj/gp5Aag44quS1/MTEHwPa9Ks4C411hwxmu7VsurW82/Zy?= =?us-ascii?Q?keejbByaxUjWAVktwrTaQkcKosvlt38qwf7LOrpC7l6DP/x4hbUV8PRnLhFk?= =?us-ascii?Q?lXKjijayuHGVhQJxmaJrZNK1MEl9tSp21oBC5TzFNsQ+dcaN0Ssm3YOdMPuw?= =?us-ascii?Q?prOKs5G/E44bJXoIv21oz7Tz+xL0uukigIOnOmgda0WmnaGsIJZEmFSzcIUI?= =?us-ascii?Q?UQ=3D=3D?= 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: ab20799d-5ded-4bc0-6e79-08dbcc0d1b38 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Oct 2023 16:54:46.6145 (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: GyHosPIXp3izIIit77TxHcy0rB7ohvXcmVzTSB5vB1eTBvaKf2VKfjt5+A1PW8Lu4Anie01By+nDYXQbMZM9/Fe5tYtz1RTHzzoA3Xp1PYQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB5766 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: g8D9kwsnC65uUrmP8gz06uSdx7686176AA= 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=xBIB20Ph; 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 Reviewed-by: Michael D Kinney > -----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 >=20 > This commit adds host-based unit tests for device path lib. >=20 >=20 >=20 > Cc: Michael D Kinney >=20 > Cc: Liming Gao >=20 > Cc: Zhiguang Liu >=20 >=20 >=20 > Signed-off-by: Mateusz Albecki >=20 > --- >=20 > MdePkg/MdePkg.ci.yaml | 5 +- >=20 > MdePkg/Test/MdePkgHostTest.dsc | 2 + >=20 > .../Library/DevicePathLib/TestDevicePathLib.c | 638 > ++++++++++++++++++ >=20 > .../Library/DevicePathLib/TestDevicePathLib.h | 26 + >=20 > .../DevicePathLib/TestDevicePathLibHost.inf | 33 + >=20 > .../TestDevicePathStringConversions.c | 370 ++++++++++ >=20 > 6 files changed, 1073 insertions(+), 1 deletion(-) >=20 > create mode 100644 > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c >=20 > create mode 100644 > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h >=20 > create mode 100644 > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf >=20 > create mode 100644 > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConvers > ions.c >=20 >=20 >=20 > diff --git a/MdePkg/MdePkg.ci.yaml b/MdePkg/MdePkg.ci.yaml >=20 > index c3faf4913d..45f4fb537b 100644 >=20 > --- a/MdePkg/MdePkg.ci.yaml >=20 > +++ b/MdePkg/MdePkg.ci.yaml >=20 > @@ -74,7 +74,10 @@ >=20 >=20 > "Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.c", >=20 > "Library/BaseFdtLib", >=20 > "Library/MipiSysTLib/mipi_syst.h", >=20 > - "Include/Register/Amd/SmramSaveStateMap.h" >=20 > + "Include/Register/Amd/SmramSaveStateMap.h", >=20 > + > "Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c", >=20 > + > "Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h", >=20 > + > "Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConversions.c > " >=20 > ] >=20 > }, >=20 > ## options defined ci/Plugin/CompilerPlugin >=20 > diff --git a/MdePkg/Test/MdePkgHostTest.dsc > b/MdePkg/Test/MdePkgHostTest.dsc >=20 > index 529ea69024..b92b564d43 100644 >=20 > --- a/MdePkg/Test/MdePkgHostTest.dsc >=20 > +++ b/MdePkg/Test/MdePkgHostTest.dsc >=20 > @@ -21,6 +21,7 @@ >=20 >=20 >=20 > [LibraryClasses] >=20 > SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf >=20 > + > DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibBase.i > nf >=20 >=20 >=20 > [Components] >=20 > # >=20 > @@ -29,6 +30,7 @@ >=20 >=20 > MdePkg/Test/UnitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibHost.inf >=20 > MdePkg/Test/UnitTest/Library/BaseLib/BaseLibUnitTestsHost.inf >=20 >=20 > MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib > .inf >=20 > + > MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf >=20 >=20 >=20 > # >=20 > # Build HOST_APPLICATION Libraries >=20 > diff --git > a/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c >=20 > new file mode 100644 >=20 > index 0000000000..687497278c >=20 > --- /dev/null >=20 > +++ b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.c >=20 > @@ -0,0 +1,638 @@ >=20 > +/** @file >=20 > + UEFI OS based application for unit testing the DevicePathLib. >=20 > + >=20 > + Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +**/ >=20 > + >=20 > +#include "TestDevicePathLib.h" >=20 > + >=20 > +#define UNIT_TEST_NAME "DevicePathLib Unit Test Application" >=20 > +#define UNIT_TEST_VERSION "0.1" >=20 > + >=20 > +typedef struct { >=20 > + ACPI_HID_DEVICE_PATH AcpiPath; >=20 > + PCI_DEVICE_PATH PciPathRootPort; >=20 > + PCI_DEVICE_PATH PciPathEndPoint; >=20 > + USB_DEVICE_PATH UsbPath; >=20 > + EFI_DEVICE_PATH_PROTOCOL End; >=20 > +} TEST_COMPLEX_DEVICE_PATH; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED TEST_COMPLEX_DEVICE_PATH > mComplexDevicePath =3D { >=20 > + { // ACPI device path with root bridge EISA_PNP_ID >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0x0A03), >=20 > + 0 >=20 > + }, >=20 > + { // PCI device path - root port (0x2:0x0) >=20 > + { >=20 > + HARDWARE_DEVICE_PATH, >=20 > + HW_PCI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (PCI_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + 0x2, >=20 > + 0x0 >=20 > + }, >=20 > + { // PCI device path - endpoint (0x0:0x0) >=20 > + { >=20 > + HARDWARE_DEVICE_PATH, >=20 > + HW_PCI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (PCI_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + 0x0, >=20 > + 0x0 >=20 > + }, >=20 > + { // USB interface >=20 > + { >=20 > + MESSAGING_DEVICE_PATH, >=20 > + MSG_USB_DP, >=20 > + { >=20 > + (UINT8)(sizeof (USB_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + 0, >=20 > + 2 >=20 > + }, >=20 > + { >=20 > + END_DEVICE_PATH_TYPE, >=20 > + END_ENTIRE_DEVICE_PATH_SUBTYPE, >=20 > + { >=20 > + (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)), >=20 > + (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8) >=20 > + } >=20 > + } >=20 > +}; >=20 > + >=20 > +CONST GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mComplexDevicePathString > =3D L"PciRoot(0x0)/Pci(0x0,0x2)/Pci(0x0,0x0)/USB(0x0,0x2)"; >=20 > + >=20 > +CONST GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mPciEndPointPathString =3D > L"Pci(0x0, 0x0)"; >=20 > + >=20 > +typedef struct { >=20 > + ACPI_HID_DEVICE_PATH AcpiPath; >=20 > + EFI_DEVICE_PATH_PROTOCOL End; >=20 > +} TEST_SIMPLE_DEVICE_PATH; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED TEST_SIMPLE_DEVICE_PATH > mSimpleDevicePath =3D { >=20 > + { // ACPI device path with root bridge EISA_PNP_ID >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0x0A03), >=20 > + 0 >=20 > + }, >=20 > + { >=20 > + END_DEVICE_PATH_TYPE, >=20 > + END_ENTIRE_DEVICE_PATH_SUBTYPE, >=20 > + { >=20 > + (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)), >=20 > + (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8) >=20 > + } >=20 > + } >=20 > +}; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED TEST_SIMPLE_DEVICE_PATH > mInvalidSimpleDevicePath =3D { >=20 > + { // ACPI device path with root bridge EISA_PNP_ID >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_DP, >=20 > + { >=20 > + 0, >=20 > + 0 >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0x0A03), >=20 > + 0 >=20 > + }, >=20 > + { >=20 > + END_DEVICE_PATH_TYPE, >=20 > + END_ENTIRE_DEVICE_PATH_SUBTYPE, >=20 > + { >=20 > + (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)), >=20 > + (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8) >=20 > + } >=20 > + } >=20 > +}; >=20 > + >=20 > +typedef struct { >=20 > + TEST_SIMPLE_DEVICE_PATH *SimpleDevicePath; >=20 > + TEST_SIMPLE_DEVICE_PATH *InvalidDevicePath; >=20 > + TEST_COMPLEX_DEVICE_PATH *ComplexDevicePath; >=20 > +} SIMPLE_TEST_SUITE_CONTEXT; >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestIsDevicePathValid ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + BOOLEAN IsValid; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext->SimpleDevicePath, sizeof (TEST_SIMPLE_DEVICE_PATH)); >=20 > + UT_ASSERT_TRUE (IsValid); >=20 > + >=20 > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext->ComplexDevicePath, sizeof (TEST_COMPLEX_DEVICE_PATH)); >=20 > + UT_ASSERT_TRUE (IsValid); >=20 > + >=20 > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext->ComplexDevicePath, 0); >=20 > + UT_ASSERT_TRUE (IsValid); >=20 > + >=20 > + // Device path can't be NULL >=20 > + IsValid =3D IsDevicePathValid (NULL, 0); >=20 > + UT_ASSERT_FALSE (IsValid); >=20 > + >=20 > + // MaxSize can't be less then the size of the device path >=20 > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext->SimpleDevicePath, sizeof (TEST_SIMPLE_DEVICE_PATH) - > 1); >=20 > + UT_ASSERT_FALSE (IsValid); >=20 > + >=20 > + // If MaxSize !=3D 0 it must be bigger then EFI_DEVICE_PATH_PROTOCOL >=20 > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext->SimpleDevicePath, sizeof (EFI_DEVICE_PATH_PROTOCOL) - > 1); >=20 > + UT_ASSERT_FALSE (IsValid); >=20 > + >=20 > + IsValid =3D IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext->InvalidDevicePath, 0); >=20 > + UT_ASSERT_FALSE (IsValid); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestDevicePathType ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + UINT8 Type; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + // Test 2 types just in case the implementation is returning > constant value >=20 > + // NOTE: passing NULL to this function causes NULL pointer > dereference. >=20 > + Type =3D DevicePathType (&TestContext->ComplexDevicePath->AcpiPath); >=20 > + UT_ASSERT_EQUAL (Type, ACPI_DEVICE_PATH); >=20 > + >=20 > + Type =3D DevicePathType (&TestContext->ComplexDevicePath- > >PciPathRootPort); >=20 > + UT_ASSERT_EQUAL (Type, HARDWARE_DEVICE_PATH); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestDevicePathSubType ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + UINT8 SubType; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + // Test 2 sub types just in case the implementation is returning > constant value >=20 > + // NOTE: passing NULL to this function causes NULL pointer > dereference. >=20 > + SubType =3D DevicePathSubType (&TestContext->ComplexDevicePath- > >AcpiPath); >=20 > + UT_ASSERT_EQUAL (SubType, ACPI_DP); >=20 > + >=20 > + SubType =3D DevicePathSubType (&TestContext->ComplexDevicePath- > >PciPathRootPort); >=20 > + UT_ASSERT_EQUAL (SubType, HW_PCI_DP); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestDevicePathNodeLength ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + UINTN Length; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + // Test 2 nodes just in case the implementation is returning > constant value >=20 > + // NOTE: passing NULL to this function causes NULL pointer > dereference. >=20 > + Length =3D DevicePathNodeLength (&TestContext->ComplexDevicePath- > >AcpiPath); >=20 > + UT_ASSERT_EQUAL (Length, sizeof (ACPI_HID_DEVICE_PATH)); >=20 > + >=20 > + Length =3D DevicePathNodeLength (&TestContext->ComplexDevicePath- > >PciPathRootPort); >=20 > + UT_ASSERT_EQUAL (Length, sizeof (PCI_DEVICE_PATH)); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestNextDevicePathNode ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + VOID *Node; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + Node =3D &mComplexDevicePath; >=20 > + Node =3D NextDevicePathNode (Node); >=20 > + UT_ASSERT_MEM_EQUAL (Node, &TestContext->ComplexDevicePath- > >PciPathRootPort, DevicePathNodeLength (Node)); >=20 > + >=20 > + Node =3D NextDevicePathNode (Node); >=20 > + UT_ASSERT_MEM_EQUAL (Node, &TestContext->ComplexDevicePath- > >PciPathEndPoint, DevicePathNodeLength (Node)); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestIsDevicePathEndType ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + BOOLEAN IsEndType; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + IsEndType =3D IsDevicePathEndType (&TestContext->ComplexDevicePath- > >PciPathRootPort); >=20 > + UT_ASSERT_FALSE (IsEndType); >=20 > + >=20 > + IsEndType =3D IsDevicePathEndType (&TestContext->ComplexDevicePath- > >End); >=20 > + UT_ASSERT_TRUE (IsEndType); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestIsDevicePathEnd ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + BOOLEAN IsEnd; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + IsEnd =3D IsDevicePathEnd (&TestContext->ComplexDevicePath- > >PciPathRootPort); >=20 > + UT_ASSERT_FALSE (IsEnd); >=20 > + >=20 > + IsEnd =3D IsDevicePathEnd (&TestContext->ComplexDevicePath->End); >=20 > + UT_ASSERT_TRUE (IsEnd); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestSetDevicePathNodeLength ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL DevPath; >=20 > + >=20 > + // NOTE: Node =3D=3D NULL or NodeLength >=3D 0x10000 NodeLength < size= of > (EFI_DEVICE_PATH_PROTOCOL) >=20 > + // are all invalid parameters. However there are only ASSERTS added > to catch them so there is no >=20 > + // way to test it. >=20 > + SetDevicePathNodeLength (&DevPath, sizeof > (EFI_DEVICE_PATH_PROTOCOL)); >=20 > + UT_ASSERT_EQUAL (DevicePathNodeLength (&DevPath), sizeof > (EFI_DEVICE_PATH_PROTOCOL)); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestSetDevicePathEndNode ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL EndNode; >=20 > + >=20 > + SetDevicePathEndNode (&EndNode); >=20 > + UT_ASSERT_EQUAL (EndNode.Type, END_DEVICE_PATH_TYPE); >=20 > + UT_ASSERT_EQUAL (EndNode.SubType, END_ENTIRE_DEVICE_PATH_SUBTYPE); >=20 > + UT_ASSERT_EQUAL (DevicePathNodeLength (&EndNode), > END_DEVICE_PATH_LENGTH); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestGetDevicePathSize ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + UINTN Size; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + Size =3D GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)TestContext- > >SimpleDevicePath); >=20 > + UT_ASSERT_EQUAL (Size, sizeof (TEST_SIMPLE_DEVICE_PATH)); >=20 > + >=20 > + Size =3D GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)TestContext- > >ComplexDevicePath); >=20 > + UT_ASSERT_EQUAL (Size, sizeof (TEST_COMPLEX_DEVICE_PATH)); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestDuplicateDevicePath ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL *Duplicate; >=20 > + SIMPLE_TEST_SUITE_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (SIMPLE_TEST_SUITE_CONTEXT *)Context; >=20 > + >=20 > + Duplicate =3D DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL > *)TestContext->ComplexDevicePath); >=20 > + UT_ASSERT_EQUAL (GetDevicePathSize (Duplicate), GetDevicePathSize > ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->ComplexDevicePath)); >=20 > + UT_ASSERT_MEM_EQUAL (Duplicate, TestContext->ComplexDevicePath, > GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)TestContext- > >ComplexDevicePath)); >=20 > + FreePool (Duplicate); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestAppendDevicePath ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL *Appended; >=20 > + EFI_DEVICE_PATH_PROTOCOL *NextNode; >=20 > + >=20 > + Appended =3D AppendDevicePath ((EFI_DEVICE_PATH_PROTOCOL > *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL > *)&mComplexDevicePath); >=20 > + NextNode =3D NextDevicePathNode (Appended); >=20 > + UT_ASSERT_MEM_EQUAL (NextNode, &mSimpleDevicePath.AcpiPath, sizeof > (ACPI_HID_DEVICE_PATH)); >=20 > + FreePool (Appended); >=20 > + >=20 > + // If one of the paths is invalid result device path should be NULL >=20 > + Appended =3D AppendDevicePath ((EFI_DEVICE_PATH_PROTOCOL > *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL > *)&mInvalidSimpleDevicePath); >=20 > + UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL); >=20 > + >=20 > + Appended =3D AppendDevicePath (NULL, NULL); >=20 > + UT_ASSERT_EQUAL (Appended->Type, END_DEVICE_PATH_TYPE); >=20 > + UT_ASSERT_EQUAL (Appended->SubType, > END_ENTIRE_DEVICE_PATH_SUBTYPE); >=20 > + UT_ASSERT_EQUAL (DevicePathNodeLength (Appended), > END_DEVICE_PATH_LENGTH); >=20 > + FreePool (Appended); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestAppendDevicePathNode ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL *Appended; >=20 > + EFI_DEVICE_PATH_PROTOCOL *NextNode; >=20 > + BOOLEAN IsValid; >=20 > + ACPI_HID_DEVICE_PATH AcpiPath =3D >=20 > + { >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0x0AAB), >=20 > + 0 >=20 > + }; >=20 > + >=20 > + Appended =3D AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL > *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&AcpiPath); >=20 > + NextNode =3D NextDevicePathNode (Appended); >=20 > + UT_ASSERT_MEM_EQUAL (NextNode, &AcpiPath, sizeof > (ACPI_HID_DEVICE_PATH)); >=20 > + FreePool (Appended); >=20 > + >=20 > + Appended =3D AppendDevicePathNode (NULL, (EFI_DEVICE_PATH_PROTOCOL > *)&AcpiPath); >=20 > + UT_ASSERT_MEM_EQUAL (Appended, &AcpiPath, sizeof > (ACPI_HID_DEVICE_PATH)); >=20 > + IsValid =3D IsDevicePathValid (Appended, 0); >=20 > + UT_ASSERT_TRUE (IsValid); >=20 > + FreePool (Appended); >=20 > + >=20 > + Appended =3D AppendDevicePathNode (NULL, NULL); >=20 > + UT_ASSERT_EQUAL (Appended->Type, END_DEVICE_PATH_TYPE); >=20 > + UT_ASSERT_EQUAL (Appended->SubType, > END_ENTIRE_DEVICE_PATH_SUBTYPE); >=20 > + UT_ASSERT_EQUAL (DevicePathNodeLength (Appended), > END_DEVICE_PATH_LENGTH); >=20 > + FreePool (Appended); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestAppendDevicePathInstance ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL *Appended; >=20 > + EFI_DEVICE_PATH_PROTOCOL *NextInstance; >=20 > + EFI_DEVICE_PATH_PROTOCOL *NextInstanceRet; >=20 > + BOOLEAN IsMultiInstance; >=20 > + UINTN Size; >=20 > + >=20 > + Appended =3D AppendDevicePathInstance > ((EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath, > (EFI_DEVICE_PATH_PROTOCOL *)&mComplexDevicePath); >=20 > + IsMultiInstance =3D IsDevicePathMultiInstance (Appended); >=20 > + UT_ASSERT_TRUE (IsMultiInstance); >=20 > + UT_ASSERT_MEM_EQUAL (Appended, &mSimpleDevicePath, sizeof > (ACPI_DEVICE_PATH)); >=20 > + NextInstance =3D Appended; >=20 > + NextInstanceRet =3D GetNextDevicePathInstance (&NextInstance, &Size); >=20 > + UT_ASSERT_MEM_EQUAL (NextInstance, &mComplexDevicePath, Size); >=20 > + FreePool (Appended); >=20 > + FreePool (NextInstanceRet); >=20 > + >=20 > + Appended =3D AppendDevicePathInstance (NULL, > (EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath); >=20 > + UT_ASSERT_MEM_EQUAL (Appended, &mSimpleDevicePath, sizeof > (TEST_SIMPLE_DEVICE_PATH)); >=20 > + FreePool (Appended); >=20 > + >=20 > + Appended =3D AppendDevicePathInstance (NULL, NULL); >=20 > + UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL); >=20 > + FreePool (Appended); >=20 > + >=20 > + Appended =3D AppendDevicePathInstance ((EFI_DEVICE_PATH_PROTOCOL > *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL > *)&mInvalidSimpleDevicePath); >=20 > + UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL); >=20 > + FreePool (Appended); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestDevicePathFromHandle ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_HANDLE Handle; >=20 > + EFI_DEVICE_PATH_PROTOCOL *DevicePath; >=20 > + UINTN FakeHandle; >=20 > + >=20 > + Handle =3D NULL; >=20 > + DevicePath =3D DevicePathFromHandle (Handle); >=20 > + UT_ASSERT_EQUAL ((uintptr_t)DevicePath, (uintptr_t)NULL); >=20 > + >=20 > + Handle =3D (EFI_HANDLE)&FakeHandle; >=20 > + DevicePath =3D DevicePathFromHandle (Handle); >=20 > + UT_ASSERT_EQUAL ((uintptr_t)DevicePath, (uintptr_t)NULL); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestCreateDeviceNode ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL *DevNode; >=20 > + >=20 > + DevNode =3D CreateDeviceNode (HARDWARE_DEVICE_PATH, HW_PCI_DP, sizeof > (PCI_DEVICE_PATH)); >=20 > + UT_ASSERT_EQUAL (DevNode->Type, HARDWARE_DEVICE_PATH); >=20 > + UT_ASSERT_EQUAL (DevNode->SubType, HW_PCI_DP); >=20 > + UT_ASSERT_EQUAL (DevicePathNodeLength (DevNode), sizeof > (PCI_DEVICE_PATH)); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestFileDevicePath ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_HANDLE Handle; >=20 > + FILEPATH_DEVICE_PATH *DevicePath; >=20 > + CONST CHAR16 *TestFilePath =3D L"FS0:/Boot/EFI/BootMgr.efi"; >=20 > + >=20 > + Handle =3D NULL; >=20 > + DevicePath =3D (FILEPATH_DEVICE_PATH *)FileDevicePath (Handle, > TestFilePath); >=20 > + UT_ASSERT_NOT_NULL (DevicePath); >=20 > + UT_ASSERT_EQUAL (DevicePath->Header.Type, MEDIA_DEVICE_PATH); >=20 > + UT_ASSERT_EQUAL (DevicePath->Header.Type, MEDIA_FILEPATH_DP); >=20 > + UT_ASSERT_MEM_EQUAL (DevicePath->PathName, TestFilePath, StrSize > (TestFilePath)); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +/** >=20 > + >=20 > + Main fuction sets up the unit test environment >=20 > + >=20 > +**/ >=20 > +EFI_STATUS >=20 > +EFIAPI >=20 > +UefiTestMain ( >=20 > + VOID >=20 > + ) >=20 > +{ >=20 > + EFI_STATUS Status; >=20 > + UNIT_TEST_FRAMEWORK_HANDLE Framework; >=20 > + UNIT_TEST_SUITE_HANDLE DevicePathSimpleTestSuite; >=20 > + UNIT_TEST_SUITE_HANDLE DevicePathAppendTestSuite; >=20 > + UNIT_TEST_SUITE_HANDLE DevicePathFileTestSuite; >=20 > + SIMPLE_TEST_SUITE_CONTEXT SimpleTestContext; >=20 > + >=20 > + DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_NAME, > UNIT_TEST_VERSION)); >=20 > + >=20 > + Framework =3D NULL; >=20 > + DevicePathSimpleTestSuite =3D NULL; >=20 > + DevicePathAppendTestSuite =3D NULL; >=20 > + DevicePathFileTestSuite =3D NULL; >=20 > + >=20 > + Status =3D InitUnitTestFramework (&Framework, UNIT_TEST_NAME, > gEfiCallerBaseName, UNIT_TEST_VERSION); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status =3D > %r\n", Status)); >=20 > + goto EXIT; >=20 > + } >=20 > + >=20 > + Status =3D CreateUnitTestSuite (&DevicePathSimpleTestSuite, > Framework, "Simple device path operations test suite", > "Common.DevicePath.SimpleOps", NULL, NULL); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "Failed to create simple device path test > suite\n")); >=20 > + goto EXIT; >=20 > + } >=20 > + >=20 > + SimpleTestContext.SimpleDevicePath =3D &mSimpleDevicePath; >=20 > + SimpleTestContext.InvalidDevicePath =3D &mInvalidSimpleDevicePath; >=20 > + SimpleTestContext.ComplexDevicePath =3D &mComplexDevicePath; >=20 > + >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test IsDevicePathValid", > "TestIsDevicePathValid", TestIsDevicePathValid, NULL, NULL, > &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test DevicePathType", > "TestDevicePathType", TestDevicePathType, NULL, NULL, > &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test DevicePathSubType", > "TestDevicePathSubType", TestDevicePathSubType, NULL, NULL, > &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test > DevicePathNodeLength", "TestDevicePathNodeLength", > TestDevicePathNodeLength, NULL, NULL, &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test NextDevicePathNode", > "TestNextDevicePathNode", TestNextDevicePathNode, NULL, NULL, > &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test IsDevicePathEndType", > "TestIsDevicePathEndType", TestIsDevicePathEndType, NULL, NULL, > &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test IsDevicePathEnd", > "TestIsDevicePathEnd", TestIsDevicePathEnd, NULL, NULL, > &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test > SetDevicePathNodeLength", "TestSetDevicePathNodeLength", > TestSetDevicePathNodeLength, NULL, NULL, &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test GetDevicePathSize", > "TestGetDevicePathSize", TestGetDevicePathSize, NULL, NULL, > &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test CreateDeviceNode", > "TestCreateDeviceNode", TestCreateDeviceNode, NULL, NULL, > &SimpleTestContext); >=20 > + AddTestCase (DevicePathSimpleTestSuite, "Test > SetDevicePathEndNode", "TestSetDevicePathEndNode", > TestSetDevicePathEndNode, NULL, NULL, &SimpleTestContext); >=20 > + AddTestCase (DevicePathAppendTestSuite, "Test DuplicateDevicePath", > "TestDuplicateDevicePath", TestDuplicateDevicePath, NULL, NULL, > &SimpleTestContext); >=20 > + >=20 > + Status =3D CreateUnitTestSuite (&DevicePathAppendTestSuite, > Framework, "Device path append operations test suite", > "Common.DevicePath.Append", NULL, NULL); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "Failed to create append device path test > suite\n")); >=20 > + goto EXIT; >=20 > + } >=20 > + >=20 > + AddTestCase (DevicePathAppendTestSuite, "Test AppendDevicePath", > "TestAppendDevicePath", TestAppendDevicePath, NULL, NULL, NULL); >=20 > + AddTestCase (DevicePathAppendTestSuite, "Test > AppendDevicePathNode", "TestAppendDevicePathNode", > TestAppendDevicePathNode, NULL, NULL, NULL); >=20 > + AddTestCase (DevicePathAppendTestSuite, "Test > AppendDevicePathInstance", "TestAppendDevicePathInstance", > TestAppendDevicePathInstance, NULL, NULL, NULL); >=20 > + >=20 > + Status =3D CreateDevicePathStringConversionsTestSuite (Framework); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "Failed to create conversions test > suite\n")); >=20 > + goto EXIT; >=20 > + } >=20 > + >=20 > + Status =3D CreateUnitTestSuite (&DevicePathFileTestSuite, Framework, > "Device path file operations test suite", > "Common.DevicePath.FileDevPath", NULL, NULL); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "Failed to create device path file test > suite\n")); >=20 > + goto EXIT; >=20 > + } >=20 > + >=20 > + AddTestCase (DevicePathFileTestSuite, "Test DevicePathFromHandle", > "TestDevicePathFromHandle", TestDevicePathFromHandle, NULL, NULL, > NULL); >=20 > + AddTestCase (DevicePathFileTestSuite, "Test FileDevicePath", > "TestFileDevicePath", TestFileDevicePath, NULL, NULL, NULL); >=20 > + >=20 > + Status =3D RunAllTestSuites (Framework); >=20 > + >=20 > +EXIT: >=20 > + if (Framework !=3D NULL) { >=20 > + FreeUnitTestFramework (Framework); >=20 > + } >=20 > + >=20 > + return Status; >=20 > +} >=20 > + >=20 > +int >=20 > +main ( >=20 > + int argc, >=20 > + char *argv[] >=20 > + ) >=20 > +{ >=20 > + return UefiTestMain (); >=20 > +} >=20 > diff --git > a/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h >=20 > new file mode 100644 >=20 > index 0000000000..4a0c3d4c43 >=20 > --- /dev/null >=20 > +++ b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLib.h >=20 > @@ -0,0 +1,26 @@ >=20 > +/** @file >=20 > + UEFI OS based application for unit testing the DevicePathLib. >=20 > + >=20 > + Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +**/ >=20 > + >=20 > +#ifndef __TEST_DEVICE_PATH_LIB_H__ >=20 > +#define __TEST_DEVICE_PATH_LIB_H__ >=20 > + >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > +#include >=20 > + >=20 > +EFI_STATUS >=20 > +CreateDevicePathStringConversionsTestSuite ( >=20 > + IN UNIT_TEST_FRAMEWORK_HANDLE Framework >=20 > + ); >=20 > + >=20 > +#endif >=20 > diff --git > a/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf >=20 > new file mode 100644 >=20 > index 0000000000..9f9c36946a >=20 > --- /dev/null >=20 > +++ > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathLibHost.inf >=20 > @@ -0,0 +1,33 @@ >=20 > +## @file >=20 > +# Host OS based Application that Unit Tests the UefiDevicePathLib >=20 > +# >=20 > +# Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > +# SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > +## >=20 > + >=20 > +[Defines] >=20 > + INF_VERSION =3D 0x00010005 >=20 > + BASE_NAME =3D TestDevicePathLibHost >=20 > + MODULE_UNI_FILE =3D TestDevicePathLib.uni >=20 > + FILE_GUID =3D F1505A0E-D71F-4431-99BE-736776842E38 >=20 > + MODULE_TYPE =3D HOST_APPLICATION >=20 > + VERSION_STRING =3D 1.0 >=20 > + >=20 > +# >=20 > +# The following information is for reference only and not required by > the build tools. >=20 > +# >=20 > +# VALID_ARCHITECTURES =3D IA32 X64 >=20 > +# >=20 > + >=20 > +[Sources] >=20 > + TestDevicePathLib.c >=20 > + TestDevicePathStringConversions.c >=20 > + >=20 > +[Packages] >=20 > + MdePkg/MdePkg.dec >=20 > + >=20 > +[LibraryClasses] >=20 > + BaseLib >=20 > + DebugLib >=20 > + DevicePathLib >=20 > + UnitTestLib >=20 > diff --git > a/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConve > rsions.c > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConve > rsions.c >=20 > new file mode 100644 >=20 > index 0000000000..4ea25ec142 >=20 > --- /dev/null >=20 > +++ > b/MdePkg/Test/UnitTest/Library/DevicePathLib/TestDevicePathStringConve > rsions.c >=20 > @@ -0,0 +1,370 @@ >=20 > +/** @file >=20 > + UEFI OS based application for unit testing the DevicePathLib. >=20 > + >=20 > + Copyright (c) 2023, Intel Corporation. All rights reserved.
>=20 > + SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > + >=20 > +**/ >=20 > + >=20 > +#include "TestDevicePathLib.h" >=20 > + >=20 > +typedef struct { >=20 > + EFI_DEVICE_PATH_PROTOCOL *DevPath; >=20 > + CONST CHAR16 *DevPathString; >=20 > +} DEVICE_PATH_CONVERSIONS_TEST_CONTEXT; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED PCI_DEVICE_PATH mPciDevicePathNode =3D >=20 > +{ >=20 > + // PCI device path - root port (0x2:0x0) >=20 > + { >=20 > + HARDWARE_DEVICE_PATH, >=20 > + HW_PCI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (PCI_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + 0x2, >=20 > + 0x0 >=20 > +}; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_HID_DEVICE_PATH > mAcpiPciRootHidDevicePathNode =3D >=20 > +{ >=20 > + // ACPI PCI root - PciRoot(0x0) >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0x0A03), >=20 > + 0 >=20 > +}; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_HID_DEVICE_PATH > mAcpiNonPciRootHidDevicePathNode =3D >=20 > +{ >=20 > + // Random ACPI device - ACPI(PNPB0C0, 1) >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0xB0C0), >=20 > + 1 >=20 > +}; >=20 > + >=20 > +#define HID_STR_SIZE 8 >=20 > +#define CID_STR_SIZE 8 >=20 > +#define UID_STR_SIZE 8 >=20 > + >=20 > +typedef struct { >=20 > + ACPI_EXTENDED_HID_DEVICE_PATH AcpiEx; >=20 > + CHAR8 HidStr[HID_STR_SIZE]; >=20 > + CHAR8 CidStr[CID_STR_SIZE]; >=20 > + CHAR8 UidStr[UID_STR_SIZE]; >=20 > +} ACPI_EXTENDED_HID_DEVICE_PATH_FULL; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_EXTENDED_HID_DEVICE_PATH_FULL > mAcpiExtendedDevicePathFull =3D >=20 > +{ >=20 > + // ACPI Extended HID PciRoot device node >=20 > + { >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_EXTENDED_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_EXTENDED_HID_DEVICE_PATH_FULL)), >=20 > + (UINT8)((sizeof (ACPI_EXTENDED_HID_DEVICE_PATH_FULL)) >> 8) >=20 > + } >=20 > + }, >=20 > + 0, >=20 > + 0, >=20 > + 0, >=20 > + }, >=20 > + { 'P', 'N', 'P', 'B', '0', 'C', '0', '\0' }, // HIDSTR >=20 > + { 'P', 'N', 'P', '0', '0', '0', '1', '\0' }, // CIDSTR >=20 > + { 'U', 'I', 'D', '0', '0', '0', '0', '\0' } // UIDSTR >=20 > +}; >=20 > + >=20 > +typedef struct { >=20 > + ACPI_EXTENDED_HID_DEVICE_PATH AcpiEx; >=20 > + CHAR8 HidStr[HID_STR_SIZE]; >=20 > +} ACPI_EXTENDED_HID_DEVICE_PATH_PARTIAL; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_EXTENDED_HID_DEVICE_PATH_PARTIAL > mAcpiExtendedDevicePathPartial =3D >=20 > +{ >=20 > + { >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_EXTENDED_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_EXTENDED_HID_DEVICE_PATH_PARTIAL)), >=20 > + (UINT8)((sizeof (ACPI_EXTENDED_HID_DEVICE_PATH_PARTIAL)) >> > 8) >=20 > + } >=20 > + }, >=20 > + 0, >=20 > + 2, >=20 > + 0, >=20 > + }, >=20 > + { 'P', 'N', 'P', 'B', '0', '\0', '\0', '\0' }, // HIDSTR >=20 > +}; >=20 > + >=20 > +typedef struct { >=20 > + ACPI_EXTENDED_HID_DEVICE_PATH AcpiEx; >=20 > + CHAR8 UidStr[UID_STR_SIZE]; >=20 > +} ACPI_EXPANDED_DEVICE_PATH; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_EXPANDED_DEVICE_PATH > mAcpiExpandedDevicePathUidOnly =3D >=20 > +{ >=20 > + { >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_EXTENDED_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_EXPANDED_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (ACPI_EXPANDED_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0xAAAA), >=20 > + 0, >=20 > + 0, >=20 > + }, >=20 > + { '\0', 'U', 'I', 'D', '0', '0', '\0', '\0' } // UIDSTR >=20 > +}; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED ACPI_EXPANDED_DEVICE_PATH > mAcpiExpandedDevicePathUidOnlyWithCid =3D >=20 > +{ >=20 > + { >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_EXTENDED_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_EXPANDED_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (ACPI_EXPANDED_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0xAAAA), >=20 > + 0, >=20 > + EISA_PNP_ID (0xAADD), >=20 > + }, >=20 > + { '\0', 'U', 'I', 'D', '0', '0', '\0', '\0' } // UIDSTR >=20 > +}; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_CONVERSIONS_TEST_CONTEXT > mDevPathNodeToFromTextContext[] =3D { >=20 > + { >=20 > + (EFI_DEVICE_PATH_PROTOCOL *)&mPciDevicePathNode, >=20 > + L"Pci(0x0,0x2)" >=20 > + }, >=20 > + { >=20 > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiPciRootHidDevicePathNode, >=20 > + L"PciRoot(0x0)" >=20 > + }, >=20 > + { >=20 > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiNonPciRootHidDevicePathNode, >=20 > + L"Acpi(PNPB0C0,0x1)" >=20 > + }, >=20 > + { >=20 > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiExtendedDevicePathFull, >=20 > + L"AcpiEx(@@@0000,@@@0000,0x0,PNPB0C0,UID0000,PNP0001)" >=20 > + }, >=20 > + { >=20 > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiExtendedDevicePathPartial, >=20 > + L"AcpiEx(@@@0000,@@@0000,0x2,PNPB0,,)" >=20 > + }, >=20 > + { >=20 > + (EFI_DEVICE_PATH_PROTOCOL *)&mAcpiExpandedDevicePathUidOnly, >=20 > + L"AcpiExp(PNPAAAA,0,UID00)" >=20 > + }, >=20 > + { >=20 > + (EFI_DEVICE_PATH_PROTOCOL > *)&mAcpiExpandedDevicePathUidOnlyWithCid, >=20 > + L"AcpiExp(PNPAAAA,PNPAADD,UID00)" >=20 > + } >=20 > +}; >=20 > + >=20 > +typedef struct { >=20 > + ACPI_HID_DEVICE_PATH AcpiPath; >=20 > + PCI_DEVICE_PATH PciPathRootPort; >=20 > + PCI_DEVICE_PATH PciPathEndPoint; >=20 > + USB_DEVICE_PATH UsbPath; >=20 > + EFI_DEVICE_PATH_PROTOCOL End; >=20 > +} TEST_CONVERSIONS_DEVICE_PATH; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED TEST_CONVERSIONS_DEVICE_PATH > mConversionsDevicePath =3D { >=20 > + { // ACPI device path with root bridge EISA_PNP_ID >=20 > + { >=20 > + ACPI_DEVICE_PATH, >=20 > + ACPI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + EISA_PNP_ID (0x0A03), >=20 > + 0 >=20 > + }, >=20 > + { // PCI device path - root port (0x2:0x0) >=20 > + { >=20 > + HARDWARE_DEVICE_PATH, >=20 > + HW_PCI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (PCI_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + 0x2, >=20 > + 0x0 >=20 > + }, >=20 > + { // PCI device path - endpoint (0x0:0x0) >=20 > + { >=20 > + HARDWARE_DEVICE_PATH, >=20 > + HW_PCI_DP, >=20 > + { >=20 > + (UINT8)(sizeof (PCI_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + 0x0, >=20 > + 0x0 >=20 > + }, >=20 > + { // USB interface >=20 > + { >=20 > + MESSAGING_DEVICE_PATH, >=20 > + MSG_USB_DP, >=20 > + { >=20 > + (UINT8)(sizeof (USB_DEVICE_PATH)), >=20 > + (UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8) >=20 > + } >=20 > + }, >=20 > + 0, >=20 > + 2 >=20 > + }, >=20 > + { >=20 > + END_DEVICE_PATH_TYPE, >=20 > + END_ENTIRE_DEVICE_PATH_SUBTYPE, >=20 > + { >=20 > + (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)), >=20 > + (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8) >=20 > + } >=20 > + } >=20 > +}; >=20 > + >=20 > +GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_CONVERSIONS_TEST_CONTEXT > mDevPathToFromTextContext[] =3D { >=20 > + { >=20 > + (EFI_DEVICE_PATH_PROTOCOL *)&mConversionsDevicePath, >=20 > + L"PciRoot(0x0)/Pci(0x0,0x2)/Pci(0x0,0x0)/USB(0x0,0x2)" >=20 > + } >=20 > +}; >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestConvertDevicePathToText ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + CHAR16 *DevPathString; >=20 > + DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *)Context; >=20 > + >=20 > + DevPathString =3D ConvertDevicePathToText (TestContext->DevPath, > FALSE, FALSE); >=20 > + UT_ASSERT_EQUAL (StrLen (DevPathString), StrLen (TestContext- > >DevPathString)); >=20 > + UT_ASSERT_MEM_EQUAL (DevPathString, TestContext->DevPathString, > StrLen (TestContext->DevPathString)); >=20 > + FreePool (DevPathString); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestConvertTextToDevicePath ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL *ConvertedDevPath; >=20 > + DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *)Context; >=20 > + >=20 > + ConvertedDevPath =3D ConvertTextToDevicePath (TestContext- > >DevPathString); >=20 > + UT_ASSERT_EQUAL (GetDevicePathSize (ConvertedDevPath), > GetDevicePathSize (TestContext->DevPath)); >=20 > + UT_ASSERT_MEM_EQUAL (ConvertedDevPath, TestContext->DevPath, > GetDevicePathSize (TestContext->DevPath)); >=20 > + FreePool (ConvertedDevPath); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestConvertDeviceNodeToText ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + CHAR16 *DevPathNodeString; >=20 > + DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *)Context; >=20 > + >=20 > + DevPathNodeString =3D ConvertDeviceNodeToText (TestContext->DevPath, > FALSE, FALSE); >=20 > + UT_ASSERT_EQUAL (StrLen (DevPathNodeString), StrLen (TestContext- > >DevPathString)); >=20 > + UT_ASSERT_MEM_EQUAL (DevPathNodeString, TestContext->DevPathString, > StrLen (TestContext->DevPathString)); >=20 > + FreePool (DevPathNodeString); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +UNIT_TEST_STATUS >=20 > +EFIAPI >=20 > +TestConvertTextToDeviceNode ( >=20 > + IN UNIT_TEST_CONTEXT Context >=20 > + ) >=20 > +{ >=20 > + EFI_DEVICE_PATH_PROTOCOL *DevPath; >=20 > + DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *TestContext; >=20 > + >=20 > + TestContext =3D (DEVICE_PATH_CONVERSIONS_TEST_CONTEXT *)Context; >=20 > + >=20 > + DevPath =3D ConvertTextToDeviceNode (TestContext->DevPathString); >=20 > + UT_ASSERT_EQUAL (DevicePathNodeLength (DevPath), > DevicePathNodeLength (TestContext->DevPath)); >=20 > + UT_ASSERT_MEM_EQUAL (DevPath, TestContext->DevPath, > DevicePathNodeLength (TestContext->DevPath)); >=20 > + FreePool (DevPath); >=20 > + >=20 > + return UNIT_TEST_PASSED; >=20 > +} >=20 > + >=20 > +EFI_STATUS >=20 > +CreateDevicePathStringConversionsTestSuite ( >=20 > + IN UNIT_TEST_FRAMEWORK_HANDLE Framework >=20 > + ) >=20 > +{ >=20 > + EFI_STATUS Status; >=20 > + UNIT_TEST_SUITE_HANDLE DevicePathTextConversionSuite =3D NULL; >=20 > + UINTN Index; >=20 > + >=20 > + Status =3D CreateUnitTestSuite (&DevicePathTextConversionSuite, > Framework, "Device path text conversion operations test suite", > "Common.DevicePath.TextConversions", NULL, NULL); >=20 > + if (EFI_ERROR (Status)) { >=20 > + DEBUG ((DEBUG_ERROR, "Failed to create device path text > conversions test suite\n")); >=20 > + return Status; >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < ARRAY_SIZE (mDevPathNodeToFromTextContext); > Index++) { >=20 > + AddTestCase (DevicePathTextConversionSuite, "Test > ConvertDeviceNodeToText", "TestConvertDeviceNodeToText", > TestConvertDeviceNodeToText, NULL, NULL, > &mDevPathNodeToFromTextContext[Index]); >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < ARRAY_SIZE (mDevPathNodeToFromTextContext); > Index++) { >=20 > + AddTestCase (DevicePathTextConversionSuite, "Test > ConvertTextToDeviceNode", "TestConvertTextToDeviceNode", > TestConvertTextToDeviceNode, NULL, NULL, > &mDevPathNodeToFromTextContext[Index]); >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < ARRAY_SIZE (mDevPathToFromTextContext); > Index++) { >=20 > + AddTestCase (DevicePathTextConversionSuite, "Test > ConvertDevicePathToText", "TestConvertDevicePathToText", > TestConvertDevicePathToText, NULL, NULL, > &mDevPathToFromTextContext[Index]); >=20 > + } >=20 > + >=20 > + for (Index =3D 0; Index < ARRAY_SIZE (mDevPathToFromTextContext); > Index++) { >=20 > + AddTestCase (DevicePathTextConversionSuite, "Test > ConvertTextToDevicePath", "TestConvertTextToDevicePath", > TestConvertTextToDevicePath, NULL, NULL, > &mDevPathToFromTextContext[Index]); >=20 > + } >=20 > + >=20 > + return EFI_SUCCESS; >=20 > +} >=20 > -- >=20 > 2.39.2 >=20 >=20 -=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 (#109594): https://edk2.groups.io/g/devel/message/109594 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-