10#define UNIT_TEST_NAME "DevicePathLib Unit Test Application"
11#define UNIT_TEST_VERSION "0.1"
72 END_ENTIRE_DEVICE_PATH_SUBTYPE,
103 END_DEVICE_PATH_TYPE,
104 END_ENTIRE_DEVICE_PATH_SUBTYPE,
122 EISA_PNP_ID (0x0A03),
126 END_DEVICE_PATH_TYPE,
127 END_ENTIRE_DEVICE_PATH_SUBTYPE,
143TestIsDevicePathValid (
176 return UNIT_TEST_PASSED;
192 Type =
DevicePathType (&TestContext->ComplexDevicePath->AcpiPath);
195 Type =
DevicePathType (&TestContext->ComplexDevicePath->PciPathRootPort);
198 return UNIT_TEST_PASSED;
203TestDevicePathSubType (
220 return UNIT_TEST_PASSED;
225TestDevicePathNodeLength (
242 return UNIT_TEST_PASSED;
247TestNextDevicePathNode (
256 Node = &mComplexDevicePath;
263 return UNIT_TEST_PASSED;
268TestIsDevicePathEndType (
283 return UNIT_TEST_PASSED;
297 IsEnd =
IsDevicePathEnd (&TestContext->ComplexDevicePath->PciPathRootPort);
303 return UNIT_TEST_PASSED;
308TestSetDevicePathNodeLength (
320 return UNIT_TEST_PASSED;
325TestSetDevicePathEndNode (
336 return UNIT_TEST_PASSED;
341TestGetDevicePathSize (
356 return UNIT_TEST_PASSED;
361TestDuplicateDevicePath (
375 return UNIT_TEST_PASSED;
380TestAppendDevicePath (
402 return UNIT_TEST_PASSED;
407TestAppendDevicePathNode (
424 EISA_PNP_ID (0x0AAB),
445 return UNIT_TEST_PASSED;
450TestAppendDevicePathInstance (
457 BOOLEAN IsMultiInstance;
464 NextInstance = Appended;
480 return UNIT_TEST_PASSED;
485TestDevicePathFromHandle (
501 return UNIT_TEST_PASSED;
506TestCreateDeviceNode (
517 return UNIT_TEST_PASSED;
528 CONST CHAR16 *TestFilePath = L
"FS0:/Boot/EFI/BootMgr.efi";
537 return UNIT_TEST_PASSED;
552 UNIT_TEST_FRAMEWORK_HANDLE Framework;
553 UNIT_TEST_SUITE_HANDLE DevicePathSimpleTestSuite;
554 UNIT_TEST_SUITE_HANDLE DevicePathAppendTestSuite;
555 UNIT_TEST_SUITE_HANDLE DevicePathFileTestSuite;
558 DEBUG ((DEBUG_INFO,
"%a v%a\n", UNIT_TEST_NAME, UNIT_TEST_VERSION));
561 DevicePathSimpleTestSuite =
NULL;
562 DevicePathAppendTestSuite =
NULL;
563 DevicePathFileTestSuite =
NULL;
566 if (EFI_ERROR (Status)) {
567 DEBUG ((DEBUG_ERROR,
"Failed in InitUnitTestFramework. Status = %r\n", Status));
571 Status =
CreateUnitTestSuite (&DevicePathSimpleTestSuite, Framework,
"Simple device path operations test suite",
"Common.DevicePath.SimpleOps",
NULL,
NULL);
572 if (EFI_ERROR (Status)) {
573 DEBUG ((DEBUG_ERROR,
"Failed to create simple device path test suite\n"));
577 SimpleTestContext.SimpleDevicePath = &mSimpleDevicePath;
578 SimpleTestContext.InvalidDevicePath = &mInvalidSimpleDevicePath;
579 SimpleTestContext.ComplexDevicePath = &mComplexDevicePath;
581 AddTestCase (DevicePathSimpleTestSuite,
"Test IsDevicePathValid",
"TestIsDevicePathValid", TestIsDevicePathValid,
NULL,
NULL, &SimpleTestContext);
582 AddTestCase (DevicePathSimpleTestSuite,
"Test DevicePathType",
"TestDevicePathType", TestDevicePathType,
NULL,
NULL, &SimpleTestContext);
583 AddTestCase (DevicePathSimpleTestSuite,
"Test DevicePathSubType",
"TestDevicePathSubType", TestDevicePathSubType,
NULL,
NULL, &SimpleTestContext);
584 AddTestCase (DevicePathSimpleTestSuite,
"Test DevicePathNodeLength",
"TestDevicePathNodeLength", TestDevicePathNodeLength,
NULL,
NULL, &SimpleTestContext);
585 AddTestCase (DevicePathSimpleTestSuite,
"Test NextDevicePathNode",
"TestNextDevicePathNode", TestNextDevicePathNode,
NULL,
NULL, &SimpleTestContext);
586 AddTestCase (DevicePathSimpleTestSuite,
"Test IsDevicePathEndType",
"TestIsDevicePathEndType", TestIsDevicePathEndType,
NULL,
NULL, &SimpleTestContext);
587 AddTestCase (DevicePathSimpleTestSuite,
"Test IsDevicePathEnd",
"TestIsDevicePathEnd", TestIsDevicePathEnd,
NULL,
NULL, &SimpleTestContext);
588 AddTestCase (DevicePathSimpleTestSuite,
"Test SetDevicePathNodeLength",
"TestSetDevicePathNodeLength", TestSetDevicePathNodeLength,
NULL,
NULL, &SimpleTestContext);
589 AddTestCase (DevicePathSimpleTestSuite,
"Test GetDevicePathSize",
"TestGetDevicePathSize", TestGetDevicePathSize,
NULL,
NULL, &SimpleTestContext);
590 AddTestCase (DevicePathSimpleTestSuite,
"Test CreateDeviceNode",
"TestCreateDeviceNode", TestCreateDeviceNode,
NULL,
NULL, &SimpleTestContext);
591 AddTestCase (DevicePathSimpleTestSuite,
"Test SetDevicePathEndNode",
"TestSetDevicePathEndNode", TestSetDevicePathEndNode,
NULL,
NULL, &SimpleTestContext);
592 AddTestCase (DevicePathAppendTestSuite,
"Test DuplicateDevicePath",
"TestDuplicateDevicePath", TestDuplicateDevicePath,
NULL,
NULL, &SimpleTestContext);
594 Status =
CreateUnitTestSuite (&DevicePathAppendTestSuite, Framework,
"Device path append operations test suite",
"Common.DevicePath.Append",
NULL,
NULL);
595 if (EFI_ERROR (Status)) {
596 DEBUG ((DEBUG_ERROR,
"Failed to create append device path test suite\n"));
600 AddTestCase (DevicePathAppendTestSuite,
"Test AppendDevicePath",
"TestAppendDevicePath", TestAppendDevicePath,
NULL,
NULL,
NULL);
601 AddTestCase (DevicePathAppendTestSuite,
"Test AppendDevicePathNode",
"TestAppendDevicePathNode", TestAppendDevicePathNode,
NULL,
NULL,
NULL);
602 AddTestCase (DevicePathAppendTestSuite,
"Test AppendDevicePathInstance",
"TestAppendDevicePathInstance", TestAppendDevicePathInstance,
NULL,
NULL,
NULL);
604 Status = CreateDevicePathStringConversionsTestSuite (Framework);
605 if (EFI_ERROR (Status)) {
606 DEBUG ((DEBUG_ERROR,
"Failed to create conversions test suite\n"));
610 Status =
CreateUnitTestSuite (&DevicePathFileTestSuite, Framework,
"Device path file operations test suite",
"Common.DevicePath.FileDevPath",
NULL,
NULL);
611 if (EFI_ERROR (Status)) {
612 DEBUG ((DEBUG_ERROR,
"Failed to create device path file test suite\n"));
616 AddTestCase (DevicePathFileTestSuite,
"Test DevicePathFromHandle",
"TestDevicePathFromHandle", TestDevicePathFromHandle,
NULL,
NULL,
NULL);
617 AddTestCase (DevicePathFileTestSuite,
"Test FileDevicePath",
"TestFileDevicePath", TestFileDevicePath,
NULL,
NULL,
NULL);
622 if (Framework !=
NULL) {
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
#define MEDIA_FILEPATH_DP
#define HARDWARE_DEVICE_PATH
#define MESSAGING_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT16 EFIAPI SetDevicePathNodeLength(IN OUT VOID *Node, IN UINTN Length)
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI FileDevicePath(IN EFI_HANDLE Device OPTIONAL, IN CONST CHAR16 *FileName)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathValid(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN MaxSize)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathInstance(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI CreateDeviceNode(IN UINT8 NodeType, IN UINT8 NodeSubType, IN UINT16 NodeLength)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI GetNextDevicePathInstance(IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, OUT UINTN *Size)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DuplicateDevicePath(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
BOOLEAN EFIAPI IsDevicePathEndType(IN CONST VOID *Node)
BOOLEAN EFIAPI IsDevicePathMultiInstance(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
int main()
=== TEST ENGINE ================================================================================
VOID EFIAPI FreePool(IN VOID *Buffer)
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define DEBUG(Expression)
EFI_STATUS EFIAPI UefiTestMain(VOID)
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
#define UT_ASSERT_NOT_NULL(Pointer)
#define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
#define UT_ASSERT_TRUE(Expression)
#define UT_ASSERT_EQUAL(ValueA, ValueB)
EFI_STATUS EFIAPI CreateUnitTestSuite(OUT UNIT_TEST_SUITE_HANDLE *SuiteHandle, IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *Name, IN UNIT_TEST_SUITE_SETUP Setup OPTIONAL, IN UNIT_TEST_SUITE_TEARDOWN Teardown OPTIONAL)
EFI_STATUS EFIAPI FreeUnitTestFramework(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
EFI_STATUS EFIAPI AddTestCase(IN UNIT_TEST_SUITE_HANDLE SuiteHandle, IN CHAR8 *Description, IN CHAR8 *Name, IN UNIT_TEST_FUNCTION Function, IN UNIT_TEST_PREREQUISITE Prerequisite OPTIONAL, IN UNIT_TEST_CLEANUP CleanUp OPTIONAL, IN UNIT_TEST_CONTEXT Context OPTIONAL)
EFI_STATUS EFIAPI InitUnitTestFramework(OUT UNIT_TEST_FRAMEWORK_HANDLE *FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *ShortTitle, IN CHAR8 *VersionString)
#define UT_ASSERT_FALSE(Expression)