summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSendil Kumar <sendilkumarn@live.com>2019-08-22 20:50:13 +0200
committerSendil Kumar <sendilkumarn@live.com>2019-08-22 20:50:13 +0200
commite7433361a4312a04be7a9d0250fffb99bfce45bc (patch)
tree6bfbc2f123063f52efd517ad95cde742239f83c3 /test
parentea102096803dd12acf5fc592fb5c581e9b9ff51d (diff)
downloadnix-e7433361a4312a04be7a9d0250fffb99bfce45bc.zip
update readlink to return the path instead of mangling the buffer
Diffstat (limited to 'test')
-rw-r--r--test/test_fcntl.rs16
-rw-r--r--test/test_unistd.rs5
2 files changed, 4 insertions, 17 deletions
diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs
index c8773219..1bcf12cb 100644
--- a/test/test_fcntl.rs
+++ b/test/test_fcntl.rs
@@ -58,20 +58,8 @@ fn test_readlink() {
Mode::empty()).unwrap();
let expected_dir = src.to_str().unwrap();
- // When the size of the buffer is bigger than the expected directory length
- let mut buf = vec![0; src.to_str().unwrap().len() + 1];
- assert_eq!(readlink(&dst, &mut buf).unwrap().to_str().unwrap(), expected_dir);
- assert_eq!(readlinkat(dirfd, "b", &mut buf).unwrap().to_str().unwrap(), expected_dir);
-
- // When the size of the buffer is equal to the expected directory length
- let mut exact_buf = vec![0; src.to_str().unwrap().len()];
- assert_eq!(readlink(&dst, &mut exact_buf).unwrap().to_str().unwrap(), expected_dir);
- assert_eq!(readlinkat(dirfd, "b", &mut exact_buf).unwrap().to_str().unwrap(), expected_dir);
-
- // When the size of the buffer is smaller than the expected directory length
- let mut small_buf = vec![0;0];
- assert_eq!(readlink(&dst, &mut small_buf).unwrap().to_str().unwrap(), "");
- assert_eq!(readlinkat(dirfd, "b", &mut small_buf).unwrap().to_str().unwrap(), "");
+ assert_eq!(readlink(&dst).unwrap().to_str().unwrap(), expected_dir);
+ assert_eq!(readlinkat(dirfd, "b").unwrap().to_str().unwrap(), expected_dir);
}
diff --git a/test/test_unistd.rs b/test/test_unistd.rs
index 46196dec..e1e03f3f 100644
--- a/test/test_unistd.rs
+++ b/test/test_unistd.rs
@@ -576,14 +576,13 @@ fn test_canceling_alarm() {
#[test]
fn test_symlinkat() {
- let mut buf = [0; 1024];
let tempdir = tempfile::tempdir().unwrap();
let target = tempdir.path().join("a");
let linkpath = tempdir.path().join("b");
symlinkat(&target, None, &linkpath).unwrap();
assert_eq!(
- readlink(&linkpath, &mut buf).unwrap().to_str().unwrap(),
+ readlink(&linkpath).unwrap().to_str().unwrap(),
target.to_str().unwrap()
);
@@ -592,7 +591,7 @@ fn test_symlinkat() {
let linkpath = "d";
symlinkat(target, Some(dirfd), linkpath).unwrap();
assert_eq!(
- readlink(&tempdir.path().join(linkpath), &mut buf)
+ readlink(&tempdir.path().join(linkpath))
.unwrap()
.to_str()
.unwrap(),