18#define UNIT_TEST_APP_NAME "FmpDependencyLib Unit Test Application"
19#define UNIT_TEST_APP_VERSION "1.0"
23 UINTN DependenciesSize;
24 BOOLEAN ExpectedResult;
30#define IMAGE_TYPE_ID_1 { 0x97144DFA, 0xEB8E, 0xD14D, {0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42}}
35#define IMAGE_TYPE_ID_2 { 0xA42A7370, 0x433A, 0x684D, {0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3}}
42 { IMAGE_TYPE_ID_1, 0x00000002 },
43 { IMAGE_TYPE_ID_2, 0x00000003 }
47static UINT8 mExpression1[] = {
48 EFI_FMP_DEP_PUSH_VERSION, 0x01, 0x00, 0x00, 0x00,
49 EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
51 EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00,
52 EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4,0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
59static UINT8 mExpression2[] = {
60 EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
61 EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
63 EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00,
64 EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4,0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
71static UINT8 mExpression3[] = {
72 EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
73 EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E,0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
80static UINT8 mExpression4[] = {
81 EFI_FMP_DEP_VERSION_STR,
'T',
'e',
's',
't',
'\0',
89static UINT8 mExpression5[] = { EFI_FMP_DEP_TRUE, 0xAA, EFI_FMP_DEP_END };
92static UINT8 mExpression6[] = { EFI_FMP_DEP_VERSION_STR,
'T',
'e',
's',
't', EFI_FMP_DEP_TRUE, EFI_FMP_DEP_END };
95static UINT8 mExpression7[] = {
96 EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
103static UINT8 mExpression8[] = {
104 EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00,
105 EFI_FMP_DEP_PUSH_GUID, 0xDA, 0xCB,0x25,0xAC, 0x9E, 0xCD, 0x5E, 0xE2, 0x9C, 0x5E, 0x4A, 0x99, 0x35, 0xA7, 0x67, 0x53,
111static UINT8 mExpression9[] = { EFI_FMP_DEP_TRUE, EFI_FMP_DEP_FALSE, EFI_FMP_DEP_GTE, EFI_FMP_DEP_END };
114static UINT8 mExpression10[] = {
115 EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
116 EFI_FMP_DEP_PUSH_GUID, 0xDA, 0xCB, 0x25, 0xAC,0x9E,0xCD, 0x5E, 0xE2, 0x9C, 0x5E, 0x4A, 0x99, 0x35, 0xA7, 0x67, 0x53,
122static UINT8 mExpression11[] = {
123 EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
129static UINT8 mExpression12[] = {
130 EFI_FMP_DEP_DECLARE_LENGTH, 0x35, 0x00, 0x00, 0x00,
131 EFI_FMP_DEP_PUSH_VERSION, 0x01, 0x00, 0x00, 0x00,
132 EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
134 EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00,
135 EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4,0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
142static UINT8 mExpression13[] = {
143 EFI_FMP_DEP_DECLARE_LENGTH, 0x3B, 0x00, 0x00, 0x00,
144 EFI_FMP_DEP_PUSH_VERSION, 0x01, 0x00, 0x00, 0x00,
145 EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
147 EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00,
148 EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4,0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
155static UINT8 mExpression14[] = {
156 EFI_FMP_DEP_DECLARE_LENGTH, 0x1B, 0x00, 0x00, 0x00,
157 EFI_FMP_DEP_PUSH_VERSION, 0x01, 0x00, 0x00, 0x00,
158 EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
160 EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00,
161 EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4,0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
168static UINT8 mExpression15[] = {
169 EFI_FMP_DEP_PUSH_VERSION, 0x01, 0x00, 0x00, 0x00,
170 EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
172 EFI_FMP_DEP_DECLARE_LENGTH, 0x35, 0x00, 0x00, 0x00,
173 EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00,
174 EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4,0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
221 BOOLEAN EvaluationResult;
222 UINT32 LastAttemptStatus;
228 TestContext->DependenciesSize,
236 return UNIT_TEST_PASSED;
255 UNIT_TEST_FRAMEWORK_HANDLE Fw;
256 UNIT_TEST_SUITE_HANDLE DepexEvalTests;
260 DEBUG ((DEBUG_INFO,
"%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION));
266 if (EFI_ERROR (Status)) {
267 DEBUG ((DEBUG_ERROR,
"Failed in InitUnitTestFramework. Status = %r\n", Status));
275 if (EFI_ERROR (Status)) {
276 DEBUG ((DEBUG_ERROR,
"Failed in CreateUnitTestSuite for DepexEvalTests\n"));
int main()
=== TEST ENGINE ================================================================================
STATIC UNIT_TEST_STATUS EFIAPI EvaluateDependencyTest(IN UNIT_TEST_CONTEXT Context)
EFI_STATUS EFIAPI FmpDependencyLibUnitTestAppEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC EFI_STATUS EFIAPI UnitTestingEntry(VOID)
#define EFI_FMP_DEP_PUSH_GUID
BOOLEAN EFIAPI EvaluateDependency(IN EFI_FIRMWARE_IMAGE_DEP *Dependencies, IN UINTN DependenciesSize, IN FMP_DEPEX_CHECK_VERSION_DATA *FmpVersions OPTIONAL, IN UINTN FmpVersionsCount, OUT UINT32 *LastAttemptStatus OPTIONAL)
#define DEBUG(Expression)
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
#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)