diff options
| author | Ralf Jung <post@ralfj.de> | 2023-10-06 11:06:16 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-10-06 11:09:58 +0200 |
| commit | 03a03e2ef66f80548681b8dbbf387b55e7b8a3cb (patch) | |
| tree | 0094bba66f69358d43c92766d5b3135578591a98 /src/tools/miri/tests | |
| parent | 413540837b904e7cdf5d2b5ff137867268868095 (diff) | |
| download | rust-03a03e2ef66f80548681b8dbbf387b55e7b8a3cb.tar.gz rust-03a03e2ef66f80548681b8dbbf387b55e7b8a3cb.zip | |
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(); |
