* [PATCH EDK2 v1 0/1] MdeModulePkg/FrameBufferBltLib:Add unit test
@ 2021-12-01 9:43 wenyi,xie
2021-12-01 9:43 ` [PATCH EDK2 v1 1/1] " wenyi,xie
0 siblings, 1 reply; 2+ messages in thread
From: wenyi,xie @ 2021-12-01 9:43 UTC (permalink / raw)
To: devel, jian.j.wang, gaoliming, zhichao.gao, ray.ni
Cc: songdongkuang, xiewenyi2
Main Changes :
1.Add unit test for function FrameBufferBltConfigure.
Wenyi Xie (1):
MdeModulePkg/FrameBufferBltLib:Add unit test
MdeModulePkg/Test/MdeModulePkgHostTest.dsc | 5 +
MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.inf | 32 ++++
MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.c | 174 ++++++++++++++++++++
MdeModulePkg/MdeModulePkg.ci.yaml | 1 +
4 files changed, 212 insertions(+)
create mode 100644 MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.inf
create mode 100644 MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.c
--
2.20.1.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH EDK2 v1 1/1] MdeModulePkg/FrameBufferBltLib:Add unit test
2021-12-01 9:43 [PATCH EDK2 v1 0/1] MdeModulePkg/FrameBufferBltLib:Add unit test wenyi,xie
@ 2021-12-01 9:43 ` wenyi,xie
0 siblings, 0 replies; 2+ messages in thread
From: wenyi,xie @ 2021-12-01 9:43 UTC (permalink / raw)
To: devel, jian.j.wang, gaoliming, zhichao.gao, ray.ni
Cc: songdongkuang, xiewenyi2
Add unit test for FrameBufferBltLib.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
---
MdeModulePkg/Test/MdeModulePkgHostTest.dsc | 5 +
MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.inf | 32 ++++
MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.c | 174 ++++++++++++++++++++
MdeModulePkg/MdeModulePkg.ci.yaml | 1 +
4 files changed, 212 insertions(+)
diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
index c9ec835df65d..e08bf7d95fe7 100644
--- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
+++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
@@ -47,3 +47,8 @@ [Components]
UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
}
+
+ MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.inf {
+ <LibraryClasses>
+ FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
+ }
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.inf b/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.inf
new file mode 100644
index 000000000000..de32f2d93ba6
--- /dev/null
+++ b/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.inf
@@ -0,0 +1,32 @@
+## @file
+# This is a unit test for the FrameBufferBltLib.
+#
+# Copyright (C) Huawei Technologies Co., Ltd. All rights reserved
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 0x00010017
+ BASE_NAME = FrameBufferBltLibUnitTest
+ FILE_GUID = E9E25A30-D34A-8E09-F9D1-40249AB39778
+ VERSION_STRING = 1.0
+ MODULE_TYPE = HOST_APPLICATION
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ FrameBufferBltLibUnitTest.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ UnitTestLib
+ DebugLib
+ FrameBufferBltLib
diff --git a/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.c b/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.c
new file mode 100644
index 000000000000..0d157f55cb69
--- /dev/null
+++ b/MdeModulePkg/Library/FrameBufferBltLib/UnitTest/FrameBufferBltLibUnitTest.c
@@ -0,0 +1,174 @@
+/** @file
+ Unit tests of the FrameBufferBltLib
+
+ Copyright (C) Huawei Technologies Co., Ltd. All rights reserved
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+
+#include <Library/UnitTestLib.h>
+#include <Library/FrameBufferBltLib.h>
+
+#define UNIT_TEST_APP_NAME "FrameBufferBltLib Unit Tests"
+#define UNIT_TEST_APP_VERSION "1.0"
+
+struct FRAME_BUFFER_CONFIGURE {
+ UINT32 PixelsPerScanLine;
+ UINT32 BytesPerPixel;
+ UINT32 Width;
+ UINT32 Height;
+ UINT8 *FrameBuffer;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+ EFI_PIXEL_BITMASK PixelMasks;
+ INT8 PixelShl[4]; // R-G-B-Rsvd
+ INT8 PixelShr[4]; // R-G-B-Rsvd
+ UINT8 LineBuffer[0];
+};
+
+typedef struct {
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION Information;
+ RETURN_STATUS ExpectedResult;
+} BASIC_TEST_CONTEXT;
+
+static BASIC_TEST_CONTEXT mBasicTestTrue1 = {
+ {0, 1920, 1080, PixelRedGreenBlueReserved8BitPerColor, {0, 0, 0, 0}, 1920},
+ RETURN_SUCCESS
+};
+
+static BASIC_TEST_CONTEXT mBasicTestFalse1 = {
+ {0, 1920, 1080, PixelRedGreenBlueReserved8BitPerColor, {0, 0, 0, 0}, 1080},
+ RETURN_UNSUPPORTED
+};
+
+/**
+ Unit test for FrameBufferBltConfigure () API of the FrameBufferBltLib.
+
+ @param[in] Context [Optional] An optional parameter that enables:
+ 1) test-case reuse with varied parameters and
+ 2) test-case re-entry for Target tests that need a
+ reboot. This parameter is a VOID* and it is the
+ responsibility of the test author to ensure that the
+ contents are well understood by all test cases that may
+ consume it.
+
+ @retval UNIT_TEST_PASSED The Unit test has completed and the test
+ case was successful.
+ @retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has failed.
+**/
+UNIT_TEST_STATUS
+EFIAPI
+FrameBufferBltConfigureTest (
+ IN UNIT_TEST_CONTEXT Context
+ )
+{
+ RETURN_STATUS Result;
+ VOID *FrameBuffer;
+ BASIC_TEST_CONTEXT *BasicContext;
+ FRAME_BUFFER_CONFIGURE Configure;
+ UINTN ConfigureSize;
+
+ FrameBuffer = NULL;
+
+ //FrameBufferInfoInitial (&FrameBufferInfo);
+ BasicContext = (BASIC_TEST_CONTEXT*)Context;
+ Result = FrameBufferBltConfigure (FrameBuffer, &(BasicContext->Information), &Configure, &ConfigureSize);
+ UT_ASSERT_TRUE (Result == BasicContext->ExpectedResult);
+
+ return UNIT_TEST_PASSED;
+}
+
+/**
+ Initialze the unit test framework, suite, and unit tests for the
+ FrameBufferBltLib and run the FrameBufferBltLib unit test.
+
+ @retval EFI_SUCCESS All test cases were dispatched.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources available to
+ initialize the unit tests.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+UnitTestingEntry (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UNIT_TEST_FRAMEWORK_HANDLE Framework;
+ UNIT_TEST_SUITE_HANDLE SortTests;
+
+ Framework = NULL;
+
+ DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION ));
+
+ //
+ // Start setting up the test framework for running the tests.
+ //
+ Status = InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME, gEfiCallerBaseName, UNIT_TEST_APP_VERSION);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
+ goto EXIT;
+ }
+
+ //
+ // Populate the FrameBufferBltLib Unit Test Suite.
+ //
+ Status = CreateUnitTestSuite (&SortTests, Framework, "FrameBufferBltLib Tests", "FrameBufferBltLib.Configure", NULL, NULL);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for FrameBufferBltLib API Tests\n"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EXIT;
+ }
+
+ //
+ // -------------Suite-----------Description----------Name-------------Function-------------Pre---Post---Context-----------
+ //
+ AddTestCase (SortTests, "Create the configuration", "Sort", FrameBufferBltConfigureTest, NULL, NULL, &mBasicTestTrue1);
+ AddTestCase (SortTests, "Create the configuration", "Sort", FrameBufferBltConfigureTest, NULL, NULL, &mBasicTestFalse1);
+
+ //
+ // Execute the tests.
+ //
+ Status = RunAllTestSuites (Framework);
+
+EXIT:
+ if (Framework) {
+ FreeUnitTestFramework (Framework);
+ }
+
+ return Status;
+}
+
+///
+/// Avoid ECC error for function name that starts with lower case letter
+///
+#define FrameBufferBltLibUnitTestMain main
+
+/**
+ Standard POSIX C entry point for host based unit test execution.
+
+ @param[in] Argc Number of arguments
+ @param[in] Argv Array of pointers to arguments
+
+ @retval 0 Success
+ @retval other Error
+**/
+INT32
+FrameBufferBltLibUnitTestMain (
+ IN INT32 Argc,
+ IN CHAR8 *Argv[]
+ )
+{
+ UnitTestingEntry ();
+ return 0;
+}
diff --git a/MdeModulePkg/MdeModulePkg.ci.yaml b/MdeModulePkg/MdeModulePkg.ci.yaml
index f69989087b4c..58dfc3659718 100644
--- a/MdeModulePkg/MdeModulePkg.ci.yaml
+++ b/MdeModulePkg/MdeModulePkg.ci.yaml
@@ -20,6 +20,7 @@
"8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.UID",
"8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.HID",
"8001", "UefiSortLibUnitTestMain",
+ "8001", "FrameBufferBltLibUnitTestMain",
],
## Both file path and directory path are accepted.
"IgnoreFiles": [
--
2.20.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-01 9:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-01 9:43 [PATCH EDK2 v1 0/1] MdeModulePkg/FrameBufferBltLib:Add unit test wenyi,xie
2021-12-01 9:43 ` [PATCH EDK2 v1 1/1] " wenyi,xie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox