coreutils/tests/by-util/test_uptime.rs

31 lines
640 B
Rust
Raw Normal View History

2023-03-20 13:51:19 +00:00
use crate::common::util::TestScenario;
use regex::Regex;
2020-05-15 22:14:54 +00:00
#[test]
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
2020-05-15 22:14:54 +00:00
#[test]
fn test_uptime() {
2021-04-17 23:28:06 +00:00
TestScenario::new(util_name!())
.ucmd()
2021-04-17 23:28:06 +00:00
.succeeds()
.stdout_contains("load average:")
.stdout_contains(" up ");
2020-05-15 22:14:54 +00:00
// Don't check for users as it doesn't show in some CI
}
#[test]
fn test_uptime_since() {
let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}").unwrap();
2021-04-17 23:28:06 +00:00
new_ucmd!().arg("--since").succeeds().stdout_matches(&re);
}
#[test]
fn test_failed() {
new_ucmd!().arg("will-fail").fails();
}