Skip to content

Commit

Permalink
fix(tests): dmesg tests depending on system logs
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma committed Feb 3, 2025
1 parent 407876f commit ed7f5cf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ thiserror = { version = "2.0.11", default-features = false, features = ["std"] }
assert_cmd = { version = "2.0.16", default-features = false, features = ["color", "color-auto"] }
fastrand = { version = "2.3.0", default-features = false, features = ["std"] }
nix = { version = "0.29.0", default-features = false, features = ["user"] }
predicates = { version = "3.1.3", default-features = false, features = ["color"] }
predicates = { version = "3.1.3", default-features = false, features = ["color", "regex"] }
pretty_assertions = { version = "1.4.1", default-features = false, features = ["std"] }

[features]
Expand Down
5 changes: 3 additions & 2 deletions tests/systemd-run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use assert_cmd::{
use predicates::prelude::predicate;

static ALL_SHH_RUN_OPTS: LazyLock<Vec<Vec<&'static str>>> = LazyLock::new(all_shh_run_opts);
const KERNEL_LOG_REGEX: &str = r"\[\ *[0-9]+\.[0-9]+\] ";

/// Run `shh run` for a given command, and return generated systemd options
fn generate_options(cmd: &[&str], run_opts: &[&str]) -> Vec<String> {
Expand Down Expand Up @@ -176,7 +177,7 @@ fn systemd_run_dmesg() {
for shh_opts in &*ALL_SHH_RUN_OPTS {
let sd_opts = generate_options(&cmd, shh_opts);
let asrt = systemd_run(&cmd, &sd_opts);
asrt.stdout(predicate::str::contains("0.000000] Linux version"));
asrt.stdout(predicate::str::is_match(KERNEL_LOG_REGEX).unwrap());
}
}

Expand Down Expand Up @@ -251,7 +252,7 @@ fn systemd_run_syslog() {
for shh_opts in &*ALL_SHH_RUN_OPTS {
let sd_opts = generate_options(&cmd, shh_opts);
let asrt = systemd_run(&cmd, &sd_opts);
asrt.stdout(predicate::str::contains("0.000000] Linux version"));
asrt.stdout(predicate::str::is_match(KERNEL_LOG_REGEX).unwrap());
}
}

Expand Down

0 comments on commit ed7f5cf

Please sign in to comment.