TianoCore EDK2 master
Loading...
Searching...
No Matches
TestDevicePathLib.c
Go to the documentation of this file.
1
8#include "TestDevicePathLib.h"
9
10#define UNIT_TEST_NAME "DevicePathLib Unit Test Application"
11#define UNIT_TEST_VERSION "0.1"
12
13typedef struct {
14 ACPI_HID_DEVICE_PATH AcpiPath;
15 PCI_DEVICE_PATH PciPathRootPort;
16 PCI_DEVICE_PATH PciPathEndPoint;
17 USB_DEVICE_PATH UsbPath;
20
22 { // ACPI device path with root bridge EISA_PNP_ID
23 {
25 ACPI_DP,
26 {
27 (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
28 (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
29 }
30 },
31 EISA_PNP_ID (0x0A03),
32 0
33 },
34 { // PCI device path - root port (0x2:0x0)
35 {
38 {
39 (UINT8)(sizeof (PCI_DEVICE_PATH)),
40 (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8)
41 }
42 },
43 0x2,
44 0x0
45 },
46 { // PCI device path - endpoint (0x0:0x0)
47 {
50 {
51 (UINT8)(sizeof (PCI_DEVICE_PATH)),
52 (UINT8)((sizeof (PCI_DEVICE_PATH)) >> 8)
53 }
54 },
55 0x0,
56 0x0
57 },
58 { // USB interface
59 {
62 {
63 (UINT8)(sizeof (USB_DEVICE_PATH)),
64 (UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
65 }
66 },
67 0,
68 2
69 },
70 {
71 END_DEVICE_PATH_TYPE,
72 END_ENTIRE_DEVICE_PATH_SUBTYPE,
73 {
74 (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
75 (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
76 }
77 }
78};
79
80CONST GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mComplexDevicePathString = L"PciRoot(0x0)/Pci(0x0,0x2)/Pci(0x0,0x0)/USB(0x0,0x2)";
81
82CONST GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mPciEndPointPathString = L"Pci(0x0, 0x0)";
83
84typedef struct {
85 ACPI_HID_DEVICE_PATH AcpiPath;
88
90 { // ACPI device path with root bridge EISA_PNP_ID
91 {
93 ACPI_DP,
94 {
95 (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
96 (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
97 }
98 },
99 EISA_PNP_ID (0x0A03),
100 0
101 },
102 {
103 END_DEVICE_PATH_TYPE,
104 END_ENTIRE_DEVICE_PATH_SUBTYPE,
105 {
106 (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
107 (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
108 }
109 }
110};
111
113 { // ACPI device path with root bridge EISA_PNP_ID
114 {
116 ACPI_DP,
117 {
118 0,
119 0
120 }
121 },
122 EISA_PNP_ID (0x0A03),
123 0
124 },
125 {
126 END_DEVICE_PATH_TYPE,
127 END_ENTIRE_DEVICE_PATH_SUBTYPE,
128 {
129 (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
130 (UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
131 }
132 }
133};
134
135typedef struct {
136 TEST_SIMPLE_DEVICE_PATH *SimpleDevicePath;
137 TEST_SIMPLE_DEVICE_PATH *InvalidDevicePath;
138 TEST_COMPLEX_DEVICE_PATH *ComplexDevicePath;
140
142EFIAPI
143TestIsDevicePathValid (
144 IN UNIT_TEST_CONTEXT Context
145 )
146{
147 BOOLEAN IsValid;
148 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
149
150 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
151
152 IsValid = IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->SimpleDevicePath, sizeof (TEST_SIMPLE_DEVICE_PATH));
153 UT_ASSERT_TRUE (IsValid);
154
155 IsValid = IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->ComplexDevicePath, sizeof (TEST_COMPLEX_DEVICE_PATH));
156 UT_ASSERT_TRUE (IsValid);
157
158 IsValid = IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->ComplexDevicePath, 0);
159 UT_ASSERT_TRUE (IsValid);
160
161 // Device path can't be NULL
162 IsValid = IsDevicePathValid (NULL, 0);
163 UT_ASSERT_FALSE (IsValid);
164
165 // MaxSize can't be less then the size of the device path
166 IsValid = IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->SimpleDevicePath, sizeof (TEST_SIMPLE_DEVICE_PATH) - 1);
167 UT_ASSERT_FALSE (IsValid);
168
169 // If MaxSize != 0 it must be bigger then EFI_DEVICE_PATH_PROTOCOL
170 IsValid = IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->SimpleDevicePath, sizeof (EFI_DEVICE_PATH_PROTOCOL) - 1);
171 UT_ASSERT_FALSE (IsValid);
172
173 IsValid = IsDevicePathValid ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->InvalidDevicePath, 0);
174 UT_ASSERT_FALSE (IsValid);
175
176 return UNIT_TEST_PASSED;
177}
178
180EFIAPI
181TestDevicePathType (
182 IN UNIT_TEST_CONTEXT Context
183 )
184{
185 UINT8 Type;
186 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
187
188 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
189
190 // Test 2 types just in case the implementation is returning constant value
191 // NOTE: passing NULL to this function causes NULL pointer dereference.
192 Type = DevicePathType (&TestContext->ComplexDevicePath->AcpiPath);
194
195 Type = DevicePathType (&TestContext->ComplexDevicePath->PciPathRootPort);
197
198 return UNIT_TEST_PASSED;
199}
200
202EFIAPI
203TestDevicePathSubType (
204 IN UNIT_TEST_CONTEXT Context
205 )
206{
207 UINT8 SubType;
208 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
209
210 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
211
212 // Test 2 sub types just in case the implementation is returning constant value
213 // NOTE: passing NULL to this function causes NULL pointer dereference.
214 SubType = DevicePathSubType (&TestContext->ComplexDevicePath->AcpiPath);
215 UT_ASSERT_EQUAL (SubType, ACPI_DP);
216
217 SubType = DevicePathSubType (&TestContext->ComplexDevicePath->PciPathRootPort);
218 UT_ASSERT_EQUAL (SubType, HW_PCI_DP);
219
220 return UNIT_TEST_PASSED;
221}
222
224EFIAPI
225TestDevicePathNodeLength (
226 IN UNIT_TEST_CONTEXT Context
227 )
228{
229 UINTN Length;
230 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
231
232 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
233
234 // Test 2 nodes just in case the implementation is returning constant value
235 // NOTE: passing NULL to this function causes NULL pointer dereference.
236 Length = DevicePathNodeLength (&TestContext->ComplexDevicePath->AcpiPath);
237 UT_ASSERT_EQUAL (Length, sizeof (ACPI_HID_DEVICE_PATH));
238
239 Length = DevicePathNodeLength (&TestContext->ComplexDevicePath->PciPathRootPort);
240 UT_ASSERT_EQUAL (Length, sizeof (PCI_DEVICE_PATH));
241
242 return UNIT_TEST_PASSED;
243}
244
246EFIAPI
247TestNextDevicePathNode (
248 IN UNIT_TEST_CONTEXT Context
249 )
250{
251 VOID *Node;
252 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
253
254 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
255
256 Node = &mComplexDevicePath;
257 Node = NextDevicePathNode (Node);
258 UT_ASSERT_MEM_EQUAL (Node, &TestContext->ComplexDevicePath->PciPathRootPort, DevicePathNodeLength (Node));
259
260 Node = NextDevicePathNode (Node);
261 UT_ASSERT_MEM_EQUAL (Node, &TestContext->ComplexDevicePath->PciPathEndPoint, DevicePathNodeLength (Node));
262
263 return UNIT_TEST_PASSED;
264}
265
267EFIAPI
268TestIsDevicePathEndType (
269 IN UNIT_TEST_CONTEXT Context
270 )
271{
272 BOOLEAN IsEndType;
273 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
274
275 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
276
277 IsEndType = IsDevicePathEndType (&TestContext->ComplexDevicePath->PciPathRootPort);
278 UT_ASSERT_FALSE (IsEndType);
279
280 IsEndType = IsDevicePathEndType (&TestContext->ComplexDevicePath->End);
281 UT_ASSERT_TRUE (IsEndType);
282
283 return UNIT_TEST_PASSED;
284}
285
287EFIAPI
288TestIsDevicePathEnd (
289 IN UNIT_TEST_CONTEXT Context
290 )
291{
292 BOOLEAN IsEnd;
293 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
294
295 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
296
297 IsEnd = IsDevicePathEnd (&TestContext->ComplexDevicePath->PciPathRootPort);
298 UT_ASSERT_FALSE (IsEnd);
299
300 IsEnd = IsDevicePathEnd (&TestContext->ComplexDevicePath->End);
301 UT_ASSERT_TRUE (IsEnd);
302
303 return UNIT_TEST_PASSED;
304}
305
307EFIAPI
308TestSetDevicePathNodeLength (
309 IN UNIT_TEST_CONTEXT Context
310 )
311{
313
314 // NOTE: Node == NULL or NodeLength >= 0x10000 NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)
315 // are all invalid parameters. However there are only ASSERTS added to catch them so there is no
316 // way to test it.
319
320 return UNIT_TEST_PASSED;
321}
322
324EFIAPI
325TestSetDevicePathEndNode (
326 IN UNIT_TEST_CONTEXT Context
327 )
328{
330
331 SetDevicePathEndNode (&EndNode);
332 UT_ASSERT_EQUAL (EndNode.Type, END_DEVICE_PATH_TYPE);
333 UT_ASSERT_EQUAL (EndNode.SubType, END_ENTIRE_DEVICE_PATH_SUBTYPE);
334 UT_ASSERT_EQUAL (DevicePathNodeLength (&EndNode), END_DEVICE_PATH_LENGTH);
335
336 return UNIT_TEST_PASSED;
337}
338
340EFIAPI
341TestGetDevicePathSize (
342 IN UNIT_TEST_CONTEXT Context
343 )
344{
345 UINTN Size;
346 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
347
348 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
349
350 Size = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->SimpleDevicePath);
352
353 Size = GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->ComplexDevicePath);
355
356 return UNIT_TEST_PASSED;
357}
358
360EFIAPI
361TestDuplicateDevicePath (
362 IN UNIT_TEST_CONTEXT Context
363 )
364{
365 EFI_DEVICE_PATH_PROTOCOL *Duplicate;
366 SIMPLE_TEST_SUITE_CONTEXT *TestContext;
367
368 TestContext = (SIMPLE_TEST_SUITE_CONTEXT *)Context;
369
370 Duplicate = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->ComplexDevicePath);
371 UT_ASSERT_EQUAL (GetDevicePathSize (Duplicate), GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->ComplexDevicePath));
372 UT_ASSERT_MEM_EQUAL (Duplicate, TestContext->ComplexDevicePath, GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *)TestContext->ComplexDevicePath));
373 FreePool (Duplicate);
374
375 return UNIT_TEST_PASSED;
376}
377
379EFIAPI
380TestAppendDevicePath (
381 IN UNIT_TEST_CONTEXT Context
382 )
383{
384 EFI_DEVICE_PATH_PROTOCOL *Appended;
385 EFI_DEVICE_PATH_PROTOCOL *NextNode;
386
387 Appended = AppendDevicePath ((EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&mComplexDevicePath);
388 NextNode = NextDevicePathNode (Appended);
389 UT_ASSERT_MEM_EQUAL (NextNode, &mSimpleDevicePath.AcpiPath, sizeof (ACPI_HID_DEVICE_PATH));
390 FreePool (Appended);
391
392 // If one of the paths is invalid result device path should be NULL
393 Appended = AppendDevicePath ((EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&mInvalidSimpleDevicePath);
394 UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL);
395
396 Appended = AppendDevicePath (NULL, NULL);
397 UT_ASSERT_EQUAL (Appended->Type, END_DEVICE_PATH_TYPE);
398 UT_ASSERT_EQUAL (Appended->SubType, END_ENTIRE_DEVICE_PATH_SUBTYPE);
399 UT_ASSERT_EQUAL (DevicePathNodeLength (Appended), END_DEVICE_PATH_LENGTH);
400 FreePool (Appended);
401
402 return UNIT_TEST_PASSED;
403}
404
406EFIAPI
407TestAppendDevicePathNode (
408 IN UNIT_TEST_CONTEXT Context
409 )
410{
411 EFI_DEVICE_PATH_PROTOCOL *Appended;
412 EFI_DEVICE_PATH_PROTOCOL *NextNode;
413 BOOLEAN IsValid;
414 ACPI_HID_DEVICE_PATH AcpiPath =
415 {
416 {
418 ACPI_DP,
419 {
420 (UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
421 (UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
422 }
423 },
424 EISA_PNP_ID (0x0AAB),
425 0
426 };
427
428 Appended = AppendDevicePathNode ((EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&AcpiPath);
429 NextNode = NextDevicePathNode (Appended);
430 UT_ASSERT_MEM_EQUAL (NextNode, &AcpiPath, sizeof (ACPI_HID_DEVICE_PATH));
431 FreePool (Appended);
432
433 Appended = AppendDevicePathNode (NULL, (EFI_DEVICE_PATH_PROTOCOL *)&AcpiPath);
434 UT_ASSERT_MEM_EQUAL (Appended, &AcpiPath, sizeof (ACPI_HID_DEVICE_PATH));
435 IsValid = IsDevicePathValid (Appended, 0);
436 UT_ASSERT_TRUE (IsValid);
437 FreePool (Appended);
438
439 Appended = AppendDevicePathNode (NULL, NULL);
440 UT_ASSERT_EQUAL (Appended->Type, END_DEVICE_PATH_TYPE);
441 UT_ASSERT_EQUAL (Appended->SubType, END_ENTIRE_DEVICE_PATH_SUBTYPE);
442 UT_ASSERT_EQUAL (DevicePathNodeLength (Appended), END_DEVICE_PATH_LENGTH);
443 FreePool (Appended);
444
445 return UNIT_TEST_PASSED;
446}
447
449EFIAPI
450TestAppendDevicePathInstance (
451 IN UNIT_TEST_CONTEXT Context
452 )
453{
454 EFI_DEVICE_PATH_PROTOCOL *Appended;
455 EFI_DEVICE_PATH_PROTOCOL *NextInstance;
456 EFI_DEVICE_PATH_PROTOCOL *NextInstanceRet;
457 BOOLEAN IsMultiInstance;
458 UINTN Size;
459
460 Appended = AppendDevicePathInstance ((EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&mComplexDevicePath);
461 IsMultiInstance = IsDevicePathMultiInstance (Appended);
462 UT_ASSERT_TRUE (IsMultiInstance);
463 UT_ASSERT_MEM_EQUAL (Appended, &mSimpleDevicePath, sizeof (ACPI_DEVICE_PATH));
464 NextInstance = Appended;
465 NextInstanceRet = GetNextDevicePathInstance (&NextInstance, &Size);
466 UT_ASSERT_MEM_EQUAL (NextInstance, &mComplexDevicePath, Size);
467 FreePool (Appended);
468 FreePool (NextInstanceRet);
469
470 Appended = AppendDevicePathInstance (NULL, (EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath);
471 UT_ASSERT_MEM_EQUAL (Appended, &mSimpleDevicePath, sizeof (TEST_SIMPLE_DEVICE_PATH));
472 FreePool (Appended);
473
474 Appended = AppendDevicePathInstance (NULL, NULL);
475 UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL);
476
477 Appended = AppendDevicePathInstance ((EFI_DEVICE_PATH_PROTOCOL *)&mSimpleDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&mInvalidSimpleDevicePath);
478 UT_ASSERT_EQUAL ((uintptr_t)Appended, (uintptr_t)NULL);
479
480 return UNIT_TEST_PASSED;
481}
482
484EFIAPI
485TestDevicePathFromHandle (
486 IN UNIT_TEST_CONTEXT Context
487 )
488{
489 EFI_HANDLE Handle;
490 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
491 UINTN FakeHandle;
492
493 Handle = NULL;
494 DevicePath = DevicePathFromHandle (Handle);
495 UT_ASSERT_EQUAL ((uintptr_t)DevicePath, (uintptr_t)NULL);
496
497 Handle = (EFI_HANDLE)&FakeHandle;
498 DevicePath = DevicePathFromHandle (Handle);
499 UT_ASSERT_EQUAL ((uintptr_t)DevicePath, (uintptr_t)NULL);
500
501 return UNIT_TEST_PASSED;
502}
503
505EFIAPI
506TestCreateDeviceNode (
507 IN UNIT_TEST_CONTEXT Context
508 )
509{
511
516
517 return UNIT_TEST_PASSED;
518}
519
521EFIAPI
522TestFileDevicePath (
523 IN UNIT_TEST_CONTEXT Context
524 )
525{
526 EFI_HANDLE Handle;
527 FILEPATH_DEVICE_PATH *DevicePath;
528 CONST CHAR16 *TestFilePath = L"FS0:/Boot/EFI/BootMgr.efi";
529
530 Handle = NULL;
531 DevicePath = (FILEPATH_DEVICE_PATH *)FileDevicePath (Handle, TestFilePath);
532 UT_ASSERT_NOT_NULL (DevicePath);
533 UT_ASSERT_EQUAL (DevicePath->Header.Type, MEDIA_DEVICE_PATH);
534 UT_ASSERT_EQUAL (DevicePath->Header.Type, MEDIA_FILEPATH_DP);
535 UT_ASSERT_MEM_EQUAL (DevicePath->PathName, TestFilePath, StrSize (TestFilePath));
536
537 return UNIT_TEST_PASSED;
538}
539
546EFIAPI
548 VOID
549 )
550{
551 EFI_STATUS Status;
552 UNIT_TEST_FRAMEWORK_HANDLE Framework;
553 UNIT_TEST_SUITE_HANDLE DevicePathSimpleTestSuite;
554 UNIT_TEST_SUITE_HANDLE DevicePathAppendTestSuite;
555 UNIT_TEST_SUITE_HANDLE DevicePathFileTestSuite;
556 SIMPLE_TEST_SUITE_CONTEXT SimpleTestContext;
557
558 DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_NAME, UNIT_TEST_VERSION));
559
560 Framework = NULL;
561 DevicePathSimpleTestSuite = NULL;
562 DevicePathAppendTestSuite = NULL;
563 DevicePathFileTestSuite = NULL;
564
565 Status = InitUnitTestFramework (&Framework, UNIT_TEST_NAME, gEfiCallerBaseName, UNIT_TEST_VERSION);
566 if (EFI_ERROR (Status)) {
567 DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
568 goto EXIT;
569 }
570
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"));
574 goto EXIT;
575 }
576
577 SimpleTestContext.SimpleDevicePath = &mSimpleDevicePath;
578 SimpleTestContext.InvalidDevicePath = &mInvalidSimpleDevicePath;
579 SimpleTestContext.ComplexDevicePath = &mComplexDevicePath;
580
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);
593
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"));
597 goto EXIT;
598 }
599
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);
603
604 Status = CreateDevicePathStringConversionsTestSuite (Framework);
605 if (EFI_ERROR (Status)) {
606 DEBUG ((DEBUG_ERROR, "Failed to create conversions test suite\n"));
607 goto EXIT;
608 }
609
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"));
613 goto EXIT;
614 }
615
616 AddTestCase (DevicePathFileTestSuite, "Test DevicePathFromHandle", "TestDevicePathFromHandle", TestDevicePathFromHandle, NULL, NULL, NULL);
617 AddTestCase (DevicePathFileTestSuite, "Test FileDevicePath", "TestFileDevicePath", TestFileDevicePath, NULL, NULL, NULL);
618
619 Status = RunAllTestSuites (Framework);
620
621EXIT:
622 if (Framework != NULL) {
623 FreeUnitTestFramework (Framework);
624 }
625
626 return Status;
627}
628
629int
630main (
631 int argc,
632 char *argv[]
633 )
634{
635 return UefiTestMain ();
636}
UINT64 UINTN
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
#define MEDIA_FILEPATH_DP
Definition: DevicePath.h:1098
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define ACPI_DEVICE_PATH
Definition: DevicePath.h:190
#define MSG_USB_DP
Definition: DevicePath.h:418
#define ACPI_DP
Definition: DevicePath.h:195
#define HW_PCI_DP
Definition: DevicePath.h:73
#define MESSAGING_DEVICE_PATH
Definition: DevicePath.h:321
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 NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define GLOBAL_REMOVE_IF_UNREFERENCED
Definition: Base.h:48
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS EFIAPI UefiTestMain(VOID)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
Definition: RunTests.c:145
#define UT_ASSERT_NOT_NULL(Pointer)
Definition: UnitTestLib.h:439
VOID * UNIT_TEST_CONTEXT
Definition: UnitTestLib.h:54
#define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
Definition: UnitTestLib.h:389
#define UT_ASSERT_TRUE(Expression)
Definition: UnitTestLib.h:350
#define UT_ASSERT_EQUAL(ValueA, ValueB)
Definition: UnitTestLib.h:375
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)
Definition: UnitTestLib.c:326
EFI_STATUS EFIAPI FreeUnitTestFramework(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
Definition: UnitTestLib.c:150
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)
Definition: UnitTestLib.c:426
EFI_STATUS EFIAPI InitUnitTestFramework(OUT UNIT_TEST_FRAMEWORK_HANDLE *FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *ShortTitle, IN CHAR8 *VersionString)
Definition: UnitTestLib.c:204
UINT32 UNIT_TEST_STATUS
Definition: UnitTestLib.h:16
#define UT_ASSERT_FALSE(Expression)
Definition: UnitTestLib.h:362