mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 20:47:46 +00:00
nproc: support --ignore=' 1' as GNU
This commit is contained in:
parent
bfd1e14137
commit
2c6bbcf716
2 changed files with 11 additions and 4 deletions
|
@ -33,7 +33,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let matches = uu_app().get_matches_from(args);
|
let matches = uu_app().get_matches_from(args);
|
||||||
|
|
||||||
let mut ignore = match matches.value_of(OPT_IGNORE) {
|
let mut ignore = match matches.value_of(OPT_IGNORE) {
|
||||||
Some(numstr) => match numstr.parse() {
|
Some(numstr) => match numstr.trim().parse() {
|
||||||
Ok(num) => num,
|
Ok(num) => num,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(USimpleError::new(
|
return Err(USimpleError::new(
|
||||||
|
|
|
@ -33,15 +33,22 @@ fn test_nproc_all_omp() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nproc_ignore() {
|
fn test_nproc_ignore() {
|
||||||
let result = new_ucmd!().succeeds();
|
let result = new_ucmd!().succeeds();
|
||||||
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
|
let nproc_total: u8 = result.stdout_str().trim().parse().unwrap();
|
||||||
if nproc > 1 {
|
if nproc_total > 1 {
|
||||||
// Ignore all CPU but one
|
// Ignore all CPU but one
|
||||||
let result = TestScenario::new(util_name!())
|
let result = TestScenario::new(util_name!())
|
||||||
.ucmd_keepenv()
|
.ucmd_keepenv()
|
||||||
.arg("--ignore")
|
.arg("--ignore")
|
||||||
.arg((nproc - 1).to_string())
|
.arg((nproc_total - 1).to_string())
|
||||||
.succeeds();
|
.succeeds();
|
||||||
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
|
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
|
||||||
assert!(nproc == 1);
|
assert!(nproc == 1);
|
||||||
|
// Ignore all CPU but one with a string
|
||||||
|
let result = TestScenario::new(util_name!())
|
||||||
|
.ucmd_keepenv()
|
||||||
|
.arg("--ignore= 1")
|
||||||
|
.succeeds();
|
||||||
|
let nproc: u8 = result.stdout_str().trim().parse().unwrap();
|
||||||
|
assert!(nproc_total - 1 == nproc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue