Skip to content

Commit

Permalink
test: simplify dmesg test
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma-s1n committed Sep 28, 2023
1 parent d46c422 commit 92cef27
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions tests/cl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,16 @@ fn run_ls_modules() {
#[test]
#[cfg_attr(not(feature = "as-root"), ignore)]
fn run_dmesg() {
assert!(Uid::effective().is_root());
Command::cargo_bin(env!("CARGO_PKG_NAME"))
.unwrap()
.args(["run", "--", "dmesg"])
.unwrap()
.assert()
.success()
.stdout(predicate::str::contains("ProtectSystem=strict\n").count(1))
.stdout(predicate::str::contains(
if Uid::effective().is_root() {
"ProtectHome=tmpfs\n"
} else {
"ProtectHome=read-only\n"
}
).count(1))
.stdout(if !Uid::effective().is_root() && env::current_exe().unwrap().starts_with("/tmp") {
predicate::str::contains("PrivateTmp=true\n").count(0)
} else {
predicate::str::contains("PrivateTmp=true\n").count(1)
})
.stdout(predicate::str::contains("ProtectHome=tmpfs\n").count(1))
.stdout(predicate::str::contains("PrivateTmp=true\n").count(1))
.stdout(predicate::str::contains("PrivateDevices=").not())
.stdout(predicate::str::contains("ProtectKernelTunables=true\n").count(1))
.stdout(predicate::str::contains("ProtectKernelModules=true\n").count(1))
Expand Down

0 comments on commit 92cef27

Please sign in to comment.