<html xmlns:v="urn:schemas-microsoft-com:vml" 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)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 5 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* 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;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.spelle
        {mso-style-name:spelle;}
.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;}
/* List Definitions */
@list l0
        {mso-list-id:931242;
        mso-list-template-ids:-1;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Andrew,</p>
<p class="MsoNormal">I agree with your points.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Mike,</p>
<p class="MsoNormal">You’ve got a lot more there. Let me take a look and update the draft. I’ll ping back ASAP.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- Bret</p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:afish@apple.com">Andrew Fish</a><br>
<b>Sent: </b>Wednesday, December 4, 2019 9:50 AM<br>
<b>To: </b><a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>; <a href="mailto:michael.d.kinney@intel.com">
Kinney, Michael D</a><br>
<b>Cc: </b><a href="mailto:Bret.Barkelew@microsoft.com">Bret Barkelew</a>; <a href="mailto:rfc@edk2.groups.io">
rfc@edk2.groups.io</a><br>
<b>Subject: </b>[EXTERNAL] Re: [edk2-devel] EDK2 Host-Based Unit Test RFC (Now with docs!)</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Mike, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I like and agree with your comments.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">On the UnitTestPkg(s) dependency issue I think it would make sense to move as much as possible into the *Pkg/Test/ ( *Pkg/HostLibrary,  MdePkg/MdePkgTest.dsc, etc.) directory structure. It looks like for implementation specific tests we
 skip the Test directory and drop the UnitTest or FuzzTest directly into modules directory. Maybe we should follow the same pattern as *Pkg/Test and have a Test directory? This will help minimize the number of "reserved" directories we need for managing the
 testing. Have a standardized directory structure will make it easier to differentiate the code from tests while doing `git grep` or other forms of code spelunking. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">A Host-Based Unit Test for a Library makes sense as you can link directly against the library and test it. A Host-Based Unit Test for Protocol/PPI/GUID [1] seems a little more complex. It is easy enough to write tests for the interfaces
 but what APIs do you call to get access to the protocol? <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Per our conversation at the Stewards meeting I think make sense to try to roll out the testing of libraries as the 1st phase. The mocking required for drivers could get quite complex and let us not get bogged down in all that to get something
 working. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">[1] *Pkg/Test/UnitTest/[Library|Protocol|Ppi|Guid] <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Andrew Fish<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Dec 2, 2019, at 3:12 PM, Michael D Kinney <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hi Bret,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks for posting this content. <span class="apple-converted-space"> </span>Host based unit testing is a very valuable addition to the CI checks.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I have the following comments:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<ol style="margin-top:0in" start="1" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo1">
I see that<span class="apple-converted-space"> </span><span class="spelle">MdePkg</span><span class="apple-converted-space"> </span>adds a dependency on<span class="apple-converted-space"> </span><span class="spelle">UnitTestPkg</span>. <span class="apple-converted-space"> </span>This
 makes<span class="apple-converted-space"> </span><span class="spelle">UnitTestPkg</span><span class="apple-converted-space"> </span>the root package when building and running host based unit tests. <span class="apple-converted-space"> </span>This makes sense,
 but good to highlight that all packages that use host based tests will introduce a new package dependency on<span class="apple-converted-space"> </span><span class="spelle">UnitTestPkg</span>.
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="1" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo1">
Since the dependency only applies to unit tests, can we update the<span class="apple-converted-space"> </span><span class="spelle">DependencyCheck</span><span class="apple-converted-space"> </span>plugin to support listing dependencies for FW components separate
 from dependencies for unit tests?<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="2" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo1">
I see<span class="apple-converted-space"> </span><span class="spelle">UnitTestPkg</span><span class="apple-converted-space"> </span>declares 6 new lib classes. <span class="apple-converted-space"> </span>Are all 6 classes intended to be used directly from a
 unit test case? <span class="apple-converted-space"> </span>If some of these are only intended to be used from the framework inside the<span class="apple-converted-space"> </span><span class="spelle">UnitTestPkg</span><span class="apple-converted-space"> </span>can
 we make them private?<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo1">
In the<span class="apple-converted-space"> </span><span class="spelle">MdePkg</span>, I see a new top level directory called ‘<span class="spelle">HostLibrary</span>’. Since these lib instances are only used from a host based test, can they be moved into<span class="apple-converted-space"> </span> the
 ‘Test’ directory?<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo1">
<span class="spelle">MdePkg</span>/<span class="spelle">MdePkgTest.dsc</span>.  <o:p>
</o:p></li></ol>
<ol style="margin-top:0in" start="4" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo2">
Can this DSC file be moved into the ‘Test’ directory? <o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo2">
I see this DSC file only supports VS today. <span class="apple-converted-space"> </span>How much work is it to add GCC support?<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="5" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo2">
<span class="spelle">MdePkg</span>/<span class="spelle">HostLibrary</span>/<span class="spelle">BaseLibHost</span>
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="5" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo3">
Why are there 2<span class="apple-converted-space"> </span><span class="spelle">INFs.</span> <span class="apple-converted-space"> </span>One with ASM and one without ASM? <span class="apple-converted-space"> </span>Can we just use the one with ASM and assume
 NASM is installed?<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo3">
I see the purpose of this lib instance is to call the<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo3">
<span class="spelle">SetJump</span>()/<span class="spelle">LongJump</span>(). <span class="apple-converted-space"> </span>So these implementations always work? <span class="apple-converted-space"> </span>It looks like it assumes BASE_LIBRARY_JUMP_BUFFER is
 identical to the host OS user mode application<span class="spelle">setjmp</span>()/<span class="spelle">longjmp</span>() state.<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo3">
Why are<span class="apple-converted-space"> </span><span class="spelle">DRx</span><span class="apple-converted-space"> </span>and<span class="apple-converted-space"> </span><span class="spelle">CRx</span><span class="apple-converted-space"> </span>registers
 emulated? <span class="apple-converted-space"> </span>I would think and code that depends on read/writing these registers would not be compatible with host based testing. <span class="apple-converted-space"> </span>Can we change to ASSERT (FALSE)?<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo3">
PatchInstructionX86() – I suspect this will not work in a host based environment because it is<span class="apple-converted-space"> </span><span class="spelle">self modifying</span><span class="apple-converted-space"> </span>code. <span class="apple-converted-space"> </span>Should
 it be ASSERT (FALSE)?<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="6" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo3">
<span class="spelle">MdePkg</span>/<span class="spelle">HostLibrary</span>/<span class="spelle">DebugLibHost</span>
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="6" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo4">
What is ‘#<span class="spelle">ifndef</span><span class="apple-converted-space"> </span>TEST_WITH_KLEE’<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo4">
What is the ‘<span class="spelle">PatchFormat</span>()’ function? <span class="apple-converted-space"> </span>It is always disabled with if (0).<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo4">
Are the PCDs to set the debug message levels disabled on purpose? (<span class="spelle">DebugPrintEnabled</span>(),<span class="apple-converted-space"> </span><span class="spelle">DebugPrintLevelEnabled</span>(),<span class="apple-converted-space"> </span><span class="spelle">DebugCodeEnabled</span>())<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="7" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo4">
<span class="spelle">MdePkg</span>/<span class="spelle">HostLibrary</span>/<span class="spelle">BaseMemoryLibHost</span>
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="7" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo5">
Why can’t we use<span class="apple-converted-space"> </span><span class="spelle">MdePkg</span>/Library/<span class="spelle">BaseMemoryLib</span>/<span class="spelle">BaseMemoryLib</span>/inf instead and reduce the number of host specific lib instances?<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="8" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo5">
<span class="spelle">MdePkg</span>/<span class="spelle">HostLibrary</span>/<span class="spelle">MemoryAllocationLibHost</span>
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="8" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo6">
Why is are<span class="apple-converted-space"> </span><span class="spelle">memcpy</span>(), assert(),<span class="apple-converted-space"> </span><span class="spelle">memset</span>() used in this lib? <span class="apple-converted-space"> </span>I would expect
 this lib instance to match the<span class="apple-converted-space"> </span><span class="spelle">UefiMemoryAllocationLib</span><span class="apple-converted-space"> </span>with the only the use of malloc() and free() to replace the UEFI Boot Services calls.<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="9" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo6">
Host library instance naming conventions. <o:p></o:p></li></ol>
<ol style="margin-top:0in" start="9" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo7">
The current naming convention uses the environment as a prefix(e.g. Pei,<span class="apple-converted-space"> </span><span class="spelle">Smm</span>,<span class="apple-converted-space"> </span><span class="spelle">Uefi</span>) and the services the lib instance
 uses as a post fix. <span class="apple-converted-space"> </span>Would it make more sense to use ‘Host’ as a prefix instead of a postfix in the lib instance names?<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="10" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo7">
Unicode vs ASCII strings <o:p></o:p></li></ol>
<ol style="margin-top:0in" start="10" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo8">
I see<span class="apple-converted-space"> </span><span class="spelle">InitUnitTestFramework</span>(),<span class="apple-converted-space"> </span><span class="spelle">CreateUnitTestSuite</span>(), and<span class="apple-converted-space"> </span><span class="spelle">AddTestCase</span>()
 all take Unicode strings for the labels. <span class="apple-converted-space"> </span>I also see extra code to convert<span class="apple-converted-space"> </span><span class="spelle">gEfiCallerBaseName</span><span class="apple-converted-space"> </span>from
 ASCII to Unicode to use it as a short name of a test framework. <span class="apple-converted-space"> </span>I think it would be simpler if the parameters to these APIs were ASCII and the framework can convert to Unicode if needed.<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="11" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo8">
Will<span class="apple-converted-space"> </span><span class="spelle">InitUnitTestFramework</span>() and<span class="apple-converted-space"> </span><span class="spelle">CreateUnitTestSuite</span>() always be called in pairs? <span class="apple-converted-space"> </span>If
 so, can we combine these to a single API?  <o:p></o:p></li></ol>
<ol style="margin-top:0in" start="11" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo9">
I see the<span class="apple-converted-space"> </span><span class="spelle">SafeIntLib</span><span class="apple-converted-space"> </span>example create a single framework and multiple test suites. <span class="apple-converted-space"> </span>Perhaps we can have
 a single<span class="apple-converted-space"> </span><span class="spelle">CreateUnitTestSuite</span>() API where Framework is an IN/OUT and if it is passed in as NULL, the Framework handle is created.<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo9">
I see a pattern where the<span class="apple-converted-space"> </span><span class="spelle">CreateUnitTestSuite</span>() ‘Package’ parameter is used as a prefix to every call to<span class="apple-converted-space"> </span><span class="spelle">AddTestCase</span>()
 in the ‘<span class="spelle">ClassName</span>’ parameter. <span class="apple-converted-space"> </span>Can we simplify<span class="apple-converted-space"> </span><span class="spelle">AddTestCase</span>() so it only need to pass in the name of the unit test
 case, and the framework can append Package <span class="apple-converted-space"> </span>and the unit test case name?<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="12" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo9">
I see the use of the ‘<span class="spelle">Fw</span>’ variable as a shorthand for ‘Framework’. <span class="apple-converted-space"> </span>Can we use something other than ‘<span class="spelle">Fw</span>’. <span class="apple-converted-space"> </span>It may be
 confused with ‘Firmware’. <span class="apple-converted-space"> </span><o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo9">
<span class="spelle">UnitTestPkg</span>/Include/<span class="spelle">UnitTestTypes.h</span>
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="13" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo10">
I see several hard coded string lengths. <span class="apple-converted-space"> </span>Since this runs in a host environment and strings can always be allocated, can the hard coded lengths be removed? <span class="apple-converted-space"> </span>Update the structs
 to use pointers to strings instead of string arrays, and the framework can manage<span class="apple-converted-space"> </span><span class="spelle">alloc</span>() and free()?<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo10">
How are Fingerprints used? <span class="apple-converted-space"> </span>The idea of using as hash as a unique identifier is a good idea. <span class="apple-converted-space"> </span>How is the hash calculated? <span class="apple-converted-space"> </span>What
 unit test code artifacts are used so developers know what parameters must be unique? <span class="apple-converted-space"> </span>Can we just decide to use a specific hash algorithm/size and the structure can be a pointer to an allocated buffer instead of a
 fixed size array to make it easy to change the algorithm/size in the future?<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo10">
Update all the strings to be ASCII? <span class="apple-converted-space"> </span>See Unicode vs ASCII above.<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo10">
UNIT_TEST_SAVE_TEST – The last field is a variable sized array, so it can be a formal field.<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo10">
UNIT_TEST_SAVE_CONTEXT - – The last field is a variable sized array, so it can be a formal field.<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo10">
UNIT_TEST_SAVE_HEADER – Can the last 3 fields be changed to pointers and be formal fields?<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo10">
Do the structures really need to be packed? <span class="apple-converted-space"> </span>Specially with the changes suggested above? <span class="apple-converted-space"> </span>Is the intent to potentially share data stored on disk between different host execution
 environments that may have different width architectures?<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="14" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo10">
<span class="spelle">UnitTestPkg</span><span class="apple-converted-space"> </span>–<span class="apple-converted-space"> </span><span class="spelle">UnitTestLib.h</span>
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="14" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo11">
Can you provide more context for the APIs<span class="apple-converted-space"> </span><span class="spelle">SaveFrameworkState</span>(),<span class="apple-converted-space"> </span><span class="spelle">SaveFrameworkStateAndQuit</span>(),<span class="apple-converted-space"> </span><span class="spelle">SaveFrameworkStateAndReboot</span>(),<span class="apple-converted-space"> </span><span class="spelle">SetFrameworkBootNextDevice</span>(). <span class="apple-converted-space"> </span>I
 do not see any Load() functions, so how would a set of tests be resumed? <span class="apple-converted-space"> </span>If these do not apply to host based tests, should these be split out to a different lib class?<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="15" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo11">
<span class="spelle">UnitTestPkg</span>/Library/<span class="spelle">UnitTestLib</span>
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="15" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo12">
I see an implementation of MD5. <span class="apple-converted-space"> </span>We should not do our own. <span class="apple-converted-space"> </span>We should use an approved implementation such as OpenSSL.<o:p></o:p></li></ol>
</ol>
<ol style="margin-top:0in" start="16" type="1">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level1 lfo12">
<span class="spelle">UnitTestPkg</span>/Library/<span class="spelle">UnitTestTerminationLibTbd</span>
<o:p></o:p></li></ol>
<ol style="margin-top:0in" start="16" type="1">
<ol style="margin-top:0in" start="1" type="a">
<li class="MsoListParagraph" style="margin-top:0in;margin-bottom:0in;margin-bottom:.0001pt;mso-list:l0 level2 lfo13">
Do we really need this lib instance now?<o:p></o:p></li></ol>
</ol>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Mike<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<div>
<p class="MsoNormal"><b>From:</b><span class="apple-converted-space"> </span><a href="mailto:devel@edk2.groups.io"><span style="color:#954F72">devel@edk2.groups.io</span></a><span class="apple-converted-space"> </span><<a href="mailto:devel@edk2.groups.io"><span style="color:#954F72">devel@edk2.groups.io</span></a>><span class="apple-converted-space"> </span><b>On
 Behalf Of<span class="apple-converted-space"> </span></b>Bret Barkelew via Groups.Io<br>
<b>Sent:</b><span class="apple-converted-space"> </span>Thursday, November 21, 2019 11:39 PM<br>
<b>To:</b><span class="apple-converted-space"> </span><a href="mailto:devel@edk2.groups.io"><span style="color:#954F72">devel@edk2.groups.io</span></a><br>
<b>Subject:</b><span class="apple-converted-space"> </span>[edk2-devel] EDK2 Host-Based Unit Test RFC (Now with docs!)<o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<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://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcorthon%2Fedk2-staging%2Ftree%2Fedk2-host-test_v2&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C99a0ca0ef5c047f15d7c08d778e2842f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637110786587150091&sdata=R0cEUBx2R%2F6ppOZf5pwyZ2xHO1vrYWDD4lDP0AhseQw%3D&reserved=0"><span style="color:#954F72">https://github.com/corthon/edk2-staging/tree/edk2-host-test_v2</span></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&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C99a0ca0ef5c047f15d7c08d778e2842f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637110786587150091&sdata=eVlGMFrTlnBQqIqE76aC12TYPAATe0tGAkg8dbfRfjM%3D&reserved=0"><span style="color:#954F72">https://dev.azure.com/tianocore/edk2-ci-play/_build?definitionId=36&_a=summary</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&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C99a0ca0ef5c047f15d7c08d778e2842f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637110786587160084&sdata=9DtP1PcX8FiGGtnzQf1%2FKoDjdieM7zMstI1H34Isi6I%3D&reserved=0"><span style="color:#954F72">https://dev.azure.com/tianocore/edk2-ci-play/_build/results?buildId=2813</span></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.</p>
<p class="MsoNormal" style="margin-bottom:12.0pt">There’s an RFC doc here:<span class="apple-converted-space"> </span><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcorthon%2Fedk2-staging%2Fblob%2Fedk2-host-test_v2%2FReadme-RFC.md&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C99a0ca0ef5c047f15d7c08d778e2842f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637110786587170082&sdata=Wk%2FUyw63ja6eYOqidqExBwfMVkwvSDPMyqO%2FcjEMw6Q%3D&reserved=0"><span style="color:#954F72">https://github.com/corthon/edk2-staging/blob/edk2-host-test_v2/Readme-RFC.md</span></a></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">And a usage guide here:<span class="apple-converted-space"> </span><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcorthon%2Fedk2-staging%2Fblob%2Fedk2-host-test_v2%2FUnitTestPkg%2FReadMe.md&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C99a0ca0ef5c047f15d7c08d778e2842f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637110786587170082&sdata=w5oVcKFRt6kWyahwGJjwSgYO6Ii%2B%2FfwjW18rwNcaoQo%3D&reserved=0"><span style="color:#954F72">https://github.com/corthon/edk2-staging/blob/edk2-host-test_v2/UnitTestPkg/ReadMe.md</span></a></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</p>
<div>
<p class="MsoNormal"></o:p></span></p>
</div>
</div>
</blockquote>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><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/51755">View/Reply Online (#51755)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/66498107/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>