setpgid: Add tool

This commit is contained in:
Tuomas Tynkkynen
2025-09-20 04:50:13 +03:00
parent 1e525d1ca3
commit 38bdf37fcd
8 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
// This file is part of the uutils util-linux package.
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use regex::Regex;
use uutests::new_ucmd;
#[test]
#[cfg(target_family = "unix")]
fn test_nonexistent_program() {
new_ucmd!()
.arg("does_not_exist")
.fails()
.stderr_contains("failed to execute");
}
#[test]
#[cfg(target_os = "linux")]
fn test_pgid_changed() {
let our_pgid = unsafe { libc::getpgid(0) };
// Gets pgid of the 'cut' process from /proc
new_ucmd!()
.args(&["cut", "-d", " ", "-f", "5", "/proc/self/stat"])
.succeeds()
.stdout_does_not_match(&Regex::new(&format!("^{}$", our_pgid)).unwrap());
}
#[test]
#[cfg(target_family = "unix")]
fn test_flag_after_command() {
new_ucmd!()
.arg("echo")
.arg("-f")
.succeeds()
.stdout_is("-f\n");
}

View File

@@ -55,6 +55,10 @@ mod test_renice;
#[path = "by-util/test_rev.rs"]
mod test_rev;
#[cfg(feature = "setpgid")]
#[path = "by-util/test_setpgid.rs"]
mod test_setpgid;
#[cfg(feature = "setsid")]
#[path = "by-util/test_setsid.rs"]
mod test_setsid;