-
Notifications
You must be signed in to change notification settings - Fork 41
Patina Dxe Core: Add a default environment based test logger #1093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patina Dxe Core: Add a default environment based test logger #1093
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
os-d
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default this won't log anything, right? Only if you pass --no-capture will the log have it? I'm worried about cluttering the log and slowing down tests if we do actual logging.
|
Are you sure we actually need a real logger here? I think we just need to make sure the {
let lvl = ::log::Level::Error;
if lvl <= ::log::STATIC_MAX_LEVEL
&& lvl <= ::log::max_level()
{
::log::__private_api::log(
{ ::log::__private_api::GlobalLogger },
format_args!(
"Error freeing previous MAT pointer: {0:#X?}",
err,
),
lvl,
&(
"patina_dxe_core::config_tables::memory_attributes_table",
"patina_dxe_core::config_tables::memory_attributes_table",
::log::__private_api::loc(),
),
(),
);
}
}Overall, I'm not against having a real logger, but realistically it should be unnecessary with the debugger on a host based system. |
That's correct. No logs without |
0179dd3 to
6c6ffd0
Compare
I still think there is value in have a real logger because it helps diagnose individual tests using |
6c6ffd0 to
6d4cd51
Compare
6d4cd51 to
7882bba
Compare
Since Patina relies on the `log::*` API for logging, not configuring a default
logger can cause `log::*` calls to appear completely uncovered in llvm-cov
reports, slightly reducing overall coverage. Adding a simple environment based
logger avoids this issue. Although this change enables coverage for `log::*`,
there are still cases that cannot be covered. For example, in the function
below, there is no way to get coverage for lines 6 and 7.
```
1 1 fn print() {
2 1 let mut i = 0;
3 11 for _ in 0..10 {
4 10 log::info!(
5 10 "This will be covered {} {}",
6 i,
7 "This and the above line will not be covered."
8 );
9 10 i = i + 1;
10 }
11 1 }
```
The environment logger can be enabled as shown below:
To enable logging, set the `RUST_LOG` environment variable to the desired
log level (e.g., `debug`, `info`, `warn`, `error`) before running the tests.
```bash
$ RUST_LOG=debug cargo test -p patina_dxe_core allocator::usage_tests::uefi_memory_map -- --nocapture
or
PS:> $env:RUST_LOG="debug"; cargo test -p patina_dxe_core allocator::usage_tests::uefi_memory_map -- --nocapture
```
For `cargo make coverage` a corresponding `Makefile.toml` change will be added
from patina-devops
```
[tasks.test]
description = "Run tests and collect coverage data without generating reports."
env = { "RUST_LOG" = "info" } <---
...
```
Signed-off-by: Vineel Kovvuri[MSFT] <vineelko@microsoft.com>
7882bba to
3e601b5
Compare
Description
Since Patina relies on the
log::*API for logging, not configuring a defaultlogger can cause
log::*calls to appear completely uncovered in llvm-covreports, slightly reducing overall coverage. Adding a simple environment based
logger avoids this issue. Although this change enables coverage for
log::*,there are still cases that cannot be covered. For example, in the function
below, there is no way to get coverage for lines 6 and 7.
The environment logger can be enabled as shown below:
To enable logging, set the
RUST_LOGenvironment variable to the desiredlog level (e.g.,
debug,info,warn,error) before running the tests.For
cargo make coveragea correspondingMakefile.tomlchange will be addedfrom patina-devops
How This Was Tested
cargo make allIntegration Instructions
NA