<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal" style="margin-bottom:12.0pt">Now that CI has landed in edk2/master, we'd like to get the basic framework for unittesting staged as well. Target intercept date would be immediately after the 2019/11 stabilization, so we wanted to go ahead
 and get comments now.<br>
<br>
The host unittest framework consists of five primary pieces:<br>
- The test library (Cmocka)<br>
- Support libraries (Found in UnitTestPkg)<br>
- The test support plugins (HostUnitTestComilerPlugin, HostUnitTestDxeCompleteCheck, HostBasedUnitTestRunner)<br>
- The configuration in the package-based *.ci.yaml file and package-based Test.dsc<br>
- The tests themselves<br>
<br>
We have a demo branch set up at:<br>
<a href="https://github.com/corthon/edk2-staging/tree/edk2-host-test_v2">https://github.com/corthon/edk2-staging/tree/edk2-host-test_v2</a><br>
We also have a demo build pipeline at:<br>
<a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdev.azure.com%2Ftianocore%2Fedk2-ci-play%2F_build%3FdefinitionId%3D36%26_a%3Dsummary&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7C3ce0b4eaf6d14de8822808d769f2c5fd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637094365265670742&amp;sdata=HFBmk%2FdB5pXI3exxB82pTS1oF877fLsrrdcirOzCCw0%3D&amp;reserved=0"><span style="color:windowtext;text-decoration:none"><u><span style="color:blue">https://dev.azure.com/tianocore/edk2-ci-play/_build?definitionId=36&_a=summary</span></u></span></a><br>
<br>
The current demo branch contains a single test in MdePkg for SafeIntLib (module file MdePkg\Test\UnitTest\Library\BaseSafeIntLib\TestBaseSafeIntLib.inf). This test is automatically detected by the HostUnitTestComilerPlugin and run by the HostBasedUnitTestRunner
 as part of the CI process.<br>
<br>
A few notes about the current demo:<br>
1) The demo currently only works on Windows build chains, but there's no reason to believe that it can't work equally well on Linux build chains, and are happy to work with anyone to get it there.<br>
<br>
2) The demo currently has four failing conditions that can be seen towards the end of MdePkg "Build and Test" log file for this build:<br>
<a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdev.azure.com%2Ftianocore%2Fedk2-ci-play%2F_build%2Fresults%3FbuildId%3D2590&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7C3ce0b4eaf6d14de8822808d769f2c5fd%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637094365265670742&amp;sdata=HgPEoYg%2Fpx0fv4J5ULO1p0kvLfqcySkJHAYxp9GB598%3D&amp;reserved=0">https://dev.azure.com/tianocore/edk2-ci-play/_build/results?buildId=2813</a><br>
"WARNING -   Test SafeInt16ToChar8 - Status<br>
d:\a\1\s\MdePkg\Test\UnitTest\Library\BaseSafeIntLib\TestBaseSafeIntLib.c:302: error: Failure!<br>
WARNING - TestBaseSafeIntLib.exe Test Failed<br>
WARNING -   Test SafeInt32ToChar8 - Status<br>
d:\a\1\s\MdePkg\Test\UnitTest\Library\BaseSafeIntLib\TestBaseSafeIntLib.c:638: error: Failure!<br>
WARNING - TestBaseSafeIntLib.exe Test Failed<br>
WARNING -   Test SafeIntnToChar8 - Status<br>
d:\a\1\s\MdePkg\Test\UnitTest\Library\BaseSafeIntLib\TestBaseSafeIntLib.c:1051: error: Failure!<br>
WARNING - TestBaseSafeIntLib.exe Test Failed<br>
WARNING -   Test SafeInt64ToChar8 - Status<br>
d:\a\1\s\MdePkg\Test\UnitTest\Library\BaseSafeIntLib\TestBaseSafeIntLib.c:1456: error: Failure!"<br>
These failures seem to be legitimate and further work should be done by the community to decide whether the test case is correct or the library is correct, but one of them needs to change.<br>
<br>
3) Current demo pulls in test collateral from a fork of the edk2-test repo. This repo is currently *very* heavy due to the history of the UEFI SCT project and the number of binaries that it pulls down. It's possible that we (the community) need to select a
 better place for this code to live. Maybe in edk2 primary (though it's not explicitly firmware code, so it seems unnecessary). Maybe in a new edk2-test2 repo or something like that.<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">There’s an RFC doc here: <a href="https://github.com/corthon/edk2-staging/blob/edk2-host-test_v2/Readme-RFC.md">
https://github.com/corthon/edk2-staging/blob/edk2-host-test_v2/Readme-RFC.md</a><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">And a usage guide here: <a href="https://github.com/corthon/edk2-staging/blob/edk2-host-test_v2/UnitTestPkg/ReadMe.md">
https://github.com/corthon/edk2-staging/blob/edk2-host-test_v2/UnitTestPkg/ReadMe.md</a><o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
Once again, would love to get this into EDK2 master after stabilization, and most of this has previously been shopped around in other discussion threads. This is just where the rubber meets the road and is the minimal subset of code that needs to land for folks
 to start contributing unittests against the core libraries that can be run as part of any CI pass.<br>
<br>
Thanks!<br>
- Bret<o:p></o:p></p>
</div>
</body>
</html>

<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>

You receive all messages sent to this group.


<p>

<a target="_blank" href="https://edk2.groups.io/g/devel/message/51165">View/Reply Online (#51165)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/61559421/1813853">Mute This Topic</a>
  

| <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>



<br>

<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>