summaryrefslogtreecommitdiffstats
path: root/UnitTestFrameworkPkg
Commit message (Collapse)AuthorAgeFilesLines
* UnitTestFrameworkPkg/UnitTestLib: Move print log into cleanupMichael D Kinney2020-07-151-17/+16
| | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2805 If a unit test fails with an exception or an assert, then the CmockaUnitTestFunctionRunner() is terminated and the logic that follows the invocation of the unit test is skipped. This currently skips the logic that prints log messages. Move the print of log messages to the end of the function CmockaUnitTestTeardownFunctionRunner() that is guaranteed to be executed when a unit test completes normally or is terminated with an exception or an assert. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
* UnitTestFrameworkPkg: Change target mode DebugLib mappingMichael D Kinney2020-07-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2801 The default DebugLib for target mode was DebugLibNull. This library instance disables all ASSERT() and DEBUG() macros which removes the ability to write unit tests that check for ASSERT() behaviors. The DebugLib is changed to PeiDxeDebugLibReportStatusCode.inf that guarantees that DEBUG() and ASSERT() macros are active. The default ReportStatusCodeLib is set to BaseReportStatusCodeLibNull.inf so no messages are sent to any devices preserving the DebugLibNull behavior. A platform specific unit test can always override these mappings with a platform specific DebugLib. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
* UnitTestFrameworkPkg: Set host application stack size to 256KBMichael D Kinney2020-07-151-1/+1
| | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2803 The UEFI Specification defines the minimum stack size before ExitBootServices() to be 128KB. When running a host based unit test, there may be additional stack overhead from the host application environment and cmocka. Update the build flags to set the size of the stack to 256KB which is double the UEFI Specification requirement. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
* UnitTestFrameworkPkg: Enable source level debug for host testsMichael D Kinney2020-07-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2804 Optionally enable a feature to support source level debug of a host based unit test. By default, this feature is disabled. Exceptions are caught by the unit test framework and are interpreted as a test failure. When a unit test is under development, bugs may generate exceptions or a unit test developer may want to trace the execution of unit tests to debug some unexpected behavior. Defining UNIT_TESTING_DEBUG in the DSC file or from the build command line allows exceptions to be caught by the host OS and allows the developer to debug their unit test under development or debug the Unit Test Framework itself. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
* UnitTestFrameworkPkg: Use host libraries from MdePkgMichael D Kinney2020-07-151-0/+4
| | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2800 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2799 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2798 Update the default unit test library mappings to use the library instances from the MdePkg that are safe for host based unit tests. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
* UnitTestFrameworkPkg/UnitTestLib: Update SaveFrameworkState() signatureMichael Kubacki2020-06-142-11/+16
| | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2612 Removes the FrameworkHandle parameter from SaveFrameworkState() in the UnitTestLib library instance and updates callers of the function in the library to use the new function signature. Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
* UnitTestFrameworkPkg: Add info to readme about working with UnitTestsBret Barkelew2020-06-022-6/+83
| | | | | | | Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Bret Barkelew <bret.barkelew@microsoft.com> Signed-off-by: Bret Barkelew <bret.barkelew@microsoft.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
* UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS()Michael Kubacki2020-05-272-2/+2
| | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2721 The ReportOutput() function in UnitTestResultReportLib copies characters from a function input buffer to an intermediate local buffer in fixed size chunks of the maximum size of the intermediate buffer. The implementation currently calls AsciiStrCpyS() which will ASSERT on an error. This commit changes the call to AsciiStrnCpyS() to avoid the ASSERT which is not expected in the usage of the string copy in this implementation. Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
* UnitTestFrameworkPkg/UnitTestLib: Correct dereferred pointerkuqin2020-04-261-3/+1
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2609 SavedState is not sticky, copied pointer update will not change source pointer Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Guomin Jiang <guomin.jiang@intel.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
* UnitTestFrameworkPkg/PersistenceLib: Correct the allocated size.Guomin Jiang2020-04-261-1/+1
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2608 According to logic and the practice, it is need to allocate ascii length by 2 for unicode string. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Guomin Jiang <guomin.jiang@intel.com> Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
* UnitTestFrameworkPkg: Add RISC-V architecture for RISC-V EDK2 CI.Abner Chang2020-04-031-1/+2
| | | | | | | | | | | | | | | | | Add RISC-V architecture to UnitTestFrameworkPkg for RISC-V EDK2 CI. BZ:2562: https://bugzilla.tianocore.org/show_bug.cgi?id=2562 Signed-off-by: Abner Chang <abner.chang@hpe.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Gilbert Chen <gilbert.chen@hpe.com> Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
* UnitTestFrameworkPkg/ResultReportLib: Remove invalid index string indicatorGuomin Jiang2020-03-271-2/+2
| | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2535 The UNIT_TEST_STATUS and FAILURE_TYPE have used 0 as status, so use 0 as unknown is confused, remove it from array enumeration but keep it location in the array. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: Guomin Jiang <guomin.jiang@intel.com> Reviewed-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
* UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.GuoMinJ2020-03-272-4/+4
| | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2530 The Suite pointer is used before check if it is valid, correct it to check the validation before use. Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Signed-off-by: GuoMinJ <newexplorerj@gmail.com> Reviewed-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
* UnitTestFrameworkPkg: Disable EBC in DSC fileMichael D Kinney2020-02-111-1/+1
| | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2514 Remove EBC as one of the supported architectures in the UnitTestFrameworkPkg DSC file. The EBC compiler does not support vararg macros and the UnitTestLib class uses this feature. 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>
* UnitTestFrameworkPkg/UnitTestLib: Fix XCODE parenthesis issuesMichael D Kinney2020-02-112-4/+4
| | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2512 Remove extra sets of parenthesis that generate warnings on XCODE5 builds. 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: Sean Brogan <sean.brogan@microsoft.com>
* UnitTestFrameworkPkg: Add DSC, DSC INC, and YAML filesMichael D Kinney2020-02-075-0/+257
| | | | | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2505 * DSC in root of package file to perform a package build of the UnitTestFrameworkPkg and build sample unit test for all supported target environments. * DSC file in Test directory to build the sample unit test for the host environment. * UnitTestFrameworkPkgTarget.dsc.inc - DSC include file to !include when building unit tests for target environments. * UnitTestFrameworkPkgHost.dsc.inc - DSC include file to !include when building unit tests for target environments. * YAML file with set of CI checks to perform on UnitTestFrameworkPkg. 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> Reviewed-by: Sean Brogan <sean.brogan@microsoft.com>
* UnitTestFrameworkPkg/Test: Add unit test samplesMichael D Kinney2020-02-076-0/+461
| | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2505 Add an implementation of a sample unit test that demonstrates the use of the UnitTestLib services and macros and supports being built for execution in a host environment or for execution on a target in PEI, DXE, SMM, or UEFI Shell. 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>
* UnitTestFrameworkPkg/Library: Add library instancesMichael D Kinney2020-02-0738-0/+4689
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* UnitTestFrameworkPkg: Add public and private interfacesMichael D Kinney2020-02-077-0/+645
https://bugzilla.tianocore.org/show_bug.cgi?id=2505 Add public interfaces for use by unit test implementations. * Include path to cmocka library interfaces. * PcdUnitTestLogLevel to set the unit test logging message level to filter log messages. Add private interfaces that are used by UnitTestLib implementations. * [Private] UnitTestBootLib - Set boot next to continue unit tests across a reboot. * [Private] UnitTestPersistenceLib - Save unit test framework state to a persistent storage device. * [Private] UnitTestResultLib - Output unit test results to a console device. * [Private] UnitTestFrameworkTypes.h - Internal structures used by UnitTestLib implementations to keep track if unit test frameworks, unit test suites, and unit tests along with the serialized storage format to save a unit test framework state to persistent storage. 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>