mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Add initial tests for realpath.
This commit is contained in:
parent
4aed2eafa8
commit
23cb9541e7
2 changed files with 47 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -178,6 +178,7 @@ TEST_PROGS := \
|
|||
ptx \
|
||||
pwd \
|
||||
readlink \
|
||||
realpath \
|
||||
rm \
|
||||
seq \
|
||||
sort \
|
||||
|
|
46
test/realpath.rs
Normal file
46
test/realpath.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use std::process::Command;
|
||||
use std::str;
|
||||
use util::*;
|
||||
|
||||
static PROGNAME: &'static str = "./realpath";
|
||||
|
||||
#[path = "common/util.rs"]
|
||||
#[macro_use]
|
||||
mod util;
|
||||
|
||||
#[test]
|
||||
fn test_current_directory() {
|
||||
let po = Command::new(PROGNAME)
|
||||
.arg(".")
|
||||
.output()
|
||||
.unwrap_or_else(|err| panic!("{}", err));
|
||||
|
||||
let out = str::from_utf8(&po.stdout[..]).unwrap().trim_right();
|
||||
assert_eq!(out, current_directory());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_long_redirection_to_current_dir() {
|
||||
// Create a 256-character path to current directory
|
||||
let dir = repeat_str("./", 128);
|
||||
let po = Command::new(PROGNAME)
|
||||
.arg(dir)
|
||||
.output()
|
||||
.unwrap_or_else(|err| panic!("{}", err));
|
||||
|
||||
let out = str::from_utf8(&po.stdout[..]).unwrap().trim_right();
|
||||
assert_eq!(out, current_directory());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_long_redirection_to_root() {
|
||||
// Create a 255-character path to root
|
||||
let dir = repeat_str("../", 85);
|
||||
let po = Command::new(PROGNAME)
|
||||
.arg(dir)
|
||||
.output()
|
||||
.unwrap_or_else(|err| panic!("{}", err));
|
||||
|
||||
let out = str::from_utf8(&po.stdout[..]).unwrap().trim_right();
|
||||
assert_eq!(out, "/");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue