diff options
| author | bors <bors@rust-lang.org> | 2023-10-06 09:11:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-06 09:11:14 +0000 |
| commit | 4587c7c1c044652a89104b8dccfd8e025aea177f (patch) | |
| tree | 0094bba66f69358d43c92766d5b3135578591a98 /src/tools/miri/tests | |
| parent | 413540837b904e7cdf5d2b5ff137867268868095 (diff) | |
| parent | 03a03e2ef66f80548681b8dbbf387b55e7b8a3cb (diff) | |
| download | rust-4587c7c1c044652a89104b8dccfd8e025aea177f.tar.gz rust-4587c7c1c044652a89104b8dccfd8e025aea177f.zip | |
Auto merge of #3109 - RalfJung:dlsym, r=RalfJung
add a direct dlsym test
Diffstat (limited to 'src/tools/miri/tests')
| -rw-r--r-- | src/tools/miri/tests/pass-dep/shims/libc-misc.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tools/miri/tests/pass-dep/shims/libc-misc.rs b/src/tools/miri/tests/pass-dep/shims/libc-misc.rs index ebfeb863abf..82c49cfb17c 100644 --- a/src/tools/miri/tests/pass-dep/shims/libc-misc.rs +++ b/src/tools/miri/tests/pass-dep/shims/libc-misc.rs @@ -3,6 +3,7 @@ #![feature(io_error_more)] use std::fs::{remove_file, File}; +use std::mem::transmute; use std::os::unix::io::AsRawFd; use std::path::PathBuf; @@ -375,6 +376,18 @@ fn test_sigrt() { assert!(max - min >= 8) } +fn test_dlsym() { + let addr = unsafe { libc::dlsym(libc::RTLD_DEFAULT, b"notasymbol\0".as_ptr().cast()) }; + assert!(addr as usize == 0); + + let addr = unsafe { libc::dlsym(libc::RTLD_DEFAULT, b"isatty\0".as_ptr().cast()) }; + assert!(addr as usize != 0); + let isatty: extern "C" fn(i32) -> i32 = unsafe { transmute(addr) }; + assert_eq!(isatty(999), 0); + let errno = std::io::Error::last_os_error().raw_os_error().unwrap(); + assert_eq!(errno, libc::EBADF); +} + fn main() { test_posix_gettimeofday(); test_posix_mkstemp(); @@ -387,6 +400,7 @@ fn main() { test_isatty(); test_clocks(); + test_dlsym(); test_memcpy(); test_strcpy(); |
