use nextest_metadata::{RustBinaryId, TestCaseName};
use quick_junit::ReportUuid;
use serde::Serialize;
#[cfg(all(
feature = "usdt",
any(
all(
target_arch = "x86_64",
any(target_os = "linux", target_os = "freebsd", target_os = "illumos")
),
all(
target_arch = "aarch64",
any(target_os = "macos", target_os = "freebsd", target_os = "illumos")
)
)
))]
pub fn register_probes() -> Result<(), usdt::Error> {
usdt::register_probes()
}
#[cfg(not(all(
feature = "usdt",
any(
all(
target_arch = "x86_64",
any(target_os = "linux", target_os = "freebsd", target_os = "illumos")
),
all(
target_arch = "aarch64",
any(target_os = "macos", target_os = "freebsd", target_os = "illumos")
)
)
)))]
pub fn register_probes() -> Result<(), std::convert::Infallible> {
Ok(())
}
#[cfg(all(
feature = "usdt",
any(
all(
target_arch = "x86_64",
any(target_os = "linux", target_os = "freebsd", target_os = "illumos")
),
all(
target_arch = "aarch64",
any(target_os = "macos", target_os = "freebsd", target_os = "illumos")
)
)
))]
#[usdt::provider(provider = "nextest")]
pub mod usdt_probes {
use crate::usdt::*;
pub fn test__attempt__start(
attempt: &UsdtTestAttemptStart,
attempt_id: &str,
binary_id: &str,
test_name: &str,
pid: u32,
) {
}
pub fn test__attempt__done(
attempt: &UsdtTestAttemptDone,
attempt_id: &str,
binary_id: &str,
test_name: &str,
result: &str,
duration_nanos: u64,
) {
}
pub fn test__attempt__slow(
slow: &UsdtTestAttemptSlow,
attempt_id: &str,
binary_id: &str,
test_name: &str,
elapsed_nanos: u64,
) {
}
pub fn setup__script__start(
script: &UsdtSetupScriptStart,
id: &str,
script_id: &str,
pid: u32,
) {
}
pub fn setup__script__slow(
script: &UsdtSetupScriptSlow,
id: &str,
script_id: &str,
elapsed_nanos: u64,
) {
}
pub fn setup__script__done(
script: &UsdtSetupScriptDone,
id: &str,
script_id: &str,
result: &str,
duration_nanos: u64,
) {
}
pub fn run__start(run: &UsdtRunStart, run_id: ReportUuid) {}
pub fn run__done(run: &UsdtRunDone, run_id: ReportUuid) {}
pub fn stress__sub__run__start(
sub_run: &UsdtStressSubRunStart,
stress_sub_run_id: &str,
stress_current: u32,
) {
}
pub fn stress__sub__run__done(
sub_run: &UsdtStressSubRunDone,
stress_sub_run_id: &str,
stress_current: u32,
) {
}
}
#[cfg(all(
feature = "usdt",
any(
all(
target_arch = "x86_64",
any(target_os = "linux", target_os = "freebsd", target_os = "illumos")
),
all(
target_arch = "aarch64",
any(target_os = "macos", target_os = "freebsd", target_os = "illumos")
)
)
))]
#[macro_export]
macro_rules! fire_usdt {
(UsdtTestAttemptStart { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::test__attempt__start!(|| {
let probe = $crate::usdt::UsdtTestAttemptStart { $($tt)* };
let attempt_id = probe.attempt_id.clone();
let binary_id = probe.binary_id.to_string();
let test_name = probe.test_name.clone();
let pid = probe.pid;
(probe, attempt_id, binary_id, test_name, pid)
})
}};
(UsdtTestAttemptDone { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::test__attempt__done!(|| {
let probe = $crate::usdt::UsdtTestAttemptDone { $($tt)* };
let attempt_id = probe.attempt_id.clone();
let binary_id = probe.binary_id.to_string();
let test_name = probe.test_name.clone();
let result = probe.result;
let duration_nanos = probe.duration_nanos;
(
probe,
attempt_id,
binary_id,
test_name,
result,
duration_nanos,
)
})
}};
(UsdtTestAttemptSlow { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::test__attempt__slow!(|| {
let probe = $crate::usdt::UsdtTestAttemptSlow { $($tt)* };
let attempt_id = probe.attempt_id.clone();
let binary_id = probe.binary_id.to_string();
let test_name = probe.test_name.clone();
let elapsed_nanos = probe.elapsed_nanos;
(probe, attempt_id, binary_id, test_name, elapsed_nanos)
})
}};
(UsdtSetupScriptStart { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::setup__script__start!(|| {
let probe = $crate::usdt::UsdtSetupScriptStart { $($tt)* };
let id = probe.id.clone();
let script_id = probe.script_id.clone();
let pid = probe.pid;
(probe, id, script_id, pid)
})
}};
(UsdtSetupScriptSlow { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::setup__script__slow!(|| {
let probe = $crate::usdt::UsdtSetupScriptSlow { $($tt)* };
let id = probe.id.clone();
let script_id = probe.script_id.clone();
let elapsed_nanos = probe.elapsed_nanos;
(probe, id, script_id, elapsed_nanos)
})
}};
(UsdtSetupScriptDone { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::setup__script__done!(|| {
let probe = $crate::usdt::UsdtSetupScriptDone { $($tt)* };
let id = probe.id.clone();
let script_id = probe.script_id.clone();
let result = probe.result;
let duration_nanos = probe.duration_nanos;
(probe, id, script_id, result, duration_nanos)
})
}};
(UsdtRunStart { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::run__start!(|| {
let probe = $crate::usdt::UsdtRunStart { $($tt)* };
let run_id = probe.run_id;
(probe, run_id)
})
}};
(UsdtRunDone { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::run__done!(|| {
let probe = $crate::usdt::UsdtRunDone { $($tt)* };
let run_id = probe.run_id;
(probe, run_id)
})
}};
(UsdtStressSubRunStart { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::stress__sub__run__start!(|| {
let probe = $crate::usdt::UsdtStressSubRunStart { $($tt)* };
let stress_sub_run_id = probe.stress_sub_run_id.clone();
let stress_current = probe.stress_current;
(probe, stress_sub_run_id, stress_current)
})
}};
(UsdtStressSubRunDone { $($tt:tt)* }) => {{
$crate::usdt::usdt_probes::stress__sub__run__done!(|| {
let probe = $crate::usdt::UsdtStressSubRunDone { $($tt)* };
let stress_sub_run_id = probe.stress_sub_run_id.clone();
let stress_current = probe.stress_current;
(probe, stress_sub_run_id, stress_current)
})
}};
}
#[cfg(not(all(
feature = "usdt",
any(
all(
target_arch = "x86_64",
any(target_os = "linux", target_os = "freebsd", target_os = "illumos")
),
all(
target_arch = "aarch64",
any(target_os = "macos", target_os = "freebsd", target_os = "illumos")
)
)
)))]
#[macro_export]
macro_rules! fire_usdt {
($($tt:tt)*) => {
let _ = $crate::usdt::$($tt)*;
};
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtTestAttemptStart {
pub attempt_id: String,
pub run_id: ReportUuid,
pub binary_id: RustBinaryId,
pub test_name: TestCaseName,
pub pid: u32,
pub program: String,
pub args: Vec<String>,
pub attempt: u32,
pub total_attempts: u32,
pub stress_current: Option<u32>,
pub stress_total: Option<u32>,
pub global_slot: u64,
pub group_slot: Option<u64>,
pub test_group: Option<String>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtTestAttemptDone {
pub attempt_id: String,
pub run_id: ReportUuid,
pub binary_id: RustBinaryId,
pub test_name: TestCaseName,
pub attempt: u32,
pub total_attempts: u32,
pub result: &'static str,
pub exit_code: Option<i32>,
pub duration_nanos: u64,
pub leaked: bool,
pub time_to_close_fds_nanos: Option<u64>,
pub stress_current: Option<u32>,
pub stress_total: Option<u32>,
pub stdout_len: Option<u64>,
pub stderr_len: Option<u64>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtTestAttemptSlow {
pub attempt_id: String,
pub run_id: ReportUuid,
pub binary_id: RustBinaryId,
pub test_name: TestCaseName,
pub attempt: u32,
pub total_attempts: u32,
pub elapsed_nanos: u64,
pub will_terminate: bool,
pub stress_current: Option<u32>,
pub stress_total: Option<u32>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtSetupScriptStart {
pub id: String,
pub run_id: ReportUuid,
pub script_id: String,
pub pid: u32,
pub program: String,
pub args: Vec<String>,
pub stress_current: Option<u32>,
pub stress_total: Option<u32>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtSetupScriptSlow {
pub id: String,
pub run_id: ReportUuid,
pub script_id: String,
pub program: String,
pub args: Vec<String>,
pub elapsed_nanos: u64,
pub will_terminate: bool,
pub stress_current: Option<u32>,
pub stress_total: Option<u32>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtSetupScriptDone {
pub id: String,
pub run_id: ReportUuid,
pub script_id: String,
pub program: String,
pub args: Vec<String>,
pub result: &'static str,
pub exit_code: Option<i32>,
pub duration_nanos: u64,
pub stress_current: Option<u32>,
pub stress_total: Option<u32>,
pub stdout_len: Option<u64>,
pub stderr_len: Option<u64>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtRunStart {
pub run_id: ReportUuid,
pub profile_name: String,
pub total_tests: usize,
pub filter_count: usize,
pub test_threads: usize,
pub stress_count: Option<u32>,
pub stress_infinite: bool,
pub stress_duration_nanos: Option<u64>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtRunDone {
pub run_id: ReportUuid,
pub profile_name: String,
pub total_tests: usize,
pub passed: usize,
pub failed: usize,
pub skipped: usize,
pub duration_nanos: u64,
pub paused_nanos: u64,
pub stress_completed: Option<u32>,
pub stress_success: Option<u32>,
pub stress_failed: Option<u32>,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtStressSubRunStart {
pub stress_sub_run_id: String,
pub run_id: ReportUuid,
pub profile_name: String,
pub stress_current: u32,
pub stress_total: Option<u32>,
pub elapsed_nanos: u64,
}
#[derive(Clone, Debug, Serialize)]
pub struct UsdtStressSubRunDone {
pub stress_sub_run_id: String,
pub run_id: ReportUuid,
pub profile_name: String,
pub stress_current: u32,
pub stress_total: Option<u32>,
pub elapsed_nanos: u64,
pub sub_run_duration_nanos: u64,
pub total_tests: usize,
pub passed: usize,
pub failed: usize,
pub skipped: usize,
}