<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:x="urn:schemas-microsoft-com:office:excel" 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=utf-8">
<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:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@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;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"Segoe UI Emoji";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* 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;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        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.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">HI Bret<o:p></o:p></p>
<p class="MsoNormal">That is awesome.<o:p></o:p></p>
<p class="MsoNormal">I am also excited to see that.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I really like the rust unit test idea because the framework is embedded in the language and compiler.<o:p></o:p></p>
<p class="MsoNormal">That is perfect example to demonstrate the value of rust for EDKII.
<span style="font-family:Wingdings">J</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have a quick look at the code. Here is my thought:<o:p></o:p></p>
<p class="MsoNormal">1) about the "win64" usage.<o:p></o:p></p>
<p class="MsoNormal">I think this may break the compilation with other architecture such as IA32, and Linux environment.<o:p></o:p></p>
<p class="MsoNormal">I am not sure which target you use. If you use <span style="font-size:9.5pt;font-family:Consolas;color:black">
x86_64-unknown-uefi</span>, you may remove this flag.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">2) about integration test.<o:p></o:p></p>
<p class="MsoNormal">Besides unit test, we can also create the “tests” dir for integration test for more complicated function call.<o:p></o:p></p>
<p class="MsoNormal">That is also supported by rust language.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you<o:p></o:p></p>
<p class="MsoNormal">Yao Jiewen<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><a name="_____replyseparator"></a><b>From:</b> devel@edk2.groups.io <devel@edk2.groups.io>
<b>On Behalf Of </b>Bret Barkelew via Groups.Io<br>
<b>Sent:</b> Wednesday, January 15, 2020 9:56 AM<br>
<b>To:</b> devel@edk2.groups.io<br>
<b>Subject:</b> [edk2-devel] UnitTests + Rust = <3<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">What’s better than UnitTests almost being ready for deployment in TianoCore?<o:p></o:p></p>
<p class="MsoNormal">How about using those UnitTests to validate a native Rust port of one of our VarCheck libs?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Building upon Jiewen’s work (among others) I’ve finally managed to prototype a port of the UefiVariablePolicyLib to Rust, and have shown that it can build as part of our normal CI process and run the same UnitTests that are used for the
 C version…<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif"><a href="https://github.com/corthon/edk2-staging/tree/rust_and_tests" target="_blank" title="https://github.com/corthon/edk2-staging/tree/rust_and_tests">https://github.com/corthon/edk2-staging/tree/rust_and_tests</a><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">There is a Readme.md in the root directory with a “Notes for this branch” section. All of those steps are important to get Rust set up correctly.<o:p></o:p></p>
<p class="MsoNormal">You can run a CI build of MdeModulePkg with the “-t NOOPT” target and it will build the UnitTests. It will build one version against the C library, and another against the Rust library.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">You can also run native Rust test cases by going to <a href="https://github.com/corthon/edk2-staging/tree/rust_and_tests/MdeModulePkg/Library/UefiVariablePolicyLibRust">
https://github.com/corthon/edk2-staging/tree/rust_and_tests/MdeModulePkg/Library/UefiVariablePolicyLibRust</a><o:p></o:p></p>
<p class="MsoNormal">And running “cargo test”.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I acknowledge that this code is a little rough. It’s definitely a prototype, but one that I’m excited about and thing that it can be used as a pattern for interop with other core libraries.<o:p></o:p></p>
<p class="MsoNormal">I even found a couple small bugs in the original library through the process of porting to Rust, since Rust is so pedantic about covering all possible cases.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Anyway, super interested in any feedback or advice for improvement.
<span style="font-family:"Segoe UI Emoji",sans-serif">😊</span><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">- Bret<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">PS. Thanks again, Jiewen, for laying the groundwork. I’ve seen several of your contributions to Rust and the UEFI prototype while working on this.<o:p></o:p></p>
<div>
<p class="MsoNormal"></o:p></span></p>
</div>
</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/53254">View/Reply Online (#53254)</a> |


  


|


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