Skip to content

Commit c65bb00

Browse files
committed
vmstat: add tests
1 parent 995013e commit c65bb00

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/uu/vmstat/src/picker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub fn get_pickers(matches: &ArgMatches) -> Vec<Picker> {
6565
]
6666
}
6767

68+
#[cfg(target_os = "linux")]
6869
fn with_unit(x: u64, arg: &ArgMatches) -> u64 {
6970
if let Some(unit) = arg.get_one::<String>("unit") {
7071
return match unit.as_str() {

src/uu/vmstat/src/vmstat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod picker;
88

99
#[cfg(target_os = "linux")]
1010
use crate::picker::{get_pickers, Picker};
11+
#[allow(unused_imports)]
1112
use clap::{arg, crate_version, ArgMatches, Command};
1213
#[allow(unused_imports)]
1314
pub use parser::*;

tests/by-util/test_vmstat.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ fn test_simple() {
1616
fn test_invalid_arg() {
1717
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
1818
}
19+
20+
#[test]
21+
fn test_unit() {
22+
new_ucmd!().args(&["-S", "M"]).succeeds();
23+
}
24+
25+
#[test]
26+
#[cfg(target_os = "linux")]
27+
fn test_invalid_unit() {
28+
new_ucmd!().args(&["-S", "x"]).fails().code_is(1);
29+
}

0 commit comments

Comments
 (0)