summaryrefslogtreecommitdiffstats
path: root/vendor/rustix/tests/fs/long_paths.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/rustix/tests/fs/long_paths.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/tests/fs/long_paths.rs')
-rw-r--r--vendor/rustix/tests/fs/long_paths.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/rustix/tests/fs/long_paths.rs b/vendor/rustix/tests/fs/long_paths.rs
new file mode 100644
index 000000000..dbc2fa6ea
--- /dev/null
+++ b/vendor/rustix/tests/fs/long_paths.rs
@@ -0,0 +1,28 @@
+#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
+#[test]
+fn test_long_paths() {
+ use rustix::fs::{cwd, mkdirat, openat, Mode, OFlags};
+
+ let tmp = tempfile::tempdir().unwrap();
+ let dir = openat(cwd(), tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap();
+
+ #[cfg(libc)]
+ const PATH_MAX: usize = libc::PATH_MAX as usize;
+ #[cfg(linux_raw)]
+ const PATH_MAX: usize = linux_raw_sys::general::PATH_MAX as usize;
+
+ mkdirat(&dir, "a", Mode::RUSR | Mode::XUSR | Mode::WUSR).unwrap();
+
+ let mut long_path = String::new();
+ for _ in 0..PATH_MAX / 5 {
+ long_path.push_str("a/../");
+ }
+
+ let mut too_long_path = String::new();
+ for _ in 0..PATH_MAX / 4 {
+ too_long_path.push_str("a/../");
+ }
+
+ let _ = openat(&dir, &long_path, OFlags::RDONLY, Mode::empty()).unwrap();
+ let _ = openat(&dir, &too_long_path, OFlags::RDONLY, Mode::empty()).unwrap_err();
+}