From b4520e459159781966d678cc0f65c8d295f523e4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 2 Jul 2022 12:26:00 -0400 Subject: [PATCH] test fs::read_link surface function --- tests/pass/fs.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/pass/fs.rs b/tests/pass/fs.rs index bc78cb560f00..e106ca5d02bb 100644 --- a/tests/pass/fs.rs +++ b/tests/pass/fs.rs @@ -8,7 +8,8 @@ extern crate libc; use std::ffi::CString; use std::fs::{ - create_dir, read_dir, remove_dir, remove_dir_all, remove_file, rename, File, OpenOptions, + create_dir, read_dir, read_link, remove_dir, remove_dir_all, remove_file, rename, File, + OpenOptions, }; use std::io::{Error, ErrorKind, Read, Result, Seek, SeekFrom, Write}; use std::path::{Path, PathBuf}; @@ -317,10 +318,12 @@ fn test_symlink() { assert_eq!(Error::last_os_error().kind(), ErrorKind::NotFound); } - // Test that metadata of a symbolic link is correct. + // Test that metadata of a symbolic link (i.e., the file it points to) is correct. check_metadata(bytes, &symlink_path).unwrap(); // Test that the metadata of a symbolic link is correct when not following it. assert!(symlink_path.symlink_metadata().unwrap().file_type().is_symlink()); + // Check that we can follow the link. + assert_eq!(read_link(&symlink_path).unwrap(), path); // Removing symbolic link should succeed. remove_file(&symlink_path).unwrap();