UnitTestFrameworkPkg/Library: Add library instances
https://bugzilla.tianocore.org/show_bug.cgi?id=2505 Add the following library instances that are used to build unit tests for host and target environments. * CmockaLib with cmocka submodule to: https://git.cryptomilk.org/projects/cmocka.git * DebugLibPosix - Instance of DebugLib based on POSIX APIs (e.g. printf). * MemoryAllocationLibPosix - Instance of MemoryAllocationLib based on POSIX APIs (e.g. malloc/free). * UnitTestBootLibNull - Null instance of the UnitTestBootLib * UnitTestBootLibUsbClass - UnitTestBootLib instances that supports setting boot next to a USB device. * UnitTestLib - UnitTestLib instance that is designed to work with PEI, DXE, SMM, and UEFI Shell target environments. * UnitTestLibCmocka - UintTestLib instance that uses cmocka APIs and can only be use in a host environment. * UnitTestPersistenceLibNull - Null instance of the UnitTestPersistenceLib * UnitTestPersistenceLibSimpleFileSystem - UnitTestPersistenceLib instance that can safe the unit test framework state to a media device that supports the UEFI Simple File System Protocol. * UnitTestResultReportLibConOut - UnitTestResultReportLib instance that sends report results to the UEFI standard output console. * UnitTestResultReportLibDebugLib - UnitTestResultReportLib instance that sends report results to a DebugLib using DEBUG() macros. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
This commit is contained in:
committed by
mergify[bot]
parent
0f7fb5c5e5
commit
0eb522987f
@ -0,0 +1,48 @@
|
||||
/** @file
|
||||
Implement UnitTestResultReportLib doing plain txt out to console
|
||||
|
||||
Copyright (c) Microsoft Corporation.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
||||
VOID
|
||||
ReportPrint (
|
||||
IN CONST CHAR8 *Format,
|
||||
...
|
||||
)
|
||||
{
|
||||
VA_LIST Marker;
|
||||
CHAR16 String[256];
|
||||
UINTN Length;
|
||||
|
||||
VA_START (Marker, Format);
|
||||
Length = UnicodeVSPrintAsciiFormat (String, sizeof (String), Format, Marker);
|
||||
if (Length == 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a formatted string is too long\n", __FUNCTION__));
|
||||
} else {
|
||||
gST->ConOut->OutputString (gST->ConOut, String);
|
||||
}
|
||||
VA_END (Marker);
|
||||
}
|
||||
|
||||
VOID
|
||||
ReportOutput (
|
||||
IN CONST CHAR8 *Output
|
||||
)
|
||||
{
|
||||
CHAR8 AsciiString[128];
|
||||
UINTN Length;
|
||||
UINTN Index;
|
||||
|
||||
Length = AsciiStrLen (Output);
|
||||
for (Index = 0; Index < Length; Index += (sizeof (AsciiString) - 1)) {
|
||||
AsciiStrCpyS (AsciiString, sizeof (AsciiString), &Output[Index]);
|
||||
ReportPrint ("%a", AsciiString);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user