Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfacc7c5

Browse files
committed
tail: add test for tailing from end of device
1 parent24a556b commitfacc7c5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎tests/by-util/test_tail.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ use uutests::util::expected_result;
6464
#[cfg(unix)]
6565
#[cfg(not(windows))]
6666
use uutests::util::is_ci;
67+
#[cfg(target_os ="linux")]
68+
use uutests::util::run_ucmd_as_root;
6769
use uutests::util_name;
6870

6971
constFOOBAR_TXT:&str ="foobar.txt";
@@ -4946,3 +4948,30 @@ fn test_dev_zero() {
49464948
.succeeds()
49474949
.stdout_only("\0");
49484950
}
4951+
4952+
#[cfg(target_os ="linux")]
4953+
#[cfg(feature ="df")]
4954+
#[test]
4955+
fntest_end_of_device(){
4956+
let ts =TestScenario::new(util_name!());
4957+
4958+
// Determine the device of the current working directory
4959+
let result = ts
4960+
.cmd("df")
4961+
.args(&[".","--output=source","--local"])
4962+
.succeeds();
4963+
4964+
// The output of `df` had a header line, we need the second line
4965+
ifletSome(device) = result.stdout_str().lines().nth(1){
4966+
// read backwards 8 bytes from the end of the device
4967+
ifletOk(result) =run_ucmd_as_root(&ts,&["-c","8", device]){
4968+
result.success();
4969+
result.no_stderr();
4970+
assert_eq!(result.stdout().len(),8);
4971+
}else{
4972+
print!("Test skipped; requires root user");
4973+
}
4974+
}else{
4975+
print!("Test skipped; could not determine device of current working directory");
4976+
}
4977+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp