lscpu
: Improve tests a tiny bit
This commit is contained in:
parent
21706eb103
commit
95d57eb230
@ -17,12 +17,33 @@ fn test_hex() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
fn test_json() {
|
fn test_json() {
|
||||||
new_ucmd!()
|
let res = new_ucmd!().arg("--json").succeeds();
|
||||||
.arg("--json")
|
|
||||||
.succeeds()
|
let stdout = res.no_stderr().stdout_str();
|
||||||
// ensure some fields are there, non-exhausting
|
assert!(stdout.starts_with("{"));
|
||||||
.stdout_contains("\"lscpu\": [")
|
assert!(stdout.ends_with("}\n"));
|
||||||
|
|
||||||
|
res.stdout_contains("\"lscpu\": [")
|
||||||
.stdout_contains("\"field\": \"Architecture\"")
|
.stdout_contains("\"field\": \"Architecture\"")
|
||||||
.stdout_contains("\"field\": \"CPU(s)\"");
|
.stdout_contains("\"field\": \"CPU(s)\"")
|
||||||
|
.stdout_contains("\"children\": [");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
fn test_output() {
|
||||||
|
let res = new_ucmd!().succeeds();
|
||||||
|
let stdout = res.no_stderr().stdout_str();
|
||||||
|
|
||||||
|
// Non-exhaustive list of fields we expect
|
||||||
|
// This also checks that fields which should be indented, are indeed indented as excepted
|
||||||
|
assert!(stdout.contains("Architecture:"));
|
||||||
|
assert!(stdout.contains("\n Address sizes:"));
|
||||||
|
assert!(stdout.contains("\n Byte Order:"));
|
||||||
|
assert!(stdout.contains("\nCPU(s):"));
|
||||||
|
assert!(stdout.contains("\nVendor ID:"));
|
||||||
|
assert!(stdout.contains("\n Model name:"));
|
||||||
|
assert!(stdout.contains("\n CPU Family:"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user