setpgid: Add tool
This commit is contained in:
37
tests/by-util/test_setpgid.rs
Normal file
37
tests/by-util/test_setpgid.rs
Normal 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");
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user