Skip to content

Commit

Permalink
PR feedback, formatting, fix doctest errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zurcher committed Nov 26, 2024
1 parent 918e899 commit 691d627
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
2 changes: 0 additions & 2 deletions MsWheaPkg/Crates/RustMuTelemetryHelperLib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ boot_services = { workspace = true }
mu_pi = { workspace = true }
mu_rust_helpers = { workspace = true }
r-efi = { workspace = true }
RustAdvancedLoggerDxe = { workspace = true }
uuid = { workspace = true }

[dev-dependencies]
boot_services = { workspace = true, features = ["mockall"] }
RustAdvancedLoggerDxe = { workspace = true, features = ["std"] }
mockall = { version = "0.13.0" }

[lints.rust]
Expand Down
27 changes: 13 additions & 14 deletions MsWheaPkg/Crates/RustMuTelemetryHelperLib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@
//!
//! ```no_run
//! use rust_mu_telemetry_helper_lib::{init_telemetry, log_telemetry};
//! use r_efi::efi;
//! use r_efi::{efi, system};
//! pub extern "efiapi" fn efi_main(
//! _image_handle: efi::Handle,
//! system_table: *const system::SystemTable,
//! ) -> efi::Status {
//!
//! //Initialize Boot Services
//! init_telemetry((*system_table).boot_services.as_ref().unwrap());
//! unsafe {
//! init_telemetry((*system_table).boot_services.as_ref().unwrap());
//! }
//!
//! if (some_failure) {
//! //if (some_failure) {
//! let _ = log_telemetry(false, 0xA1A2A3A4, 0xB1B2B3B4B5B6B7B8, 0xC1C2C3C4C5C6C7C8, None, None, None);
//! }
//! //}
//!
//! efi::Status::SUCCESS
//! }
//! ```
//!
//! ## License
//!
//! Copyright (C) Microsoft Corporation. All rights reserved.
//! Copyright (C) Microsoft Corporation.
//!
//! SPDX-License-Identifier: BSD-2-Clause-Patent
//!
Expand Down Expand Up @@ -158,15 +161,13 @@ mod test {
use boot_services::MockBootServices;
use mu_pi::protocols::status_code;
use mu_pi::protocols::status_code::{EfiStatusCodeData, EfiStatusCodeType, EfiStatusCodeValue};
use mu_rust_helpers::guid::{guid, guid_fmt};
use mu_rust_helpers::guid::guid;
use r_efi::efi;
use rust_advanced_logger_dxe::{debugln, DEBUG_INFO};
use uuid::uuid;

use crate::{
log_telemetry_internal,
status_code_runtime::StatusCodeRuntimeProtocol,
MsWheaRscInternalErrorData, MS_WHEA_ERROR_STATUS_TYPE_FATAL,
log_telemetry_internal, status_code_runtime::StatusCodeRuntimeProtocol, MsWheaRscInternalErrorData,
MS_WHEA_ERROR_STATUS_TYPE_FATAL,
};
use core::mem::size_of;

Expand All @@ -185,12 +186,11 @@ mod test {
assert_eq!(value, MOCK_STATUS_CODE_VALUE);
assert_eq!(instance, 0);
assert_eq!(unsafe { *caller_id }, MOCK_CALLER_ID);
debugln!(DEBUG_INFO, "[MockStatusCodeRuntime] caller_id: {}", guid_fmt!(unsafe { *caller_id }));
efi::Status::SUCCESS
}

static MOCK_STATUS_CODE_RUNTIME_INTERFACE: status_code::Protocol =
status_code::Protocol { report_status_code: mock_report_status_code };
status_code::Protocol { report_status_code: mock_report_status_code };

#[test]
fn try_log_telemetry() {
Expand All @@ -199,8 +199,7 @@ mod test {
mock_boot_services.expect_locate_protocol().returning(|_: &StatusCodeRuntimeProtocol, registration| unsafe {
assert_eq!(registration, None);
Ok(Some(
(&MOCK_STATUS_CODE_RUNTIME_INTERFACE as *const status_code::Protocol
as *mut status_code::Protocol)
(&MOCK_STATUS_CODE_RUNTIME_INTERFACE as *const status_code::Protocol as *mut status_code::Protocol)
.as_mut()
.unwrap(),
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use mu_pi::protocols::status_code;
use mu_pi::protocols::status_code::{EfiStatusCodeData, EfiStatusCodeType, EfiStatusCodeValue};
use mu_rust_helpers::guid;
use r_efi::efi;
use rust_advanced_logger_dxe::{debugln, DEBUG_INFO};

pub struct StatusCodeRuntimeProtocol;

Expand Down Expand Up @@ -71,8 +70,6 @@ impl ReportStatusCode for StatusCodeRuntimeProtocol {

let caller_id = caller_id.or(Some(&guid::CALLER_ID)).unwrap();

debugln!(DEBUG_INFO, "[RustStatusCodeRuntime] caller_id: {}", guid::guid_fmt!(caller_id));

let status =
(protocol.unwrap().report_status_code)(status_code_type, status_code_value, instance, caller_id, data_ptr);

Expand Down

0 comments on commit 691d627

Please sign in to comment.