Skip to content

Commit

Permalink
rewrite arg0_passed tests so it is clearer they are focussed on the d…
Browse files Browse the repository at this point in the history
…irectory hierarchy
  • Loading branch information
squell committed Nov 28, 2024
1 parent 87e51e9 commit 1060010
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions test-framework/sudo-compliance-tests/src/sudo/path_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,12 @@ fn arg0_native_is_passed_from_commandline() -> Result<()> {
let output = Command::new("sh")
.args([
"-c",
"ln -s /bin/ls /bin/foo; sudo /bin/foo --invalid-flag; true",
"ln -s /bin /nib; sudo /nib/sleep --invalid-flag; true",
])
.output(&env)?;

let mut stderr = output.stderr();
// On GNU, this will report "/bin/foo: ...". but FreeBSD's `ls` does not print its full invoked path in error
if stderr.starts_with("/bin/") {
stderr = &stderr[5..]
}
assert_starts_with!(stderr, "foo: unrecognized option");
let stderr = output.stderr();
assert_starts_with!(stderr, "/nib/sleep:");

Ok(())
}
Expand Down Expand Up @@ -162,11 +158,11 @@ fn arg0_script_is_passed_from_commandline() -> Result<()> {
.build()?;

let output = Command::new("sh")
.args(["-c", &format!("ln -s {path} /bin/foo; sudo /bin/foo")])
.args(["-c", "ln -s /bin /nib; sudo /nib/my-script"])
.output(&env)?;

let stdout = output.stdout()?;
assert_eq!(stdout, "/bin/foo");
assert_eq!(stdout, "/nib/my-script");

Ok(())
}
Expand Down

0 comments on commit 1060010

Please sign in to comment.