public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* UnitTests + Rust = <3
@ 2020-01-15  1:56 Bret Barkelew
  2020-01-15  2:44 ` Yao, Jiewen
  0 siblings, 1 reply; 2+ messages in thread
From: Bret Barkelew @ 2020-01-15  1:56 UTC (permalink / raw)
  To: devel@edk2.groups.io

[-- Attachment #1: Type: text/plain, Size: 1622 bytes --]

What’s better than UnitTests almost being ready for deployment in TianoCore?
How about using those UnitTests to validate a native Rust port of one of our VarCheck libs?

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…
https://github.com/corthon/edk2-staging/tree/rust_and_tests

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.
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.

You can also run native Rust test cases by going to https://github.com/corthon/edk2-staging/tree/rust_and_tests/MdeModulePkg/Library/UefiVariablePolicyLibRust
And running “cargo test”.

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.
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.

Anyway, super interested in any feedback or advice for improvement. 😊

- Bret

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.

[-- Attachment #2: Type: text/html, Size: 4109 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: UnitTests + Rust = <3
  2020-01-15  1:56 UnitTests + Rust = <3 Bret Barkelew
@ 2020-01-15  2:44 ` Yao, Jiewen
  0 siblings, 0 replies; 2+ messages in thread
From: Yao, Jiewen @ 2020-01-15  2:44 UTC (permalink / raw)
  To: devel@edk2.groups.io, bret.barkelew@microsoft.com

[-- Attachment #1: Type: text/plain, Size: 2565 bytes --]

HI Bret
That is awesome.
I am also excited to see that.

I really like the rust unit test idea because the framework is embedded in the language and compiler.
That is perfect example to demonstrate the value of rust for EDKII. ☺

I have a quick look at the code. Here is my thought:
1) about the "win64" usage.
I think this may break the compilation with other architecture such as IA32, and Linux environment.
I am not sure which target you use. If you use x86_64-unknown-uefi, you may remove this flag.

2) about integration test.
Besides unit test, we can also create the “tests” dir for integration test for more complicated function call.
That is also supported by rust language.

Thank you
Yao Jiewen

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bret Barkelew via Groups.Io
Sent: Wednesday, January 15, 2020 9:56 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] UnitTests + Rust = <3

What’s better than UnitTests almost being ready for deployment in TianoCore?
How about using those UnitTests to validate a native Rust port of one of our VarCheck libs?

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…
https://github.com/corthon/edk2-staging/tree/rust_and_tests

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.
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.

You can also run native Rust test cases by going to https://github.com/corthon/edk2-staging/tree/rust_and_tests/MdeModulePkg/Library/UefiVariablePolicyLibRust
And running “cargo test”.

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.
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.

Anyway, super interested in any feedback or advice for improvement. 😊

- Bret

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.


[-- Attachment #2: Type: text/html, Size: 7419 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-15  2:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-15  1:56 UnitTests + Rust = <3 Bret Barkelew
2020-01-15  2:44 ` Yao, Jiewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox