diff --git a/src/backend/libc/fs/dir.rs b/src/backend/libc/fs/dir.rs index 0df1ea1b5..a9508b933 100644 --- a/src/backend/libc/fs/dir.rs +++ b/src/backend/libc/fs/dir.rs @@ -393,5 +393,5 @@ fn dir_iterator_handles_io_errors() { } assert!(matches!(dir.next(), Some(Err(_)))); - assert!(matches!(dir.next(), None)); + assert!(dir.next().is_none()); } diff --git a/src/backend/linux_raw/arch/x86.rs b/src/backend/linux_raw/arch/x86.rs index 581cde278..e789181cc 100644 --- a/src/backend/linux_raw/arch/x86.rs +++ b/src/backend/linux_raw/arch/x86.rs @@ -148,10 +148,10 @@ pub(in crate::backend) unsafe fn indirect_syscall5( // clobbered as the return value anyway. asm!( "push esi", - "push DWORD PTR [eax + 0]", - "mov esi, DWORD PTR [eax + 4]", - "mov eax, DWORD PTR [eax + 8]", - "call DWORD PTR [esp]", + "push [eax + 0]", + "mov esi, [eax + 4]", + "mov eax, [eax + 8]", + "call [esp]", "pop esi", "pop esi", inout("eax") &[callee as _, a3.to_asm(), nr.to_asm()] => r0, @@ -186,11 +186,11 @@ pub(in crate::backend) unsafe fn indirect_syscall6( asm!( "push ebp", "push esi", - "push DWORD PTR [eax + 0]", - "mov esi, DWORD PTR [eax + 4]", - "mov ebp, DWORD PTR [eax + 8]", - "mov eax, DWORD PTR [eax + 12]", - "call DWORD PTR [esp]", + "push [eax + 0]", + "mov esi, [eax + 4]", + "mov ebp, [eax + 8]", + "mov eax, [eax + 12]", + "call [esp]", "pop esi", "pop esi", "pop ebp", @@ -441,9 +441,9 @@ pub(in crate::backend) unsafe fn syscall6( asm!( "push ebp", "push esi", - "mov esi, DWORD PTR [eax + 0]", - "mov ebp, DWORD PTR [eax + 4]", - "mov eax, DWORD PTR [eax + 8]", + "mov esi, [eax + 0]", + "mov ebp, [eax + 4]", + "mov eax, [eax + 8]", "int $$0x80", "pop esi", "pop ebp", @@ -472,9 +472,9 @@ pub(in crate::backend) unsafe fn syscall6_readonly( asm!( "push ebp", "push esi", - "mov esi, DWORD PTR [eax + 0]", - "mov ebp, DWORD PTR [eax + 4]", - "mov eax, DWORD PTR [eax + 8]", + "mov esi, [eax + 0]", + "mov ebp, [eax + 4]", + "mov eax, [eax + 8]", "int $$0x80", "pop esi", "pop ebp", diff --git a/src/backend/linux_raw/fs/dir.rs b/src/backend/linux_raw/fs/dir.rs index ea1017957..825bca3ec 100644 --- a/src/backend/linux_raw/fs/dir.rs +++ b/src/backend/linux_raw/fs/dir.rs @@ -292,5 +292,5 @@ fn dir_iterator_handles_io_errors() { crate::io::dup2(&file_fd, &mut dir.fd).unwrap(); assert!(matches!(dir.next(), Some(Err(_)))); - assert!(matches!(dir.next(), None)); + assert!(dir.next().is_none()); } diff --git a/src/backend/linux_raw/param/auxv.rs b/src/backend/linux_raw/param/auxv.rs index fbbcdea29..d26c772ad 100644 --- a/src/backend/linux_raw/param/auxv.rs +++ b/src/backend/linux_raw/param/auxv.rs @@ -471,7 +471,7 @@ impl Iterator for AuxFile { Ok(0) => panic!("unexpected end of auxv file"), Ok(n) => slice = &mut slice[n..], Err(crate::io::Errno::INTR) => continue, - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), } } Some(unsafe { read_unaligned(buf.as_ptr().cast()) }) diff --git a/tests/event/eventfd.rs b/tests/event/eventfd.rs index 82195123d..95c68ca62 100644 --- a/tests/event/eventfd.rs +++ b/tests/event/eventfd.rs @@ -10,7 +10,7 @@ fn test_eventfd() { Ok(efd) => efd, #[cfg(target_os = "freebsd")] Err(rustix::io::Errno::NOSYS) => return, // FreeBSD 12 lacks `eventfd` - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; let child = thread::spawn(move || { diff --git a/tests/fs/chmodat.rs b/tests/fs/chmodat.rs index 01df297cb..8d990932a 100644 --- a/tests/fs/chmodat.rs +++ b/tests/fs/chmodat.rs @@ -6,24 +6,24 @@ fn test_chmod() { let tmp = tempfile::tempdir().unwrap(); let _ = open( - tmp.path().join("foo"), + tmp.path().join("file"), OFlags::CREATE | OFlags::WRONLY, Mode::RWXU, ) .unwrap(); - symlink(tmp.path().join("foo"), tmp.path().join("link")).unwrap(); + symlink(tmp.path().join("file"), tmp.path().join("link")).unwrap(); - let before = stat(tmp.path().join("foo")).unwrap(); + let before = stat(tmp.path().join("file")).unwrap(); assert_ne!(before.st_mode as u64 & libc::S_IRWXU as u64, 0); - chmod(tmp.path().join("foo"), Mode::empty()).unwrap(); + chmod(tmp.path().join("file"), Mode::empty()).unwrap(); - let after = stat(tmp.path().join("foo")).unwrap(); + let after = stat(tmp.path().join("file")).unwrap(); assert_eq!(after.st_mode as u64 & libc::S_IRWXU as u64, 0); - chmod(tmp.path().join("foo"), Mode::RWXU).unwrap(); + chmod(tmp.path().join("file"), Mode::RWXU).unwrap(); - let reverted = stat(tmp.path().join("foo")).unwrap(); + let reverted = stat(tmp.path().join("file")).unwrap(); assert_ne!(reverted.st_mode as u64 & libc::S_IRWXU as u64, 0); } @@ -35,25 +35,25 @@ fn test_chmodat() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::RWXU).unwrap(); - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::RWXU).unwrap(); - symlinkat("foo", &dir, "link").unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RWXU).unwrap(); + symlinkat("file", &dir, "link").unwrap(); match chmodat(&dir, "link", Mode::empty(), AtFlags::SYMLINK_NOFOLLOW) { Ok(()) => (), Err(rustix::io::Errno::OPNOTSUPP) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), } - let before = statat(&dir, "foo", AtFlags::empty()).unwrap(); + let before = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_ne!(before.st_mode as u64 & libc::S_IRWXU as u64, 0); - chmodat(&dir, "foo", Mode::empty(), AtFlags::empty()).unwrap(); + chmodat(&dir, "file", Mode::empty(), AtFlags::empty()).unwrap(); - let after = statat(&dir, "foo", AtFlags::empty()).unwrap(); + let after = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_eq!(after.st_mode as u64 & libc::S_IRWXU as u64, 0); - chmodat(&dir, "foo", Mode::RWXU, AtFlags::empty()).unwrap(); + chmodat(&dir, "file", Mode::RWXU, AtFlags::empty()).unwrap(); - let reverted = statat(&dir, "foo", AtFlags::empty()).unwrap(); + let reverted = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_ne!(reverted.st_mode as u64 & libc::S_IRWXU as u64, 0); } diff --git a/tests/fs/dir.rs b/tests/fs/dir.rs index 1e9f42a9d..5547c72f0 100644 --- a/tests/fs/dir.rs +++ b/tests/fs/dir.rs @@ -82,7 +82,7 @@ fn dir_iterator_handles_dir_removal() { drop(tmp); let mut dir = rustix::fs::Dir::read_from(&fd).unwrap(); - assert!(matches!(dir.next(), None)); + assert!(dir.next().is_none()); } // Like `dir_iterator_handles_dir_removal`, but close the directory after @@ -105,5 +105,5 @@ fn dir_iterator_handles_dir_removal_after_open() { // Drop the `TempDir`, which deletes the directory. drop(tmp); - assert!(matches!(dir.next(), None)); + assert!(dir.next().is_none()); } diff --git a/tests/fs/fcntl.rs b/tests/fs/fcntl.rs index dab04e1fd..acfce868c 100644 --- a/tests/fs/fcntl.rs +++ b/tests/fs/fcntl.rs @@ -23,9 +23,9 @@ fn test_fcntl_apple() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC, Mode::RUSR | Mode::WUSR, ) @@ -34,13 +34,13 @@ fn test_fcntl_apple() { // It appears `fsync_rdadvise` at offset 0 length 0 doesn't work if the // file has size zero, so write in some bytes. assert_eq!( - rustix::io::write(&foo, b"data").expect("write"), + rustix::io::write(&file, b"data").expect("write"), 4, "write failed" ); - rustix::fs::fcntl_rdadvise(&foo, 0, 0).unwrap(); - rustix::fs::fcntl_fullfsync(&foo).unwrap(); - rustix::fs::fcntl_nocache(&foo, true).unwrap(); - rustix::fs::fcntl_global_nocache(&foo, true).unwrap(); + rustix::fs::fcntl_rdadvise(&file, 0, 0).unwrap(); + rustix::fs::fcntl_fullfsync(&file).unwrap(); + rustix::fs::fcntl_nocache(&file, true).unwrap(); + rustix::fs::fcntl_global_nocache(&file, true).unwrap(); } diff --git a/tests/fs/file.rs b/tests/fs/file.rs index 83b35cc44..cbd3d5e11 100644 --- a/tests/fs/file.rs +++ b/tests/fs/file.rs @@ -33,7 +33,7 @@ fn test_file() { ) } } - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), } // Check that `SYMLINK_FOLLOW` is rejected. Except on NetBSD which seems diff --git a/tests/fs/futimens.rs b/tests/fs/futimens.rs index 2236cf9c7..616638f13 100644 --- a/tests/fs/futimens.rs +++ b/tests/fs/futimens.rs @@ -6,9 +6,9 @@ fn test_futimens() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::CREATE | OFlags::WRONLY | OFlags::CLOEXEC, Mode::empty(), ) @@ -24,9 +24,9 @@ fn test_futimens() { tv_nsec: 47000, }, }; - futimens(&foo, ×).unwrap(); + futimens(&file, ×).unwrap(); - let after = fstat(&foo).unwrap(); + let after = fstat(&file).unwrap(); assert_eq!(times.last_modification.tv_sec as u64, after.st_mtime as u64); #[cfg(not(target_os = "netbsd"))] diff --git a/tests/fs/invalid_offset.rs b/tests/fs/invalid_offset.rs index a395f3a74..58bd3d2de 100644 --- a/tests/fs/invalid_offset.rs +++ b/tests/fs/invalid_offset.rs @@ -18,7 +18,7 @@ fn invalid_offset_seek() { let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); let file = openat( &dir, - "foo", + "file", OFlags::WRONLY | OFlags::TRUNC | OFlags::CREATE, Mode::RUSR | Mode::WUSR, ) @@ -46,7 +46,7 @@ fn invalid_offset_fallocate() { let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); let file = openat( &dir, - "foo", + "file", OFlags::WRONLY | OFlags::TRUNC | OFlags::CREATE, Mode::RUSR | Mode::WUSR, ) @@ -73,7 +73,7 @@ fn invalid_offset_fadvise() { let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); let file = openat( &dir, - "foo", + "file", OFlags::WRONLY | OFlags::TRUNC | OFlags::CREATE, Mode::RUSR | Mode::WUSR, ) @@ -105,7 +105,7 @@ fn invalid_offset_pread() { let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); let file = openat( &dir, - "foo", + "file", OFlags::RDWR | OFlags::TRUNC | OFlags::CREATE, Mode::RUSR | Mode::WUSR, ) @@ -125,7 +125,7 @@ fn invalid_offset_pwrite() { let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); let file = openat( &dir, - "foo", + "file", OFlags::WRONLY | OFlags::TRUNC | OFlags::CREATE, Mode::RUSR | Mode::WUSR, ) @@ -143,39 +143,39 @@ fn invalid_offset_copy_file_range() { use rustix::io::write; let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let src = openat( &dir, - "foo", + "src", OFlags::RDWR | OFlags::TRUNC | OFlags::CREATE, Mode::RUSR | Mode::WUSR, ) .unwrap(); - let bar = openat( + let dst = openat( &dir, - "bar", + "dst", OFlags::WRONLY | OFlags::TRUNC | OFlags::CREATE, Mode::RUSR | Mode::WUSR, ) .unwrap(); - write(&foo, b"a").unwrap(); + write(&src, b"a").unwrap(); let mut off_in = u64::MAX; let mut off_out = 0; - copy_file_range(&foo, Some(&mut off_in), &bar, Some(&mut off_out), 1).unwrap_err(); + copy_file_range(&src, Some(&mut off_in), &dst, Some(&mut off_out), 1).unwrap_err(); let mut off_in = i64::MAX as u64 + 1; let mut off_out = 0; - copy_file_range(&foo, Some(&mut off_in), &bar, Some(&mut off_out), 1).unwrap_err(); + copy_file_range(&src, Some(&mut off_in), &dst, Some(&mut off_out), 1).unwrap_err(); let mut off_in = 0; let mut off_out = u64::MAX; - copy_file_range(&foo, Some(&mut off_in), &bar, Some(&mut off_out), 1).unwrap_err(); + copy_file_range(&src, Some(&mut off_in), &dst, Some(&mut off_out), 1).unwrap_err(); let mut off_in = 0; let mut off_out = i64::MAX as u64; - copy_file_range(&foo, Some(&mut off_in), &bar, Some(&mut off_out), 1).unwrap_err(); + copy_file_range(&src, Some(&mut off_in), &dst, Some(&mut off_out), 1).unwrap_err(); let mut off_in = 0; let mut off_out = i64::MAX as u64 + 1; - copy_file_range(&foo, Some(&mut off_in), &bar, Some(&mut off_out), 1).unwrap_err(); + copy_file_range(&src, Some(&mut off_in), &dst, Some(&mut off_out), 1).unwrap_err(); } diff --git a/tests/fs/ioctl.rs b/tests/fs/ioctl.rs index 3a3a92dcc..e95ea2750 100644 --- a/tests/fs/ioctl.rs +++ b/tests/fs/ioctl.rs @@ -20,6 +20,6 @@ fn test_ioctl_ficlone() { match rustix::fs::ioctl_ficlone(&dest, &src) { Ok(()) | Err(io::Errno::OPNOTSUPP) => (), Err(e) if e == io::Errno::from_raw_os_error(0x12) => (), - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), } } diff --git a/tests/fs/linkat.rs b/tests/fs/linkat.rs index 543b80556..42ad21177 100644 --- a/tests/fs/linkat.rs +++ b/tests/fs/linkat.rs @@ -5,26 +5,26 @@ fn test_link() { let tmp = tempfile::tempdir().unwrap(); let _ = open( - tmp.path().join("foo"), + tmp.path().join("file"), OFlags::CREATE | OFlags::WRONLY, Mode::RUSR, ) .unwrap(); - link(tmp.path().join("foo"), tmp.path().join("link")).unwrap(); + link(tmp.path().join("file"), tmp.path().join("link")).unwrap(); - readlink(tmp.path().join("foo"), Vec::new()).unwrap_err(); + readlink(tmp.path().join("file"), Vec::new()).unwrap_err(); readlink(tmp.path().join("link"), Vec::new()).unwrap_err(); assert_eq!( - stat(tmp.path().join("foo")).unwrap().st_ino, + stat(tmp.path().join("file")).unwrap().st_ino, stat(tmp.path().join("link")).unwrap().st_ino ); link(tmp.path().join("link"), tmp.path().join("another")).unwrap(); assert_eq!( - stat(tmp.path().join("foo")).unwrap().st_ino, + stat(tmp.path().join("file")).unwrap().st_ino, stat(tmp.path().join("another")).unwrap().st_ino ); } @@ -37,22 +37,22 @@ fn test_linkat() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); - linkat(&dir, "foo", &dir, "link", AtFlags::empty()).unwrap(); + linkat(&dir, "file", &dir, "link", AtFlags::empty()).unwrap(); - readlinkat(&dir, "foo", Vec::new()).unwrap_err(); + readlinkat(&dir, "file", Vec::new()).unwrap_err(); readlinkat(&dir, "link", Vec::new()).unwrap_err(); assert_eq!( - statat(&dir, "foo", AtFlags::empty()).unwrap().st_ino, + statat(&dir, "file", AtFlags::empty()).unwrap().st_ino, statat(&dir, "link", AtFlags::empty()).unwrap().st_ino ); linkat(&dir, "link", &dir, "another", AtFlags::empty()).unwrap(); assert_eq!( - statat(&dir, "foo", AtFlags::empty()).unwrap().st_ino, + statat(&dir, "file", AtFlags::empty()).unwrap().st_ino, statat(&dir, "another", AtFlags::empty()).unwrap().st_ino ); } diff --git a/tests/fs/mkdirat.rs b/tests/fs/mkdirat.rs index ccfe7bd74..f405490b5 100644 --- a/tests/fs/mkdirat.rs +++ b/tests/fs/mkdirat.rs @@ -4,15 +4,15 @@ fn test_mkdir() { let tmp = tempfile::tempdir().unwrap(); - mkdir(tmp.path().join("foo"), Mode::RWXU).unwrap(); - let stat = stat(tmp.path().join("foo")).unwrap(); + mkdir(tmp.path().join("file"), Mode::RWXU).unwrap(); + let stat = stat(tmp.path().join("file")).unwrap(); assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Directory); - access(tmp.path().join("foo"), Access::READ_OK).unwrap(); - access(tmp.path().join("foo"), Access::WRITE_OK).unwrap(); - access(tmp.path().join("foo"), Access::EXEC_OK).unwrap(); - access(tmp.path().join("foo"), Access::EXISTS).unwrap(); - unlink(tmp.path().join("foo")).unwrap_err(); - rmdir(tmp.path().join("foo")).unwrap(); + access(tmp.path().join("file"), Access::READ_OK).unwrap(); + access(tmp.path().join("file"), Access::WRITE_OK).unwrap(); + access(tmp.path().join("file"), Access::EXEC_OK).unwrap(); + access(tmp.path().join("file"), Access::EXISTS).unwrap(); + unlink(tmp.path().join("file")).unwrap_err(); + rmdir(tmp.path().join("file")).unwrap(); } #[cfg(not(target_os = "redox"))] @@ -25,15 +25,15 @@ fn test_mkdirat() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - mkdirat(&dir, "foo", Mode::RWXU).unwrap(); - let stat = statat(&dir, "foo", AtFlags::empty()).unwrap(); + mkdirat(&dir, "file", Mode::RWXU).unwrap(); + let stat = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Directory); - accessat(&dir, "foo", Access::READ_OK, AtFlags::empty()).unwrap(); - accessat(&dir, "foo", Access::WRITE_OK, AtFlags::empty()).unwrap(); - accessat(&dir, "foo", Access::EXEC_OK, AtFlags::empty()).unwrap(); - accessat(&dir, "foo", Access::EXISTS, AtFlags::empty()).unwrap(); - unlinkat(&dir, "foo", AtFlags::empty()).unwrap_err(); - unlinkat(&dir, "foo", AtFlags::REMOVEDIR).unwrap(); + accessat(&dir, "file", Access::READ_OK, AtFlags::empty()).unwrap(); + accessat(&dir, "file", Access::WRITE_OK, AtFlags::empty()).unwrap(); + accessat(&dir, "file", Access::EXEC_OK, AtFlags::empty()).unwrap(); + accessat(&dir, "file", Access::EXISTS, AtFlags::empty()).unwrap(); + unlinkat(&dir, "file", AtFlags::empty()).unwrap_err(); + unlinkat(&dir, "file", AtFlags::REMOVEDIR).unwrap(); } #[cfg(linux_kernel)] @@ -52,10 +52,10 @@ fn test_mkdirat_with_o_path() { ) .unwrap(); - mkdirat(&dir, "foo", Mode::RWXU).unwrap(); - let stat = statat(&dir, "foo", AtFlags::empty()).unwrap(); + mkdirat(&dir, "file", Mode::RWXU).unwrap(); + let stat = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Directory); - accessat(&dir, "foo", Access::EXISTS, AtFlags::empty()).unwrap(); - unlinkat(&dir, "foo", AtFlags::empty()).unwrap_err(); - unlinkat(&dir, "foo", AtFlags::REMOVEDIR).unwrap(); + accessat(&dir, "file", Access::EXISTS, AtFlags::empty()).unwrap(); + unlinkat(&dir, "file", AtFlags::empty()).unwrap_err(); + unlinkat(&dir, "file", AtFlags::REMOVEDIR).unwrap(); } diff --git a/tests/fs/mknodat.rs b/tests/fs/mknodat.rs index bf2398615..cf35b95ea 100644 --- a/tests/fs/mknodat.rs +++ b/tests/fs/mknodat.rs @@ -12,15 +12,15 @@ fn test_mknodat() { // or NetBSD. #[cfg(not(any(solarish, netbsdlike, target_os = "freebsd")))] { - mknodat(&dir, "foo", FileType::RegularFile, Mode::empty(), 0).unwrap(); - let stat = statat(&dir, "foo", AtFlags::empty()).unwrap(); + mknodat(&dir, "file", FileType::RegularFile, Mode::empty(), 0).unwrap(); + let stat = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::RegularFile); - unlinkat(&dir, "foo", AtFlags::empty()).unwrap(); + unlinkat(&dir, "file", AtFlags::empty()).unwrap(); } - mknodat(&dir, "foo", FileType::Fifo, Mode::empty(), 0).unwrap(); - let stat = statat(&dir, "foo", AtFlags::empty()).unwrap(); + mknodat(&dir, "file", FileType::Fifo, Mode::empty(), 0).unwrap(); + let stat = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_eq!(FileType::from_raw_mode(stat.st_mode), FileType::Fifo); - accessat(&dir, "foo", Access::EXISTS, AtFlags::empty()).unwrap(); - unlinkat(&dir, "foo", AtFlags::empty()).unwrap(); + accessat(&dir, "file", Access::EXISTS, AtFlags::empty()).unwrap(); + unlinkat(&dir, "file", AtFlags::empty()).unwrap(); } diff --git a/tests/fs/readlinkat.rs b/tests/fs/readlinkat.rs index 13ba55929..9345cd0e4 100644 --- a/tests/fs/readlinkat.rs +++ b/tests/fs/readlinkat.rs @@ -5,23 +5,23 @@ fn test_readlink() { let tmp = tempfile::tempdir().unwrap(); let _ = open( - tmp.path().join("foo"), + tmp.path().join("file"), OFlags::CREATE | OFlags::WRONLY, Mode::RUSR, ) .unwrap(); - symlink("foo", tmp.path().join("link")).unwrap(); + symlink("file", tmp.path().join("link")).unwrap(); readlink(tmp.path().join("absent"), Vec::new()).unwrap_err(); - readlink(tmp.path().join("foo"), Vec::new()).unwrap_err(); + readlink(tmp.path().join("file"), Vec::new()).unwrap_err(); let target = readlink(tmp.path().join("link"), Vec::new()).unwrap(); - assert_eq!(target.to_string_lossy(), "foo"); + assert_eq!(target.to_string_lossy(), "file"); symlink("link", tmp.path().join("another")).unwrap(); let target = readlink(tmp.path().join("link"), Vec::new()).unwrap(); - assert_eq!(target.to_string_lossy(), "foo"); + assert_eq!(target.to_string_lossy(), "file"); let target = readlink(tmp.path().join("another"), Vec::new()).unwrap(); assert_eq!(target.to_string_lossy(), "link"); } @@ -34,19 +34,19 @@ fn test_readlinkat() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); - symlinkat("foo", &dir, "link").unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); + symlinkat("file", &dir, "link").unwrap(); readlinkat(&dir, "absent", Vec::new()).unwrap_err(); - readlinkat(&dir, "foo", Vec::new()).unwrap_err(); + readlinkat(&dir, "file", Vec::new()).unwrap_err(); let target = readlinkat(&dir, "link", Vec::new()).unwrap(); - assert_eq!(target.to_string_lossy(), "foo"); + assert_eq!(target.to_string_lossy(), "file"); symlinkat("link", &dir, "another").unwrap(); let target = readlinkat(&dir, "link", Vec::new()).unwrap(); - assert_eq!(target.to_string_lossy(), "foo"); + assert_eq!(target.to_string_lossy(), "file"); let target = readlinkat(&dir, "another", Vec::new()).unwrap(); assert_eq!(target.to_string_lossy(), "link"); } @@ -62,30 +62,30 @@ fn test_readlinkat_raw() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); - symlinkat("foo", &dir, "link").unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); + symlinkat("file", &dir, "link").unwrap(); let mut some = [MaybeUninit::::new(0); 32]; let mut short = [MaybeUninit::::new(0); 2]; readlinkat_raw(&dir, "absent", &mut some).unwrap_err(); - readlinkat_raw(&dir, "foo", &mut some).unwrap_err(); + readlinkat_raw(&dir, "file", &mut some).unwrap_err(); let (yes, no) = readlinkat_raw(&dir, "link", &mut some).unwrap(); - assert_eq!(OsStr::from_bytes(yes).to_string_lossy(), "foo"); + assert_eq!(OsStr::from_bytes(yes).to_string_lossy(), "file"); assert!(!no.is_empty()); let (yes, no) = readlinkat_raw(&dir, "link", &mut short).unwrap(); - assert_eq!(yes, &[b'f', b'o']); + assert_eq!(yes, &[b'f', b'i']); assert!(no.is_empty()); symlinkat("link", &dir, "another").unwrap(); let (yes, no) = readlinkat_raw(&dir, "link", &mut some).unwrap(); - assert_eq!(OsStr::from_bytes(yes).to_string_lossy(), "foo"); + assert_eq!(OsStr::from_bytes(yes).to_string_lossy(), "file"); assert!(!no.is_empty()); let (yes, no) = readlinkat_raw(&dir, "link", &mut short).unwrap(); - assert_eq!(yes, &[b'f', b'o']); + assert_eq!(yes, &[b'f', b'i']); assert!(no.is_empty()); let (yes, no) = readlinkat_raw(&dir, "another", &mut some).unwrap(); diff --git a/tests/fs/renameat.rs b/tests/fs/renameat.rs index f0a1dbca9..84ba2f22f 100644 --- a/tests/fs/renameat.rs +++ b/tests/fs/renameat.rs @@ -11,21 +11,21 @@ fn test_rename() { let tmp = tempfile::tempdir().unwrap(); let _ = open( - tmp.path().join("foo"), + tmp.path().join("file"), OFlags::CREATE | OFlags::WRONLY, Mode::empty(), ) .unwrap(); - let before = stat(tmp.path().join("foo")).unwrap(); + let before = stat(tmp.path().join("file")).unwrap(); - access(tmp.path().join("foo"), Access::EXISTS).unwrap(); + access(tmp.path().join("file"), Access::EXISTS).unwrap(); access(tmp.path().join("bar"), Access::EXISTS).unwrap_err(); - rename(tmp.path().join("foo"), tmp.path().join("bar")).unwrap(); + rename(tmp.path().join("file"), tmp.path().join("bar")).unwrap(); let renamed = stat(tmp.path().join("bar")).unwrap(); assert!(same(&before, &renamed)); - access(tmp.path().join("foo"), Access::EXISTS).unwrap_err(); + access(tmp.path().join("file"), Access::EXISTS).unwrap_err(); access(tmp.path().join("bar"), Access::EXISTS).unwrap(); } @@ -43,17 +43,17 @@ fn test_renameat() { ) .unwrap(); - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::empty()).unwrap(); - let before = statat(&dir, "foo", AtFlags::empty()).unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::empty()).unwrap(); + let before = statat(&dir, "file", AtFlags::empty()).unwrap(); - accessat(&dir, "foo", Access::EXISTS, AtFlags::empty()).unwrap(); + accessat(&dir, "file", Access::EXISTS, AtFlags::empty()).unwrap(); accessat(&dir, "bar", Access::EXISTS, AtFlags::empty()).unwrap_err(); - renameat(&dir, "foo", &dir, "bar").unwrap(); + renameat(&dir, "file", &dir, "bar").unwrap(); let renamed = statat(&dir, "bar", AtFlags::empty()).unwrap(); assert!(same(&before, &renamed)); - accessat(&dir, "foo", Access::EXISTS, AtFlags::empty()).unwrap_err(); + accessat(&dir, "file", Access::EXISTS, AtFlags::empty()).unwrap_err(); accessat(&dir, "bar", Access::EXISTS, AtFlags::empty()).unwrap(); } @@ -73,10 +73,10 @@ fn test_renameat_overwrite() { ) .unwrap(); - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::empty()).unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::empty()).unwrap(); let _ = openat(&dir, "bar", OFlags::CREATE | OFlags::WRONLY, Mode::empty()).unwrap(); - let before = statat(&dir, "foo", AtFlags::empty()).unwrap(); - renameat(&dir, "foo", &dir, "bar").unwrap(); + let before = statat(&dir, "file", AtFlags::empty()).unwrap(); + renameat(&dir, "file", &dir, "bar").unwrap(); let renamed = statat(&dir, "bar", AtFlags::empty()).unwrap(); assert!(same(&before, &renamed)); } @@ -95,10 +95,10 @@ fn test_renameat_with() { ) .unwrap(); - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::empty()).unwrap(); - let before = statat(&dir, "foo", AtFlags::empty()).unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::empty()).unwrap(); + let before = statat(&dir, "file", AtFlags::empty()).unwrap(); - match renameat_with(&dir, "foo", &dir, "red", RenameFlags::empty()) { + match renameat_with(&dir, "file", &dir, "red", RenameFlags::empty()) { Ok(()) => (), Err(err) if err == rustix::io::Errno::NOSYS => return, Err(err) => unreachable!("unexpected error from renameat_with: {:?}", err), diff --git a/tests/fs/seals.rs b/tests/fs/seals.rs index b7f903d42..e6442cb83 100644 --- a/tests/fs/seals.rs +++ b/tests/fs/seals.rs @@ -9,7 +9,7 @@ fn test_seals() { let fd = match memfd_create("test", MemfdFlags::CLOEXEC | MemfdFlags::ALLOW_SEALING) { Ok(fd) => fd, Err(rustix::io::Errno::NOSYS) => return, - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), }; let mut file = File::from(fd); diff --git a/tests/fs/seek.rs b/tests/fs/seek.rs index aa339a0b5..fe4f4409c 100644 --- a/tests/fs/seek.rs +++ b/tests/fs/seek.rs @@ -7,23 +7,23 @@ fn test_seek_holes() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC, Mode::RUSR | Mode::WUSR, ) .unwrap(); - let mut foo = std::fs::File::from(foo); + let mut file = std::fs::File::from(file); - let stat = fstat(&foo).unwrap(); + let stat = fstat(&file).unwrap(); let hole_size = stat.st_blksize as u64; #[cfg(any(solarish, freebsdlike, netbsdlike))] let hole_size = unsafe { use std::os::unix::io::AsRawFd; - let r = libc::fpathconf(foo.as_raw_fd(), libc::_PC_MIN_HOLE_SIZE); + let r = libc::fpathconf(file.as_raw_fd(), libc::_PC_MIN_HOLE_SIZE); if r < 0 { // Holes not supported. @@ -34,27 +34,27 @@ fn test_seek_holes() { core::cmp::max(hole_size, r as u64) }; - foo.write_all(b"prefix").unwrap(); + file.write_all(b"prefix").unwrap(); assert_eq!( - seek(&foo, SeekFrom::Start(hole_size * 2)), + seek(&file, SeekFrom::Start(hole_size * 2)), Ok(hole_size * 2) ); - foo.write_all(b"suffix").unwrap(); - assert_eq!(seek(&foo, SeekFrom::Start(0)), Ok(0)); - assert_eq!(seek(&foo, SeekFrom::Current(0)), Ok(0)); - assert_eq!(seek(&foo, SeekFrom::Hole(0)), Ok(hole_size)); - assert_eq!(seek(&foo, SeekFrom::Hole(hole_size as i64)), Ok(hole_size)); + file.write_all(b"suffix").unwrap(); + assert_eq!(seek(&file, SeekFrom::Start(0)), Ok(0)); + assert_eq!(seek(&file, SeekFrom::Current(0)), Ok(0)); + assert_eq!(seek(&file, SeekFrom::Hole(0)), Ok(hole_size)); + assert_eq!(seek(&file, SeekFrom::Hole(hole_size as i64)), Ok(hole_size)); assert_eq!( - seek(&foo, SeekFrom::Hole(hole_size as i64 * 2)), + seek(&file, SeekFrom::Hole(hole_size as i64 * 2)), Ok(hole_size * 2 + 6) ); - assert_eq!(seek(&foo, SeekFrom::Data(0)), Ok(0)); + assert_eq!(seek(&file, SeekFrom::Data(0)), Ok(0)); assert_eq!( - seek(&foo, SeekFrom::Data(hole_size as i64)), + seek(&file, SeekFrom::Data(hole_size as i64)), Ok(hole_size * 2) ); assert_eq!( - seek(&foo, SeekFrom::Data(hole_size as i64 * 2)), + seek(&file, SeekFrom::Data(hole_size as i64 * 2)), Ok(hole_size * 2) ); } @@ -69,7 +69,7 @@ fn test_seek_offsets() { Ok(_) => {} Err(e) => panic!("seek failed with an unexpected error: {:?}", e), } - for invalid_offset in [i32::MIN as u64, !1 as u64, i64::MIN as u64] { + for invalid_offset in [i32::MIN as u64, !1, i64::MIN as u64] { match seek(&f, SeekFrom::Start(invalid_offset)) { Err(rustix::io::Errno::INVAL) => {} Ok(_) => panic!("seek unexpectedly succeeded"), diff --git a/tests/fs/symlinkat.rs b/tests/fs/symlinkat.rs index 01894bcc2..740b9c898 100644 --- a/tests/fs/symlinkat.rs +++ b/tests/fs/symlinkat.rs @@ -5,15 +5,15 @@ fn test_symlink() { let tmp = tempfile::tempdir().unwrap(); let _ = open( - tmp.path().join("foo"), + tmp.path().join("file"), OFlags::CREATE | OFlags::WRONLY, Mode::RUSR, ) .unwrap(); - symlink("foo", tmp.path().join("link")).unwrap(); + symlink("file", tmp.path().join("link")).unwrap(); let target = readlink(tmp.path().join("link"), Vec::new()).unwrap(); - assert_eq!(target.to_string_lossy(), "foo"); + assert_eq!(target.to_string_lossy(), "file"); assert_eq!( lstat(tmp.path().join("link")).unwrap().st_mode as u64 & libc::S_IFMT as u64, @@ -29,11 +29,11 @@ fn test_symlinkat() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); - symlinkat("foo", &dir, "link").unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); + symlinkat("file", &dir, "link").unwrap(); let target = readlinkat(&dir, "link", Vec::new()).unwrap(); - assert_eq!(target.to_string_lossy(), "foo"); + assert_eq!(target.to_string_lossy(), "file"); assert_eq!( statat(&dir, "link", AtFlags::SYMLINK_NOFOLLOW) diff --git a/tests/fs/utimensat.rs b/tests/fs/utimensat.rs index 035fb88b6..ec65f466d 100644 --- a/tests/fs/utimensat.rs +++ b/tests/fs/utimensat.rs @@ -14,7 +14,7 @@ fn test_utimensat() { let _ = openat( &dir, - "foo", + "file", OFlags::CREATE | OFlags::WRONLY | OFlags::CLOEXEC, Mode::empty(), ) @@ -30,9 +30,9 @@ fn test_utimensat() { tv_nsec: 47000, }, }; - utimensat(&dir, "foo", ×, AtFlags::empty()).unwrap(); + utimensat(&dir, "file", ×, AtFlags::empty()).unwrap(); - let after = statat(&dir, "foo", AtFlags::empty()).unwrap(); + let after = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_eq!(times.last_modification.tv_sec as u64, after.st_mtime as u64); #[cfg(not(target_os = "netbsd"))] @@ -83,7 +83,7 @@ fn test_utimensat_noent() { }, }; assert_eq!( - utimensat(&dir, "foo", ×, AtFlags::empty()).unwrap_err(), + utimensat(&dir, "file", ×, AtFlags::empty()).unwrap_err(), rustix::io::Errno::NOENT ); } @@ -102,9 +102,9 @@ fn test_utimensat_notdir() { ) .unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::CREATE | OFlags::WRONLY | OFlags::CLOEXEC, Mode::empty(), ) @@ -121,7 +121,7 @@ fn test_utimensat_notdir() { }, }; assert_eq!( - utimensat(&foo, "bar", ×, AtFlags::empty()).unwrap_err(), + utimensat(&file, "bar", ×, AtFlags::empty()).unwrap_err(), rustix::io::Errno::NOTDIR ); } diff --git a/tests/fs/y2038.rs b/tests/fs/y2038.rs index 07543fa02..eba3a16d5 100644 --- a/tests/fs/y2038.rs +++ b/tests/fs/y2038.rs @@ -30,9 +30,9 @@ fn test_y2038_with_utimensat() { tv_nsec: a_nsec as _, }, }; - let _ = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); + let _ = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); - match utimensat(&dir, "foo", ×tamps, AtFlags::empty()) { + match utimensat(&dir, "file", ×tamps, AtFlags::empty()) { Ok(()) => (), // On 32-bit platforms, accept `EOVERFLOW`, meaning that y2038 support @@ -44,7 +44,7 @@ fn test_y2038_with_utimensat() { } // Use `statat` to read back the timestamp. - let stat = statat(&dir, "foo", AtFlags::empty()).unwrap(); + let stat = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_eq!(TryInto::::try_into(stat.st_mtime).unwrap(), m_sec); @@ -67,7 +67,7 @@ fn test_y2038_with_utimensat() { ); // Now test the same thing, but with `fstat`. - let file = openat(&dir, "foo", OFlags::RDONLY, Mode::empty()).unwrap(); + let file = openat(&dir, "file", OFlags::RDONLY, Mode::empty()).unwrap(); let stat = fstat(&file).unwrap(); assert_eq!(TryInto::::try_into(stat.st_mtime).unwrap(), m_sec); @@ -123,7 +123,7 @@ fn test_y2038_with_futimens() { tv_nsec: a_nsec as _, }, }; - let file = openat(&dir, "foo", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); + let file = openat(&dir, "file", OFlags::CREATE | OFlags::WRONLY, Mode::RUSR).unwrap(); match futimens(&file, ×tamps) { Ok(()) => (), @@ -137,7 +137,7 @@ fn test_y2038_with_futimens() { } // Use `statat` to read back the timestamp. - let stat = statat(&dir, "foo", AtFlags::empty()).unwrap(); + let stat = statat(&dir, "file", AtFlags::empty()).unwrap(); assert_eq!(TryInto::::try_into(stat.st_mtime).unwrap(), m_sec); @@ -160,7 +160,7 @@ fn test_y2038_with_futimens() { ); // Now test the same thing, but with `fstat`. - let file = openat(&dir, "foo", OFlags::RDONLY, Mode::empty()).unwrap(); + let file = openat(&dir, "file", OFlags::RDONLY, Mode::empty()).unwrap(); let stat = fstat(&file).unwrap(); assert_eq!(TryInto::::try_into(stat.st_mtime).unwrap(), m_sec); @@ -213,7 +213,7 @@ fn test_y2038_with_futimens_and_stat() { }, }; let file = open( - tmp.path().join("foo"), + tmp.path().join("file"), OFlags::CREATE | OFlags::WRONLY, Mode::RUSR, ) @@ -231,7 +231,7 @@ fn test_y2038_with_futimens_and_stat() { } // Use `statat` to read back the timestamp. - let stat = stat(tmp.path().join("foo")).unwrap(); + let stat = stat(tmp.path().join("file")).unwrap(); assert_eq!(TryInto::::try_into(stat.st_mtime).unwrap(), m_sec); @@ -254,7 +254,7 @@ fn test_y2038_with_futimens_and_stat() { ); // Now test the same thing, but with `fstat`. - let file = open(tmp.path().join("foo"), OFlags::RDONLY, Mode::empty()).unwrap(); + let file = open(tmp.path().join("file"), OFlags::RDONLY, Mode::empty()).unwrap(); let stat = fstat(&file).unwrap(); assert_eq!(TryInto::::try_into(stat.st_mtime).unwrap(), m_sec); diff --git a/tests/io/read_write.rs b/tests/io/read_write.rs index 1debf89bb..fc90e3caa 100644 --- a/tests/io/read_write.rs +++ b/tests/io/read_write.rs @@ -12,9 +12,9 @@ fn test_readwrite_pv() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC, Mode::RUSR | Mode::WUSR, ) @@ -23,23 +23,23 @@ fn test_readwrite_pv() { // For most targets, just call `pwritev`. #[cfg(not(apple))] { - pwritev(&foo, &[IoSlice::new(b"hello")], 200).unwrap(); + pwritev(&file, &[IoSlice::new(b"hello")], 200).unwrap(); } // macOS only has `pwritev` in newer versions; allow it to fail with // `Errno::NOSYS`. #[cfg(apple)] { - match pwritev(&foo, &[IoSlice::new(b"hello")], 200) { + match pwritev(&file, &[IoSlice::new(b"hello")], 200) { Ok(_) => (), Err(rustix::io::Errno::NOSYS) => return, - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), } } - pwritev(&foo, &[IoSlice::new(b"world")], 300).unwrap(); + pwritev(&file, &[IoSlice::new(b"world")], 300).unwrap(); let mut buf = [0_u8; 5]; - preadv(&foo, &mut [IoSliceMut::new(&mut buf)], 200).unwrap(); + preadv(&file, &mut [IoSliceMut::new(&mut buf)], 200).unwrap(); assert_eq!(&buf, b"hello"); - preadv(&foo, &mut [IoSliceMut::new(&mut buf)], 300).unwrap(); + preadv(&file, &mut [IoSliceMut::new(&mut buf)], 300).unwrap(); assert_eq!(&buf, b"world"); } @@ -51,20 +51,20 @@ fn test_readwrite_p() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC, Mode::RUSR | Mode::WUSR, ) .unwrap(); - pwrite(&foo, b"hello", 200).unwrap(); - pwrite(&foo, b"world", 300).unwrap(); + pwrite(&file, b"hello", 200).unwrap(); + pwrite(&file, b"world", 300).unwrap(); let mut buf = [0_u8; 5]; - pread(&foo, &mut buf, 200).unwrap(); + pread(&file, &mut buf, 200).unwrap(); assert_eq!(&buf, b"hello"); - pread(&foo, &mut buf, 300).unwrap(); + pread(&file, &mut buf, 300).unwrap(); assert_eq!(&buf, b"world"); } @@ -77,21 +77,21 @@ fn test_readwrite_v() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC, Mode::RUSR | Mode::WUSR, ) .unwrap(); - writev(&foo, &[IoSlice::new(b"hello")]).unwrap(); - writev(&foo, &[IoSlice::new(b"world")]).unwrap(); - seek(&foo, SeekFrom::Start(0)).unwrap(); + writev(&file, &[IoSlice::new(b"hello")]).unwrap(); + writev(&file, &[IoSlice::new(b"world")]).unwrap(); + seek(&file, SeekFrom::Start(0)).unwrap(); let mut buf = [0_u8; 5]; - readv(&foo, &mut [IoSliceMut::new(&mut buf)]).unwrap(); + readv(&file, &mut [IoSliceMut::new(&mut buf)]).unwrap(); assert_eq!(&buf, b"hello"); - readv(&foo, &mut [IoSliceMut::new(&mut buf)]).unwrap(); + readv(&file, &mut [IoSliceMut::new(&mut buf)]).unwrap(); assert_eq!(&buf, b"world"); } @@ -103,21 +103,21 @@ fn test_readwrite() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC, Mode::RUSR | Mode::WUSR, ) .unwrap(); - write(&foo, b"hello").unwrap(); - write(&foo, b"world").unwrap(); - seek(&foo, SeekFrom::Start(0)).unwrap(); + write(&file, b"hello").unwrap(); + write(&file, b"world").unwrap(); + seek(&file, SeekFrom::Start(0)).unwrap(); let mut buf = [0_u8; 5]; - read(&foo, &mut buf).unwrap(); + read(&file, &mut buf).unwrap(); assert_eq!(&buf, b"hello"); - read(&foo, &mut buf).unwrap(); + read(&file, &mut buf).unwrap(); assert_eq!(&buf, b"world"); } @@ -157,35 +157,35 @@ fn test_pwritev2() { let tmp = tempfile::tempdir().unwrap(); let dir = openat(CWD, tmp.path(), OFlags::RDONLY, Mode::empty()).unwrap(); - let foo = openat( + let file = openat( &dir, - "foo", + "file", OFlags::RDWR | OFlags::CREATE | OFlags::TRUNC, Mode::RUSR | Mode::WUSR, ) .unwrap(); - writev(&foo, &[IoSlice::new(b"hello")]).unwrap(); - seek(&foo, SeekFrom::Start(0)).unwrap(); + writev(&file, &[IoSlice::new(b"hello")]).unwrap(); + seek(&file, SeekFrom::Start(0)).unwrap(); // pwritev2 to append with a 0 offset: don't update the current position. - match pwritev2(&foo, &[IoSlice::new(b"world")], 0, ReadWriteFlags::APPEND) { + match pwritev2(&file, &[IoSlice::new(b"world")], 0, ReadWriteFlags::APPEND) { Ok(_) => {} // Skip the rest of the test if we don't have `pwritev2` and // `RWF_APPEND`. Err(rustix::io::Errno::NOSYS | rustix::io::Errno::NOTSUP) => return, - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), } - assert_eq!(seek(&foo, SeekFrom::Current(0)).unwrap(), 0); + assert_eq!(seek(&file, SeekFrom::Current(0)).unwrap(), 0); // pwritev2 to append with a !0 offset: do update the current position. - pwritev2(&foo, &[IoSlice::new(b"world")], !0, ReadWriteFlags::APPEND).unwrap(); - assert_eq!(seek(&foo, SeekFrom::Current(0)).unwrap(), 15); + pwritev2(&file, &[IoSlice::new(b"world")], !0, ReadWriteFlags::APPEND).unwrap(); + assert_eq!(seek(&file, SeekFrom::Current(0)).unwrap(), 15); - seek(&foo, SeekFrom::Start(0)).unwrap(); + seek(&file, SeekFrom::Start(0)).unwrap(); let mut buf = [0_u8; 5]; preadv2( - &foo, + &file, &mut [IoSliceMut::new(&mut buf)], 0, ReadWriteFlags::empty(), @@ -193,7 +193,7 @@ fn test_pwritev2() { .unwrap(); assert_eq!(&buf, b"hello"); preadv2( - &foo, + &file, &mut [IoSliceMut::new(&mut buf)], 5, ReadWriteFlags::empty(), @@ -308,7 +308,7 @@ fn test_p_offsets() { } // Test that negative offsets fail with `INVAL`. - for invalid_offset in [i32::MIN as u64, !1 as u64, i64::MIN as u64] { + for invalid_offset in [i32::MIN as u64, !1, i64::MIN as u64] { match pread(&f, &mut buf, invalid_offset) { Err(rustix::io::Errno::OPNOTSUPP | rustix::io::Errno::NOSYS) => {} Err(rustix::io::Errno::INVAL) => {} diff --git a/tests/mm/mlock.rs b/tests/mm/mlock.rs index 804e95ec3..6ca74d4d0 100644 --- a/tests/mm/mlock.rs +++ b/tests/mm/mlock.rs @@ -21,7 +21,7 @@ fn test_mlock() { // Tests won't always have enough memory or permissions, and that's ok. Err(rustix::io::Errno::PERM | rustix::io::Errno::NOMEM) => {} // But they shouldn't fail otherwise. - Err(other) => Err(other).unwrap(), + Err(other) => panic!("{:?}", other), } } } @@ -41,7 +41,7 @@ fn test_mlock_with() { // Tests won't always have enough memory or permissions, and that's ok. Err(rustix::io::Errno::PERM | rustix::io::Errno::NOMEM | rustix::io::Errno::NOSYS) => {} // But they shouldn't fail otherwise. - Err(other) => Err(other).unwrap(), + Err(other) => panic!("{:?}", other), } } } @@ -75,7 +75,7 @@ fn test_mlock_with_onfault() { // Tests won't always have enough memory or permissions, and that's ok. Err(rustix::io::Errno::PERM | rustix::io::Errno::NOMEM | rustix::io::Errno::NOSYS) => {} // But they shouldn't fail otherwise. - Err(other) => Err(other).unwrap(), + Err(other) => panic!("{:?}", other), } } } diff --git a/tests/mm/mmap.rs b/tests/mm/mmap.rs index 51c83d8b8..79133dfb9 100644 --- a/tests/mm/mmap.rs +++ b/tests/mm/mmap.rs @@ -13,7 +13,7 @@ fn test_mmap() { let file = openat( &dir, - "foo", + "file", OFlags::CREATE | OFlags::WRONLY | OFlags::TRUNC, Mode::RUSR, ) @@ -21,7 +21,7 @@ fn test_mmap() { write(&file, &[b'a'; 8192]).unwrap(); drop(file); - let file = openat(&dir, "foo", OFlags::RDONLY, Mode::empty()).unwrap(); + let file = openat(&dir, "file", OFlags::RDONLY, Mode::empty()).unwrap(); unsafe { let addr = mmap( null_mut(), @@ -38,7 +38,7 @@ fn test_mmap() { munmap(addr, 8192).unwrap(); } - let file = openat(&dir, "foo", OFlags::RDONLY, Mode::empty()).unwrap(); + let file = openat(&dir, "file", OFlags::RDONLY, Mode::empty()).unwrap(); unsafe { assert_eq!( mmap( @@ -105,14 +105,14 @@ fn test_mlock() { // Tests won't always have enough memory or permissions, and that's ok. Err(rustix::io::Errno::PERM | rustix::io::Errno::NOMEM) => (), // But they shouldn't fail otherwise. - Err(other) => Err(other).unwrap(), + Err(other) => panic!("{:?}", other), } #[cfg(linux_kernel)] { match mlock_with(addr, 8192, MlockFlags::empty()) { Err(rustix::io::Errno::NOSYS) => (), - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), Ok(()) => munlock(addr, 8192).unwrap(), } @@ -121,7 +121,7 @@ fn test_mlock() { Err(rustix::io::Errno::NOSYS) => (), // Linux versions that don't recognize `ONFAULT` return this. Err(rustix::io::Errno::INVAL) => (), - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), Ok(()) => munlock(addr, 8192).unwrap(), } diff --git a/tests/net/sockopt.rs b/tests/net/sockopt.rs index cd4140e84..bb555d71b 100644 --- a/tests/net/sockopt.rs +++ b/tests/net/sockopt.rs @@ -15,10 +15,10 @@ use std::time::Duration; // Test `socket` socket options. fn test_sockopts_socket(s: &OwnedFd) { // On a new socket we shouldn't have a timeout yet. - assert!(sockopt::get_socket_timeout(&s, sockopt::Timeout::Recv) + assert!(sockopt::get_socket_timeout(s, sockopt::Timeout::Recv) .unwrap() .is_none()); - assert_eq!(sockopt::get_socket_type(&s).unwrap(), SocketType::STREAM); + assert_eq!(sockopt::get_socket_type(s).unwrap(), SocketType::STREAM); #[cfg(any( linux_kernel, target_os = "freebsd", @@ -28,35 +28,32 @@ fn test_sockopts_socket(s: &OwnedFd) { target_env = "newlib" ))] { - assert_eq!( - sockopt::get_socket_protocol(&s).unwrap(), - Some(ipproto::TCP) - ); + assert_eq!(sockopt::get_socket_protocol(s).unwrap(), Some(ipproto::TCP)); } - assert!(!sockopt::get_socket_reuseaddr(&s).unwrap()); + assert!(!sockopt::get_socket_reuseaddr(s).unwrap()); #[cfg(not(windows))] - assert!(!sockopt::get_socket_broadcast(&s).unwrap()); + assert!(!sockopt::get_socket_broadcast(s).unwrap()); // On a new socket we shouldn't have a linger yet. - assert!(sockopt::get_socket_linger(&s).unwrap().is_none()); + assert!(sockopt::get_socket_linger(s).unwrap().is_none()); #[cfg(linux_kernel)] - assert!(!sockopt::get_socket_passcred(&s).unwrap()); + assert!(!sockopt::get_socket_passcred(s).unwrap()); // On a new socket we shouldn't have an error yet. - assert_eq!(sockopt::get_socket_error(&s).unwrap(), Ok(())); - assert!(!sockopt::get_socket_keepalive(&s).unwrap()); - assert_ne!(sockopt::get_socket_recv_buffer_size(&s).unwrap(), 0); - assert_ne!(sockopt::get_socket_send_buffer_size(&s).unwrap(), 0); + assert_eq!(sockopt::get_socket_error(s).unwrap(), Ok(())); + assert!(!sockopt::get_socket_keepalive(s).unwrap()); + assert_ne!(sockopt::get_socket_recv_buffer_size(s).unwrap(), 0); + assert_ne!(sockopt::get_socket_send_buffer_size(s).unwrap(), 0); #[cfg(not(apple))] - assert!(!sockopt::get_socket_acceptconn(&s).unwrap()); + assert!(!sockopt::get_socket_acceptconn(s).unwrap()); // Set a timeout. - sockopt::set_socket_timeout(&s, sockopt::Timeout::Recv, Some(Duration::new(1, 1))).unwrap(); + sockopt::set_socket_timeout(s, sockopt::Timeout::Recv, Some(Duration::new(1, 1))).unwrap(); // Check that we have a timeout of at least the time we set. if cfg!(not(any(target_os = "freebsd", target_os = "netbsd"))) { assert!( - sockopt::get_socket_timeout(&s, sockopt::Timeout::Recv) + sockopt::get_socket_timeout(s, sockopt::Timeout::Recv) .unwrap() .unwrap() >= Duration::new(1, 1) @@ -64,7 +61,7 @@ fn test_sockopts_socket(s: &OwnedFd) { } else { // On FreeBSD <= 12 and NetBSD, it appears the system rounds the timeout down. assert!( - sockopt::get_socket_timeout(&s, sockopt::Timeout::Recv) + sockopt::get_socket_timeout(s, sockopt::Timeout::Recv) .unwrap() .unwrap() >= Duration::new(1, 0) @@ -72,92 +69,92 @@ fn test_sockopts_socket(s: &OwnedFd) { } // Set a timeout with more than a million nanoseconds. - sockopt::set_socket_timeout(&s, sockopt::Timeout::Recv, Some(Duration::new(1, 10000000))) + sockopt::set_socket_timeout(s, sockopt::Timeout::Recv, Some(Duration::new(1, 10000000))) .unwrap(); // Check that we have a timeout of at least the time we set. assert!( - sockopt::get_socket_timeout(&s, sockopt::Timeout::Recv) + sockopt::get_socket_timeout(s, sockopt::Timeout::Recv) .unwrap() .unwrap() >= Duration::new(1, 10000000) ); // Set the reuse address flag - sockopt::set_socket_reuseaddr(&s, true).unwrap(); + sockopt::set_socket_reuseaddr(s, true).unwrap(); // Check that the reuse address flag is set. - assert!(sockopt::get_socket_reuseaddr(&s).unwrap()); + assert!(sockopt::get_socket_reuseaddr(s).unwrap()); #[cfg(not(windows))] { // Set the broadcast flag; - sockopt::set_socket_broadcast(&s, true).unwrap(); + sockopt::set_socket_broadcast(s, true).unwrap(); // Check that the broadcast flag is set. This has no effect on stream // sockets, and not all platforms even remember the value. #[cfg(not(bsd))] - assert!(sockopt::get_socket_broadcast(&s).unwrap()); + assert!(sockopt::get_socket_broadcast(s).unwrap()); } // Set the keepalive flag; - sockopt::set_socket_keepalive(&s, true).unwrap(); + sockopt::set_socket_keepalive(s, true).unwrap(); // Check that the keepalive flag is set. - assert!(sockopt::get_socket_keepalive(&s).unwrap()); + assert!(sockopt::get_socket_keepalive(s).unwrap()); // Set a linger. - sockopt::set_socket_linger(&s, Some(Duration::new(1, 1))).unwrap(); + sockopt::set_socket_linger(s, Some(Duration::new(1, 1))).unwrap(); // Check that we have a linger of at least the time we set. - assert!(sockopt::get_socket_linger(&s).unwrap().unwrap() >= Duration::new(1, 1)); + assert!(sockopt::get_socket_linger(s).unwrap().unwrap() >= Duration::new(1, 1)); #[cfg(linux_kernel)] { // Set the passcred flag; - sockopt::set_socket_passcred(&s, true).unwrap(); + sockopt::set_socket_passcred(s, true).unwrap(); // Check that the passcred flag is set. - assert!(sockopt::get_socket_passcred(&s).unwrap()); + assert!(sockopt::get_socket_passcred(s).unwrap()); } // Set the receive buffer size. - let size = sockopt::get_socket_recv_buffer_size(&s).unwrap(); - sockopt::set_socket_recv_buffer_size(&s, size * 2).unwrap(); + let size = sockopt::get_socket_recv_buffer_size(s).unwrap(); + sockopt::set_socket_recv_buffer_size(s, size * 2).unwrap(); // Check that the receive buffer size is set. - assert!(sockopt::get_socket_recv_buffer_size(&s).unwrap() >= size * 2); + assert!(sockopt::get_socket_recv_buffer_size(s).unwrap() >= size * 2); // Set the send buffer size. - let size = sockopt::get_socket_send_buffer_size(&s).unwrap(); - sockopt::set_socket_send_buffer_size(&s, size * 4).unwrap(); + let size = sockopt::get_socket_send_buffer_size(s).unwrap(); + sockopt::set_socket_send_buffer_size(s, size * 4).unwrap(); // Check that the send buffer size is set. - assert!(sockopt::get_socket_send_buffer_size(&s).unwrap() >= size * 4); + assert!(sockopt::get_socket_send_buffer_size(s).unwrap() >= size * 4); // Check that the oobinline flag is not initially set. - assert!(!sockopt::get_socket_oobinline(&s).unwrap()); + assert!(!sockopt::get_socket_oobinline(s).unwrap()); // Set the oobinline flag; - sockopt::set_socket_oobinline(&s, true).unwrap(); + sockopt::set_socket_oobinline(s, true).unwrap(); // Check that the oobinline flag is set. - assert!(sockopt::get_socket_oobinline(&s).unwrap()); + assert!(sockopt::get_socket_oobinline(s).unwrap()); // Check the initial value of SO_REUSEPORT, set it, and check it. #[cfg(not(any(solarish, windows)))] { - assert!(!sockopt::get_socket_reuseport(&s).unwrap()); - sockopt::set_socket_reuseport(&s, true).unwrap(); - assert!(sockopt::get_socket_reuseport(&s).unwrap()); + assert!(!sockopt::get_socket_reuseport(s).unwrap()); + sockopt::set_socket_reuseport(s, true).unwrap(); + assert!(sockopt::get_socket_reuseport(s).unwrap()); } // Check the initial value of SO_REUSEPORT_LB, set it, and check it. #[cfg(target_os = "freebsd")] { - assert!(!sockopt::get_socket_reuseport_lb(&s).unwrap()); - sockopt::set_socket_reuseport_lb(&s, true).unwrap(); - assert!(sockopt::get_socket_reuseport_lb(&s).unwrap()); + assert!(!sockopt::get_socket_reuseport_lb(s).unwrap()); + sockopt::set_socket_reuseport_lb(s, true).unwrap(); + assert!(sockopt::get_socket_reuseport_lb(s).unwrap()); } // Not much we can check with `get_socket_cookie`, but make sure we can @@ -165,25 +162,25 @@ fn test_sockopts_socket(s: &OwnedFd) { #[cfg(target_os = "linux")] { assert_eq!( - sockopt::get_socket_cookie(&s).unwrap(), - sockopt::get_socket_cookie(&s).unwrap() + sockopt::get_socket_cookie(s).unwrap(), + sockopt::get_socket_cookie(s).unwrap() ); } // Check the initial value of SO_INCOMING_CPU, set it, and check it. #[cfg(target_os = "linux")] { - assert_eq!(sockopt::get_socket_incoming_cpu(&s).unwrap(), u32::MAX); - sockopt::set_socket_incoming_cpu(&s, 3).unwrap(); - assert_eq!(sockopt::get_socket_incoming_cpu(&s).unwrap(), 3); + assert_eq!(sockopt::get_socket_incoming_cpu(s).unwrap(), u32::MAX); + sockopt::set_socket_incoming_cpu(s, 3).unwrap(); + assert_eq!(sockopt::get_socket_incoming_cpu(s).unwrap(), 3); } // Check the initial value of SO_NOSIGPIPE, set it, and check it. #[cfg(any(apple, freebsdlike, target_os = "netbsd"))] { - assert_eq!(sockopt::get_socket_nosigpipe(&s).unwrap(), false); - sockopt::set_socket_nosigpipe(&s, true).unwrap(); - assert_eq!(sockopt::get_socket_nosigpipe(&s).unwrap(), true); + assert_eq!(sockopt::get_socket_nosigpipe(s).unwrap(), false); + sockopt::set_socket_nosigpipe(s, true).unwrap(); + assert_eq!(sockopt::get_socket_nosigpipe(s).unwrap(), true); } } @@ -191,55 +188,55 @@ fn test_sockopts_socket(s: &OwnedFd) { fn test_sockopts_tcp(s: &OwnedFd) { #[cfg(any(linux_like, taraget_os = "fuchsia"))] { - assert_eq!(sockopt::get_tcp_user_timeout(&s).unwrap(), 0); - sockopt::set_tcp_user_timeout(&s, 7).unwrap(); - assert_eq!(sockopt::get_tcp_user_timeout(&s).unwrap(), 7); + assert_eq!(sockopt::get_tcp_user_timeout(s).unwrap(), 0); + sockopt::set_tcp_user_timeout(s, 7).unwrap(); + assert_eq!(sockopt::get_tcp_user_timeout(s).unwrap(), 7); } - assert!(!sockopt::get_tcp_nodelay(&s).unwrap()); + assert!(!sockopt::get_tcp_nodelay(s).unwrap()); #[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))] { - assert!(sockopt::get_tcp_keepcnt(&s).is_ok()); - assert!(sockopt::get_tcp_keepidle(&s).is_ok()); - assert!(sockopt::get_tcp_keepintvl(&s).is_ok()); + assert!(sockopt::get_tcp_keepcnt(s).is_ok()); + assert!(sockopt::get_tcp_keepidle(s).is_ok()); + assert!(sockopt::get_tcp_keepintvl(s).is_ok()); } // Set the nodelay flag. - sockopt::set_tcp_nodelay(&s, true).unwrap(); + sockopt::set_tcp_nodelay(s, true).unwrap(); // Check that the nodelay flag is set. - assert!(sockopt::get_tcp_nodelay(&s).unwrap()); + assert!(sockopt::get_tcp_nodelay(s).unwrap()); // Clear the nodelay flag. - sockopt::set_tcp_nodelay(&s, false).unwrap(); + sockopt::set_tcp_nodelay(s, false).unwrap(); // Check that the nodelay flag is cleared. - assert!(!sockopt::get_tcp_nodelay(&s).unwrap()); + assert!(!sockopt::get_tcp_nodelay(s).unwrap()); #[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))] { // Set keepalive values: - sockopt::set_tcp_keepcnt(&s, 42).unwrap(); - sockopt::set_tcp_keepidle(&s, Duration::from_secs(3601)).unwrap(); - sockopt::set_tcp_keepintvl(&s, Duration::from_secs(60)).unwrap(); + sockopt::set_tcp_keepcnt(s, 42).unwrap(); + sockopt::set_tcp_keepidle(s, Duration::from_secs(3601)).unwrap(); + sockopt::set_tcp_keepintvl(s, Duration::from_secs(60)).unwrap(); // Check keepalive values: - assert_eq!(sockopt::get_tcp_keepcnt(&s).unwrap(), 42); + assert_eq!(sockopt::get_tcp_keepcnt(s).unwrap(), 42); assert_eq!( - sockopt::get_tcp_keepidle(&s).unwrap(), + sockopt::get_tcp_keepidle(s).unwrap(), Duration::from_secs(3601) ); assert_eq!( - sockopt::get_tcp_keepintvl(&s).unwrap(), + sockopt::get_tcp_keepintvl(s).unwrap(), Duration::from_secs(60) ); #[cfg(not(target_os = "illumos"))] { - sockopt::set_tcp_keepintvl(&s, Duration::from_secs(61)).unwrap(); + sockopt::set_tcp_keepintvl(s, Duration::from_secs(61)).unwrap(); assert_eq!( - sockopt::get_tcp_keepintvl(&s).unwrap(), + sockopt::get_tcp_keepintvl(s).unwrap(), Duration::from_secs(61) ); } @@ -248,9 +245,9 @@ fn test_sockopts_tcp(s: &OwnedFd) { // Check the initial value of TCP_QUICKACK, set it, and check it. #[cfg(any(linux_like, target_os = "fuchsia"))] { - assert!(sockopt::get_tcp_quickack(&s).unwrap()); - sockopt::set_tcp_quickack(&s, false).unwrap(); - assert!(!sockopt::get_tcp_quickack(&s).unwrap()); + assert!(sockopt::get_tcp_quickack(s).unwrap()); + sockopt::set_tcp_quickack(s, false).unwrap(); + assert!(!sockopt::get_tcp_quickack(s).unwrap()); } // Check the initial value of TCP_CONGESTION, set it, and check it. @@ -266,12 +263,12 @@ fn test_sockopts_tcp(s: &OwnedFd) { ))] #[cfg(feature = "alloc")] { - let algo = sockopt::get_tcp_congestion(&s).unwrap(); + let algo = sockopt::get_tcp_congestion(s).unwrap(); assert!(!algo.is_empty()); #[cfg(linux_like)] { - sockopt::set_tcp_congestion(&s, "reno").unwrap(); - assert_eq!(sockopt::get_tcp_congestion(&s).unwrap(), "reno"); + sockopt::set_tcp_congestion(s, "reno").unwrap(); + assert_eq!(sockopt::get_tcp_congestion(s).unwrap(), "reno"); } } @@ -279,17 +276,17 @@ fn test_sockopts_tcp(s: &OwnedFd) { // it. #[cfg(any(linux_like, target_os = "fuchsia"))] { - assert!(!sockopt::get_tcp_thin_linear_timeouts(&s).unwrap()); - sockopt::set_tcp_thin_linear_timeouts(&s, true).unwrap(); - assert!(sockopt::get_tcp_thin_linear_timeouts(&s).unwrap()); + assert!(!sockopt::get_tcp_thin_linear_timeouts(s).unwrap()); + sockopt::set_tcp_thin_linear_timeouts(s, true).unwrap(); + assert!(sockopt::get_tcp_thin_linear_timeouts(s).unwrap()); } // Check the initial value of TCP_CORK, set it, and check it. #[cfg(any(linux_like, solarish, target_os = "fuchsia"))] { - assert!(!sockopt::get_tcp_cork(&s).unwrap()); - sockopt::set_tcp_cork(&s, true).unwrap(); - assert!(sockopt::get_tcp_cork(&s).unwrap()); + assert!(!sockopt::get_tcp_cork(s).unwrap()); + sockopt::set_tcp_cork(s, true).unwrap(); + assert!(sockopt::get_tcp_cork(s).unwrap()); } } @@ -407,7 +404,7 @@ fn test_sockopts_ipv6() { Err(io::Errno::OPNOTSUPP) => (), Err(io::Errno::INVAL) => (), Err(io::Errno::NOPROTOOPT) => (), - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), } assert_ne!(sockopt::get_ipv6_unicast_hops(&s).unwrap(), 0); @@ -418,7 +415,7 @@ fn test_sockopts_ipv6() { Ok(hops) => assert_eq!(hops, 0), Err(io::Errno::NOPROTOOPT) => (), Err(io::Errno::INVAL) => (), - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), }; // Set the IPV4 V6OONLY value. @@ -434,13 +431,13 @@ fn test_sockopts_ipv6() { // Check that the IPV6 multicast loop value is set. match sockopt::get_ipv6_multicast_loop(&s) { Ok(multicast_loop) => assert!(!multicast_loop), - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), } } Err(io::Errno::OPNOTSUPP) => (), Err(io::Errno::INVAL) => (), Err(io::Errno::NOPROTOOPT) => (), - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), } // Set the IPV6 unicast hops value to the default value. diff --git a/tests/process/procctl.rs b/tests/process/procctl.rs index ff552d574..5c8622fa3 100644 --- a/tests/process/procctl.rs +++ b/tests/process/procctl.rs @@ -16,7 +16,7 @@ fn test_reaper_status() { match set_reaper_status(false).unwrap_err() { io::Errno::INVAL => (), io::Errno::PERM => return, // FreeBSD 12 doesn't support this - err => Err(err).unwrap(), + err => panic!("{:?}", err), }; set_reaper_status(true).unwrap(); let status_while_acq = dbg!(get_reaper_status(None).unwrap()); @@ -45,7 +45,7 @@ fn test_no_new_privs() { match no_new_privs(None) { Ok(flag) => assert!(!flag), Err(io::Errno::INVAL) => return, // FreeBSD 12 doesn't support this - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), }; set_no_new_privs(None).unwrap(); assert!(no_new_privs(None).unwrap()); diff --git a/tests/process/rlimit.rs b/tests/process/rlimit.rs index a83873385..da191b677 100644 --- a/tests/process/rlimit.rs +++ b/tests/process/rlimit.rs @@ -35,7 +35,7 @@ fn test_setrlimit() { let old = match rustix::process::prlimit(None, Resource::Core, new.clone()) { Ok(rlimit) => rlimit, Err(rustix::io::Errno::NOSYS) => return, - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), }; assert_eq!(first, old); diff --git a/tests/process/working_directory.rs b/tests/process/working_directory.rs index 2b4f4e244..e3ed56818 100644 --- a/tests/process/working_directory.rs +++ b/tests/process/working_directory.rs @@ -15,7 +15,7 @@ fn test_changing_working_directory() { let tmpdir = tmpdir(); let orig_cwd = rustix::process::getcwd(Vec::new()).expect("get the cwd"); - assert!(orig_cwd.to_str().unwrap().starts_with("/")); + assert!(orig_cwd.to_str().unwrap().starts_with('/')); assert_eq!( orig_cwd.to_str().unwrap(), diff --git a/tests/pty/openpty.rs b/tests/pty/openpty.rs index 71e7ed6bd..3c1153a17 100644 --- a/tests/pty/openpty.rs +++ b/tests/pty/openpty.rs @@ -20,7 +20,7 @@ fn openpty_basic() { Ok(name) => name, #[cfg(target_os = "freebsd")] Err(rustix::io::Errno::NOSYS) => return, // FreeBSD 12 doesn't support this - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), }; let user = openat( CWD, diff --git a/tests/termios/pgrp.rs b/tests/termios/pgrp.rs index 063f65e73..6b9e2a798 100644 --- a/tests/termios/pgrp.rs +++ b/tests/termios/pgrp.rs @@ -30,7 +30,7 @@ fn pgrp_pseudoterminal() { let pty = match openpt(OpenptFlags::NOCTTY) { Ok(pty) => pty, Err(rustix::io::Errno::NOSYS) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; // Linux's `tcgetpgrp` returns 0 here, which is not documented, so rustix @@ -50,6 +50,6 @@ fn pgrp_pseudoterminal() { rustix::io::Errno::PERM => {} #[cfg(any(apple, linux_kernel))] rustix::io::Errno::NOTTY => {} - err => Err(err).unwrap(), + err => panic!("{:?}", err), } } diff --git a/tests/termios/termios.rs b/tests/termios/termios.rs index 4448f86ce..0e4071640 100644 --- a/tests/termios/termios.rs +++ b/tests/termios/termios.rs @@ -6,14 +6,14 @@ fn test_termios_flush() { let pty = match openpt(OpenptFlags::empty()) { Ok(pty) => pty, Err(rustix::io::Errno::NOSYS) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; let tio = match tcgetattr(&pty) { Ok(tio) => tio, Err(rustix::io::Errno::NOSYS) => return, #[cfg(apple)] Err(rustix::io::Errno::NOTTY) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; tcsetattr(&pty, OptionalActions::Now, &tio).unwrap(); @@ -28,14 +28,14 @@ fn test_termios_drain() { let pty = match openpt(OpenptFlags::empty()) { Ok(pty) => pty, Err(rustix::io::Errno::NOSYS) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; let tio = match tcgetattr(&pty) { Ok(tio) => tio, Err(rustix::io::Errno::NOSYS) => return, #[cfg(apple)] Err(rustix::io::Errno::NOTTY) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; tcsetattr(&pty, OptionalActions::Now, &tio).unwrap(); @@ -50,7 +50,7 @@ fn test_termios_winsize() { let pty = match openpt(OpenptFlags::empty()) { Ok(pty) => pty, Err(rustix::io::Errno::NOSYS) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; // Sizes for a pseudoterminal start out 0. @@ -59,7 +59,7 @@ fn test_termios_winsize() { // Apple doesn't appear to support `tcgetwinsize` on a pty. #[cfg(apple)] Err(rustix::io::Errno::NOTTY) => return, - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), }; assert_eq!(sizes.ws_row, 0); assert_eq!(sizes.ws_col, 0); @@ -92,14 +92,14 @@ fn test_termios_speeds() { let pty = match openpt(OpenptFlags::empty()) { Ok(pty) => pty, Err(rustix::io::Errno::NOSYS) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; let mut tio = match tcgetattr(&pty) { Ok(tio) => tio, Err(rustix::io::Errno::NOSYS) => return, #[cfg(apple)] Err(rustix::io::Errno::NOTTY) => return, - Err(e) => Err(e).unwrap(), + Err(err) => panic!("{:?}", err), }; // Assume it doesn't default to 50, and then set it to 50. diff --git a/tests/termios/ttyname.rs b/tests/termios/ttyname.rs index e9a977775..b6c050c1b 100644 --- a/tests/termios/ttyname.rs +++ b/tests/termios/ttyname.rs @@ -8,12 +8,12 @@ fn test_ttyname_ok() { let file = match File::open("/dev/stdin") { Ok(file) => file, Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => return, - Err(err) => Err(err).unwrap(), + Err(err) => panic!("{:?}", err), }; if isatty(&file) { let name = ttyname(&file, Vec::new()).unwrap().into_string().unwrap(); assert!(name.starts_with("/dev/")); - assert!(!name.ends_with("/")); + assert!(!name.ends_with('/')); assert!(std::fs::metadata(&name) .unwrap() .file_type()