From 92cef27df1ba6d6419e8fbe6fa127fa0339ead39 Mon Sep 17 00:00:00 2001 From: desbma-s1n Date: Thu, 28 Sep 2023 18:39:41 +0200 Subject: [PATCH] test: simplify dmesg test --- tests/cl.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/tests/cl.rs b/tests/cl.rs index 08fceb9..60f2d67 100644 --- a/tests/cl.rs +++ b/tests/cl.rs @@ -215,6 +215,7 @@ 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"]) @@ -222,18 +223,8 @@ fn run_dmesg() { .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))