18#include "../DxeTpm2MeasureBootLibSanitization.h"
20#define UNIT_TEST_NAME "DxeTpm2MeasureBootLibSanitizationTest"
21#define UNIT_TEST_VERSION "1.0"
23#define DEFAULT_PRIMARY_TABLE_HEADER_REVISION 0x00010000
24#define DEFAULT_PRIMARY_TABLE_HEADER_NUMBER_OF_PARTITION_ENTRIES 1
25#define DEFAULT_PRIMARY_TABLE_HEADER_SIZE_OF_PARTITION_ENTRY 128
64 BlockIo.
Media = &BlockMedia;
66 BlockIo.ReadBlocks =
NULL;
67 BlockIo.WriteBlocks =
NULL;
68 BlockIo.FlushBlocks =
NULL;
72 PrimaryHeader.
Header.
Revision = DEFAULT_PRIMARY_TABLE_HEADER_REVISION;
74 PrimaryHeader.
MyLBA = 1;
110 DEBUG ((DEBUG_INFO,
"%a: Test passed\n", __func__));
112 return UNIT_TEST_PASSED;
131 UINT32 AllocationSize;
164 DEBUG ((DEBUG_INFO,
"%a: Test passed\n", __func__));
166 return UNIT_TEST_PASSED;
186 UINT32 ExistingLogicEventSize;
189 UINTN NumberOfPartition;
196 NumberOfPartition = 13;
218 DEBUG ((DEBUG_INFO,
"%a: Test passed\n", __func__));
220 return UNIT_TEST_PASSED;
241 UINTN ExistingLogicEventSize;
255 if (EventSize != ExistingLogicEventSize) {
256 UT_LOG_ERROR (
"SanitizePeImageEventSize returned an incorrect event size. Expected %u, got %u\n", ExistingLogicEventSize, EventSize);
257 return UNIT_TEST_ERROR_TEST_FAILED;
264 DEBUG ((DEBUG_INFO,
"%a: Test passed\n", __func__));
266 return UNIT_TEST_PASSED;
287 UNIT_TEST_FRAMEWORK_HANDLE Framework;
288 UNIT_TEST_SUITE_HANDLE Tcg2MeasureBootLibValidationTestSuite;
292 DEBUG ((DEBUG_INFO,
"%a: TestMain() - Start\n", UNIT_TEST_NAME));
295 if (EFI_ERROR (Status)) {
296 DEBUG ((DEBUG_ERROR,
"%a: Failed in InitUnitTestFramework. Status = %r\n", UNIT_TEST_NAME, Status));
300 Status =
CreateUnitTestSuite (&Tcg2MeasureBootLibValidationTestSuite, Framework,
"Tcg2MeasureBootLibValidationTestSuite",
"Common.Tcg2MeasureBootLibValidation",
NULL,
NULL);
301 if (EFI_ERROR (Status)) {
302 DEBUG ((DEBUG_ERROR,
"%s: Failed in CreateUnitTestSuite for Tcg2MeasureBootLibValidationTestSuite\n", UNIT_TEST_NAME));
303 Status = EFI_OUT_OF_RESOURCES;
316 if (Framework !=
NULL) {
320 DEBUG ((DEBUG_INFO,
"%a: TestMain() - End\n", UNIT_TEST_NAME));
327#define DxeTpm2MeasureBootLibUnitTestMain main
UINT32 EFIAPI CalculateCrc32(IN VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI Tpm2SanitizeEfiPartitionTableHeader(IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, IN CONST EFI_BLOCK_IO_PROTOCOL *BlockIo)
EFI_STATUS EFIAPI Tpm2SanitizePrimaryHeaderAllocationSize(IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, OUT UINT32 *AllocationSize)
EFI_STATUS Tpm2SanitizePeImageEventSize(IN UINT32 FilePathSize, OUT UINT32 *EventSize)
EFI_STATUS Tpm2SanitizePrimaryHeaderGptEventSize(IN CONST EFI_PARTITION_TABLE_HEADER *PrimaryHeader, IN UINTN NumberOfPartition, OUT UINT32 *EventSize)
EFI_STATUS EFIAPI UefiTestMain(VOID)
UNIT_TEST_STATUS EFIAPI TestSanitizePeImageEventSize(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI TestSanitizeEfiPartitionTableHeader(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI TestSanitizePrimaryHeaderAllocationSize(IN UNIT_TEST_CONTEXT Context)
#define DxeTpm2MeasureBootLibUnitTestMain
UNIT_TEST_STATUS EFIAPI TestSanitizePrimaryHeaderGptEventSize(IN UNIT_TEST_CONTEXT Context)
#define OFFSET_OF(TYPE, Field)
#define DEBUG(Expression)
#define EFI_PTAB_HEADER_ID
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
#define UT_LOG_ERROR(Format,...)
#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_NOT_EFI_ERROR(Status)
EFI_BLOCK_IO_MEDIA * Media
UINT32 SizeOfPartitionEntry
EFI_LBA PartitionEntryLBA
UINT32 PartitionEntryArrayCRC32
UINT32 NumberOfPartitionEntries