UnitTestResultReportLibConOut.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /** @file
  2. Implement UnitTestResultReportLib doing plain txt out to console
  3. Copyright (c) Microsoft Corporation.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <Uefi.h>
  7. #include <Library/BaseLib.h>
  8. #include <Library/PrintLib.h>
  9. #include <Library/UefiBootServicesTableLib.h>
  10. #include <Library/DebugLib.h>
  11. VOID
  12. EFIAPI
  13. ReportPrint (
  14. IN CONST CHAR8 *Format,
  15. ...
  16. )
  17. {
  18. VA_LIST Marker;
  19. CHAR16 String[256];
  20. UINTN Length;
  21. VA_START (Marker, Format);
  22. Length = UnicodeVSPrintAsciiFormat (String, sizeof (String), Format, Marker);
  23. if (Length == 0) {
  24. DEBUG ((DEBUG_ERROR, "%a formatted string is too long\n", __FUNCTION__));
  25. } else {
  26. gST->ConOut->OutputString (gST->ConOut, String);
  27. }
  28. VA_END (Marker);
  29. }
  30. VOID
  31. ReportOutput (
  32. IN CONST CHAR8 *Output
  33. )
  34. {
  35. CHAR8 AsciiString[128];
  36. UINTN Length;
  37. UINTN Index;
  38. Length = AsciiStrLen (Output);
  39. for (Index = 0; Index < Length; Index += (sizeof (AsciiString) - 1)) {
  40. AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &Output[Index], sizeof (AsciiString) - 1);
  41. ReportPrint ("%a", AsciiString);
  42. }
  43. }