TianoCore EDK2 master
Loading...
Searching...
No Matches
DxePrmContextBufferLibUnitTest.c
Go to the documentation of this file.
1
10#include <stdio.h>
11#include <string.h>
12#include <stdarg.h>
13#include <stddef.h>
14#include <setjmp.h>
15#include <cmocka.h>
16
17#include <Uefi.h>
18
19#include <Guid/ZeroGuid.h>
20#include <Library/BaseLib.h>
22#include <Library/DebugLib.h>
24#include <Library/PrintLib.h>
27#include <Library/UnitTestLib.h>
28#include <Protocol/PrmConfig.h>
29
30#define UNIT_TEST_NAME "PRM Context Buffer Library Unit Test"
31#define UNIT_TEST_VERSION "0.1"
32
34
36
37// *----------------------------------------------------------------------------------*
38// * Context Structures *
39// *----------------------------------------------------------------------------------*
40typedef struct {
41 PRM_MODULE_CONTEXT_BUFFERS *InstallationStructure;
42 EFI_HANDLE Handle;
43 PRM_GUID_SEARCH_TYPE GuidSearchType;
44 EFI_GUID *Guid;
45 EFI_GUID *ExpectedModuleGuid;
46 EFI_STATUS ExpectedStatus;
48
49typedef struct {
50 EFI_GUID *HandlerGuid;
51 PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
52 PRM_CONTEXT_BUFFER *ExpectedContextBuffer;
53 EFI_STATUS ExpectedStatus;
55
56// *----------------------------------------------------------------------------------*
57// * Test GUIDs *
58// *----------------------------------------------------------------------------------*
59
60// {52960b90-2f3a-4917-b91a-ed5f599a8809}
61#define HANDLER_TEST_GUID_1 {0x52960b90, 0x2f3a, 0x4917, { 0xb9, 0x1a, 0xed, 0x5f, 0x59, 0x9a, 0x88, 0x09 }}
62EFI_GUID mHandlerTestGuid1 = HANDLER_TEST_GUID_1;
63
64// {9316a80d-06dc-417b-b21d-6b3c2ae4ed6f}
65#define HANDLER_TEST_GUID_2 {0x9316a80d, 0x06dc, 0x417b, { 0xb2, 0x1d, 0x6b, 0x3c, 0x2a, 0xe4, 0xed, 0x6f }}
66EFI_GUID mHandlerTestGuid2 = HANDLER_TEST_GUID_2;
67
68// {d32ac8ba-6cc6-456f-9ed9-9233fa310434}
69#define HANDLER_TEST_GUID_3 {0xd32ac8ba, 0x6cc6, 0x456f, { 0x9e, 0xd9, 0x92, 0x33, 0xfa, 0x31, 0x04, 0x34 }}
70EFI_GUID mHandlerTestGuid3 = HANDLER_TEST_GUID_3;
71
72// {faadaa95-070b-4a34-a919-18305dc07370}
73#define MODULE_TEST_GUID_1 {0xfaadaa95, 0x070b, 0x4a34, { 0xa9, 0x19, 0x18, 0x30, 0x5d, 0xc0, 0x73, 0x70 }}
74EFI_GUID mModuleTestGuid1 = MODULE_TEST_GUID_1;
75
76// {0ea24584-731c-4863-9100-75780af509a7}
77#define MODULE_TEST_GUID_2 {0x0ea24584, 0x731c, 0x4863, { 0x91, 0x00, 0x75, 0x78, 0x0a, 0xf5, 0x09, 0xa7 }}
78EFI_GUID mModuleTestGuid2 = MODULE_TEST_GUID_2;
79
80// {f456b7a1-82a6-4427-8486-87e3a602df43}
81#define MODULE_TEST_GUID_3 {0xf456b7a1, 0x82a6, 0x4427, { 0x84, 0x86, 0x87, 0xe3, 0xa6, 0x02, 0xdf, 0x43 }}
82EFI_GUID mModuleTestGuid3 = MODULE_TEST_GUID_3;
83
84// {4a941a9c-9dcf-471b-94b5-d9e2d8c64a1b}
85#define NEGATIVE_TEST_GUID {0x4a941a9c, 0x9dcf, 0x471b, {0x94, 0xb5, 0xd9, 0xe2, 0xd8, 0xc6, 0x4a, 0x1b }}
86EFI_GUID mNegativeTestGuid = NEGATIVE_TEST_GUID;
87
88// *----------------------------------------------------------------------------------*
89// * PRM Static Test Structures *
90// *----------------------------------------------------------------------------------*
91
92PRM_DATA_BUFFER mTestStaticDataBuffer1 = {
93 {
94 PRM_DATA_BUFFER_HEADER_SIGNATURE,
95 sizeof (PRM_DATA_BUFFER)
96 }
97 // No data in the buffer (only a header)
98};
99
100PRM_CONTEXT_BUFFER mTestPrmContextBuffer1 = {
101 PRM_CONTEXT_BUFFER_SIGNATURE, // Signature
102 PRM_CONTEXT_BUFFER_INTERFACE_VERSION, // Version
103 0, // Reserved
104 HANDLER_TEST_GUID_1, // HandlerGuid
105 &mTestStaticDataBuffer1 // StaticDataBuffer
106};
107
108PRM_CONTEXT_BUFFER mTestPrmContextBuffer2[2] = {
109 // Context buffer #1
110 {
111 PRM_CONTEXT_BUFFER_SIGNATURE, // Signature
112 PRM_CONTEXT_BUFFER_INTERFACE_VERSION, // Version
113 0, // Reserved
114 HANDLER_TEST_GUID_2, // HandlerGuid
115 NULL // StaticDataBuffer
116 },
117 // Context buffer #2
118 {
119 PRM_CONTEXT_BUFFER_SIGNATURE, // Signature
120 PRM_CONTEXT_BUFFER_INTERFACE_VERSION, // Version
121 0, // Reserved
122 HANDLER_TEST_GUID_3, // HandlerGuid
123 &mTestStaticDataBuffer1 // StaticDataBuffer (reuse buffer StaticDataBuffer1)
124 }
125};
126
127PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers1 = {
128 MODULE_TEST_GUID_1,
129 1,
130 &mTestPrmContextBuffer1,
131 NULL
132};
133
134PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers2 = {
135 MODULE_TEST_GUID_2,
136 1,
137 &mTestPrmContextBuffer1,
138 NULL
139};
140
141PRM_MODULE_CONTEXT_BUFFERS mTestPrmModuleContextBuffers3 = {
142 MODULE_TEST_GUID_3,
143 2,
144 &mTestPrmContextBuffer2[0],
145 NULL
146};
147
148// *----------------------------------------------------------------------------------*
149// * Test Contexts *
150// *----------------------------------------------------------------------------------*
151
152// * Searches by module GUID *
153// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
154// + InstallationStructure | Handle | GuidSearchType | Guid | ExpectedModuleGuid | ExpectedStatus |
155// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
156PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers00 = { &mTestPrmModuleContextBuffers1, NULL, ByModuleGuid, &mModuleTestGuid1, &mModuleTestGuid1, EFI_SUCCESS };
157PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers01 = { &mTestPrmModuleContextBuffers2, NULL, ByModuleGuid, &mModuleTestGuid2, &mModuleTestGuid2, EFI_SUCCESS };
158PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers02 = { &mTestPrmModuleContextBuffers3, NULL, ByModuleGuid, &mModuleTestGuid3, &mModuleTestGuid3, EFI_SUCCESS };
159PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers03 = { &mTestPrmModuleContextBuffers3, NULL, ByModuleGuid, &mNegativeTestGuid, &gZeroGuid, EFI_NOT_FOUND };
160PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers04 = { &mTestPrmModuleContextBuffers1, NULL, ByModuleGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
161
162// * Searches by handler GUID *
163// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
164// + InstallationStructure | Handle | GuidSearchType | Guid | ExpectedModuleGuid | ExpectedStatus |
165// +--------------------------------+--------+----------------+--------------------+--------------------+--------------------+
166PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers05 = { &mTestPrmModuleContextBuffers1, NULL, ByHandlerGuid, &mHandlerTestGuid1, &mModuleTestGuid1, EFI_SUCCESS };
167PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers06 = { &mTestPrmModuleContextBuffers1, NULL, ByHandlerGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
168PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers07 = { &mTestPrmModuleContextBuffers2, NULL, ByHandlerGuid, &mHandlerTestGuid1, &mModuleTestGuid2, EFI_SUCCESS };
169PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers08 = { &mTestPrmModuleContextBuffers2, NULL, ByHandlerGuid, &mNegativeTestGuid, &gZeroGuid, EFI_NOT_FOUND };
170PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers09 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid1, &gZeroGuid, EFI_NOT_FOUND };
171PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers10 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid2, &mModuleTestGuid3, EFI_SUCCESS };
172PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers11 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &mHandlerTestGuid3, &mModuleTestGuid3, EFI_SUCCESS };
173PRM_CONTEXT_BUFFERS_TEST_CONTEXT mContextBuffers12 = { &mTestPrmModuleContextBuffers3, NULL, ByHandlerGuid, &gZeroGuid, &gZeroGuid, EFI_NOT_FOUND };
174
175PRM_CONTEXT_BUFFERS_TEST_CONTEXT *mContextBuffersArray[] = {
176 &mContextBuffers00,
177 &mContextBuffers01,
178 &mContextBuffers02,
179 &mContextBuffers03,
180 &mContextBuffers04,
181 &mContextBuffers05,
182 &mContextBuffers06,
183 &mContextBuffers07,
184 &mContextBuffers08,
185 &mContextBuffers09,
186 &mContextBuffers10,
187 &mContextBuffers11,
188 &mContextBuffers12
189};
190
191// +----------------------+----------------------------------+------------------------------------------+--------------------+
192// + HandlerGuid | ContextBuffers | ExpectedContextBuffer | ExpectedStatus |
193// +----------------------+----------------------------------+------------------------------------------+--------------------+
194PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer00 = { &mHandlerTestGuid1, &mTestPrmModuleContextBuffers1, &mTestPrmContextBuffer1, EFI_SUCCESS };
195PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer01 = { &mHandlerTestGuid1, &mTestPrmModuleContextBuffers2, &mTestPrmContextBuffer1, EFI_SUCCESS };
196PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer02 = { &mHandlerTestGuid2, &mTestPrmModuleContextBuffers3, &mTestPrmContextBuffer2[0], EFI_SUCCESS };
197PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer03 = { &mHandlerTestGuid3, &mTestPrmModuleContextBuffers3, &mTestPrmContextBuffer2[1], EFI_SUCCESS };
198PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer04 = { &mNegativeTestGuid, &mTestPrmModuleContextBuffers1, NULL, EFI_NOT_FOUND };
199PRM_CONTEXT_BUFFER_TEST_CONTEXT mContextBuffer05 = { &gZeroGuid, &mTestPrmModuleContextBuffers3, NULL, EFI_NOT_FOUND };
200
201PRM_CONTEXT_BUFFER_TEST_CONTEXT *mContextBufferArray[] = {
202 &mContextBuffer00,
203 &mContextBuffer01,
204 &mContextBuffer02,
205 &mContextBuffer03,
206 &mContextBuffer04,
207 &mContextBuffer05
208};
209
211
212// None
213
215
217
229EFIAPI
231 IN UNIT_TEST_CONTEXT Context
232 )
233{
234 EFI_GUID Guid;
235 PRM_CONTEXT_BUFFER *ContextBufferPtr;
236 PRM_MODULE_CONTEXT_BUFFERS ModuleContextBuffers;
237 PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffersPtr;
238
240 UT_ASSERT_EQUAL (FindContextBufferInModuleBuffers (NULL, &ModuleContextBuffers, (CONST PRM_CONTEXT_BUFFER **)&ContextBufferPtr), EFI_INVALID_PARAMETER);
241 UT_ASSERT_EQUAL (FindContextBufferInModuleBuffers (&Guid, NULL, (CONST PRM_CONTEXT_BUFFER **)&ContextBufferPtr), EFI_INVALID_PARAMETER);
242 UT_ASSERT_EQUAL (FindContextBufferInModuleBuffers (&Guid, &ModuleContextBuffers, NULL), EFI_INVALID_PARAMETER);
243
244 UT_ASSERT_EQUAL (GetModuleContextBuffers (ByModuleGuid, NULL, NULL), EFI_INVALID_PARAMETER);
245 UT_ASSERT_EQUAL (GetModuleContextBuffers (ByModuleGuid, NULL, (CONST PRM_MODULE_CONTEXT_BUFFERS **)&ModuleContextBuffersPtr), EFI_INVALID_PARAMETER);
246 UT_ASSERT_EQUAL (GetModuleContextBuffers (ByModuleGuid, &Guid, NULL), EFI_INVALID_PARAMETER);
247
248 UT_ASSERT_EQUAL (GetContextBuffer (NULL, NULL, NULL), EFI_INVALID_PARAMETER);
249 UT_ASSERT_EQUAL (GetContextBuffer (NULL, &ModuleContextBuffers, (CONST PRM_CONTEXT_BUFFER **)&ContextBufferPtr), EFI_INVALID_PARAMETER);
250 UT_ASSERT_EQUAL (GetContextBuffer (&Guid, NULL, (CONST PRM_CONTEXT_BUFFER **)&ContextBufferPtr), EFI_NOT_FOUND);
251 UT_ASSERT_EQUAL (GetContextBuffer (&Guid, &ModuleContextBuffers, NULL), EFI_INVALID_PARAMETER);
252
253 return UNIT_TEST_PASSED;
254}
255
257
273STATIC
275EFIAPI
277 IN UNIT_TEST_CONTEXT Context
278 )
279{
280 EFI_STATUS Status;
281 PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
282 PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffers;
284
285 UT_ASSERT_NOT_NULL (Context);
286 TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
287 ModuleContextBuffers = TestContext->InstallationStructure;
288
289 PrmConfigProtocol = AllocateZeroPool (sizeof (*PrmConfigProtocol));
290 if (PrmConfigProtocol == NULL) {
291 return UNIT_TEST_ERROR_PREREQUISITE_NOT_MET;
292 }
293
294 CopyGuid (&PrmConfigProtocol->ModuleContextBuffers.ModuleGuid, &ModuleContextBuffers->ModuleGuid);
295 PrmConfigProtocol->ModuleContextBuffers.BufferCount = ModuleContextBuffers->BufferCount;
296 PrmConfigProtocol->ModuleContextBuffers.Buffer = ModuleContextBuffers->Buffer;
297
298 Status = gBS->InstallProtocolInterface (
299 &TestContext->Handle,
300 &gPrmConfigProtocolGuid,
302 (VOID *)PrmConfigProtocol
303 );
305
306 return UNIT_TEST_PASSED;
307}
308
324STATIC
325VOID
326EFIAPI
328 IN UNIT_TEST_CONTEXT Context
329 )
330{
331 EFI_STATUS Status;
332 PRM_CONFIG_PROTOCOL *PrmConfigProtocol;
334
335 TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
336
337 Status = gBS->HandleProtocol (
338 TestContext->Handle,
339 &gPrmConfigProtocolGuid,
340 (VOID **)&PrmConfigProtocol
341 );
342
343 if (!EFI_ERROR (Status)) {
344 Status = gBS->UninstallProtocolInterface (
345 TestContext->Handle,
346 &gPrmConfigProtocolGuid,
347 PrmConfigProtocol
348 );
349 if (!EFI_ERROR (Status)) {
350 FreePool (PrmConfigProtocol);
351 }
352 }
353}
354
368EFIAPI
370 IN UNIT_TEST_CONTEXT Context
371 )
372{
373 EFI_STATUS Status;
374 PRM_MODULE_CONTEXT_BUFFERS *ContextBuffers;
376
377 ContextBuffers = NULL;
378 TestContext = (PRM_CONTEXT_BUFFERS_TEST_CONTEXT *)Context;
379
380 Status = GetModuleContextBuffers (TestContext->GuidSearchType, TestContext->Guid, (CONST PRM_MODULE_CONTEXT_BUFFERS **)&ContextBuffers);
381 UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
382
383 if (!EFI_ERROR (TestContext->ExpectedStatus)) {
384 UT_ASSERT_TRUE (CompareGuid (TestContext->ExpectedModuleGuid, &ContextBuffers->ModuleGuid));
386 "%a: Searching by %a GUID ({%g}) returned ContextBuffers at 0x%x\n",
387 __func__,
388 ((TestContext->GuidSearchType == ByModuleGuid) ? "module" : "handler"),
389 TestContext->Guid,
390 (UINTN)ContextBuffers
391 );
392 }
393
394 return UNIT_TEST_PASSED;
395}
396
410EFIAPI
412 IN UNIT_TEST_CONTEXT Context
413 )
414{
415 EFI_STATUS Status;
416 PRM_CONTEXT_BUFFER *FoundContextBuffer;
418
419 FoundContextBuffer = NULL;
420 TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *)Context;
421
422 Status = FindContextBufferInModuleBuffers (TestContext->HandlerGuid, TestContext->ContextBuffers, (CONST PRM_CONTEXT_BUFFER **)&FoundContextBuffer);
423 UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
424
425 if (!EFI_ERROR (TestContext->ExpectedStatus)) {
426 UT_ASSERT_NOT_NULL (FoundContextBuffer);
427 UT_ASSERT_TRUE (FoundContextBuffer == TestContext->ExpectedContextBuffer);
428 }
429
430 return UNIT_TEST_PASSED;
431}
432
454EFIAPI
456 IN UNIT_TEST_CONTEXT Context
457 )
458{
459 EFI_STATUS Status;
460 PRM_CONTEXT_BUFFER *FoundContextBuffer;
462
463 FoundContextBuffer = NULL;
464 TestContext = (PRM_CONTEXT_BUFFER_TEST_CONTEXT *)Context;
465
466 Status = GetContextBuffer (TestContext->HandlerGuid, TestContext->ContextBuffers, (CONST PRM_CONTEXT_BUFFER **)&FoundContextBuffer);
467
468 UT_ASSERT_STATUS_EQUAL (Status, TestContext->ExpectedStatus);
469
470 if (!EFI_ERROR (TestContext->ExpectedStatus)) {
471 UT_ASSERT_NOT_NULL (FoundContextBuffer);
472 UT_ASSERT_TRUE (FoundContextBuffer == TestContext->ExpectedContextBuffer);
473 }
474
475 return UNIT_TEST_PASSED;
476}
477
479
490int
492 )
493{
494 EFI_STATUS Status;
495 UINTN Index;
496 UNIT_TEST_FRAMEWORK_HANDLE Framework;
497 UNIT_TEST_SUITE_HANDLE BasicTests;
498 UNIT_TEST_SUITE_HANDLE FunctionalCorrectnessTests;
499 CHAR8 TestCaseClassNameString[256];
500 CHAR8 TestCaseDescriptionString[256];
501
502 Framework = NULL;
503
504 DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_NAME, UNIT_TEST_VERSION));
505
506 //
507 // Start setting up the test framework for running the tests.
508 //
509 Status = InitUnitTestFramework (&Framework, UNIT_TEST_NAME, gEfiCallerBaseName, UNIT_TEST_VERSION);
510 if (EFI_ERROR (Status)) {
511 DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
512 goto EXIT;
513 }
514
515 //
516 // Add all test suites and tests.
517 //
518 Status = CreateUnitTestSuite (&BasicTests, Framework, "Basic Context Buffer Tests", "PrmContextBufferLib.Basic", NULL, NULL);
519 if (EFI_ERROR (Status)) {
520 DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for PrmContextBufferLib.Basic\n"));
521 Status = EFI_OUT_OF_RESOURCES;
522 goto EXIT;
523 }
524
526 BasicTests,
527 "",
528 "PrmContextBufferLib.Basic.NullPointerGracefulFailure",
530 NULL,
531 NULL,
532 NULL
533 );
534
535 Status = CreateUnitTestSuite (&FunctionalCorrectnessTests, Framework, "Functional Correctness Tests", "PrmContextBufferLib.Functional", NULL, NULL);
536 if (EFI_ERROR (Status)) {
537 DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for PrmContextBufferLib.Functional\n"));
538 Status = EFI_OUT_OF_RESOURCES;
539 goto EXIT;
540 }
541
542 //
543 // Add Functional Correctness unit tests
544 //
545 for (Index = 0; Index < ARRAY_SIZE (mContextBuffersArray); Index++) {
546 ZeroMem (&TestCaseClassNameString[0], ARRAY_SIZE (TestCaseClassNameString));
547 ZeroMem (&TestCaseDescriptionString[0], ARRAY_SIZE (TestCaseDescriptionString));
548
550 &TestCaseClassNameString[0],
551 ARRAY_SIZE (TestCaseClassNameString),
552 "PrmContextBufferLib.Functional.VerifyGetModuleContextBuffers%d",
553 Index + 1
554 );
556 &TestCaseDescriptionString[0],
557 ARRAY_SIZE (TestCaseDescriptionString),
558 "Verify Get PRM Module Context Buffers Structure by %a GUID %d\n",
559 ((mContextBuffersArray[Index]->GuidSearchType == ByModuleGuid) ? "module" : "handler"),
560 Index + 1
561 );
562
564 FunctionalCorrectnessTests,
565 &TestCaseDescriptionString[0],
566 &TestCaseClassNameString[0],
570 mContextBuffersArray[Index]
571 );
572 }
573
574 for (Index = 0; Index < ARRAY_SIZE (mContextBufferArray); Index++) {
575 ZeroMem (&TestCaseClassNameString[0], ARRAY_SIZE (TestCaseClassNameString));
576 ZeroMem (&TestCaseDescriptionString[0], ARRAY_SIZE (TestCaseDescriptionString));
577
579 &TestCaseClassNameString[0],
580 ARRAY_SIZE (TestCaseClassNameString),
581 "PrmContextBufferLib.Functional.VerifyFindContextBufferInModuleBuffers%d",
582 Index + 1
583 );
585 &TestCaseDescriptionString[0],
586 ARRAY_SIZE (TestCaseDescriptionString),
587 "Verify Find PRM Context Buffer by Handler GUID %d\n",
588 Index + 1
589 );
590
592 FunctionalCorrectnessTests,
593 &TestCaseDescriptionString[0],
594 &TestCaseClassNameString[0],
596 NULL,
597 NULL,
598 mContextBufferArray[Index]
599 );
600 }
601
602 for (Index = 0; Index < ARRAY_SIZE (mContextBufferArray); Index++) {
603 ZeroMem (&TestCaseClassNameString[0], ARRAY_SIZE (TestCaseClassNameString));
604 ZeroMem (&TestCaseDescriptionString[0], ARRAY_SIZE (TestCaseDescriptionString));
605
607 &TestCaseClassNameString[0],
608 ARRAY_SIZE (TestCaseClassNameString),
609 "PrmContextBufferLib.Functional.VerifyGetContextBuffer%d",
610 Index + 1
611 );
613 &TestCaseDescriptionString[0],
614 ARRAY_SIZE (TestCaseDescriptionString),
615 "Verify Get PRM Context Buffer by Handler GUID %d\n",
616 Index + 1
617 );
618
620 FunctionalCorrectnessTests,
621 &TestCaseDescriptionString[0],
622 &TestCaseClassNameString[0],
624 NULL,
625 NULL,
626 mContextBufferArray[Index]
627 );
628 }
629
630 //
631 // Execute the tests.
632 //
633 Status = RunAllTestSuites (Framework);
634
635EXIT:
636 if (Framework) {
637 FreeUnitTestFramework (Framework);
638 }
639
640 return Status;
641}
UINT64 UINTN
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_HANDLE mTestProtocolHandle
=== TEST DATA ==================================================================================
UNIT_TEST_STATUS EFIAPI VerifyFindContextBufferInModuleBuffers(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI NullPointerArgumentsShouldFailGracefully(IN UNIT_TEST_CONTEXT Context)
=== HELPER FUNCTIONS ===========================================================================
STATIC UNIT_TEST_STATUS EFIAPI InitializeFunctionalCorrectness(IN UNIT_TEST_CONTEXT Context)
===== FUNCTIONAL CORRECTNESS SUITE ==================================================
STATIC VOID EFIAPI DeInitializeFunctionalCorrectness(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI VerifyGetContextBuffer(IN UNIT_TEST_CONTEXT Context)
int main()
=== TEST ENGINE ================================================================================
UNIT_TEST_STATUS EFIAPI VerifyGetModuleContextBuffers(IN UNIT_TEST_CONTEXT Context)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
Definition: PrintLib.c:813
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define ARRAY_SIZE(Array)
Definition: Base.h:1393
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_STATUS FindContextBufferInModuleBuffers(IN CONST EFI_GUID *HandlerGuid, IN CONST PRM_MODULE_CONTEXT_BUFFERS *ModuleContextBuffers, OUT CONST PRM_CONTEXT_BUFFER **ContextBuffer)
EFI_STATUS GetContextBuffer(IN CONST EFI_GUID *PrmHandlerGuid, IN CONST PRM_MODULE_CONTEXT_BUFFERS *PrmModuleContextBuffers OPTIONAL, OUT CONST PRM_CONTEXT_BUFFER **PrmContextBuffer)
PRM_GUID_SEARCH_TYPE
@ ByModuleGuid
@ ByHandlerGuid
EFI_STATUS GetModuleContextBuffers(IN PRM_GUID_SEARCH_TYPE GuidSearchType, IN CONST EFI_GUID *Guid, OUT CONST PRM_MODULE_CONTEXT_BUFFERS **PrmModuleContextBuffers)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
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_TRUE(Expression)
Definition: UnitTestLib.h:350
#define UT_ASSERT_EQUAL(ValueA, ValueB)
Definition: UnitTestLib.h:375
#define UT_ASSERT_STATUS_EQUAL(Status, Expected)
Definition: UnitTestLib.h:427
#define UT_LOG_INFO(Format,...)
Definition: UnitTestLib.h:813
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_NOT_EFI_ERROR(Status)
Definition: UnitTestLib.h:414
Definition: Base.h:213
PRM_CONTEXT_BUFFER * Buffer