about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-11-16 19:35:13 +0100
committerRalf Jung <post@ralfj.de>2023-11-16 21:32:04 +0100
commit70cc63958063a42418858be21f5b19c6b0a3f4a4 (patch)
treee999261dcadf5777c53876830769087cdd3c3c5c /src/tools
parent6985431923ccd3111cc16680db441c55f9aaf6b4 (diff)
downloadrust-70cc63958063a42418858be21f5b19c6b0a3f4a4.tar.gz
rust-70cc63958063a42418858be21f5b19c6b0a3f4a4.zip
move reallocarray test into libc-misc
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/miri/ci.sh2
-rw-r--r--src/tools/miri/tests/pass-dep/shims/libc-misc.rs17
-rw-r--r--src/tools/miri/tests/pass-dep/shims/libc-reallocarray.rs16
3 files changed, 18 insertions, 17 deletions
diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh
index 2bb151c3464..dbfb4eca3f3 100755
--- a/src/tools/miri/ci.sh
+++ b/src/tools/miri/ci.sh
@@ -108,7 +108,7 @@ case $HOST_TARGET in
     MIRI_TEST_TARGET=aarch64-unknown-linux-gnu run_tests
     MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
     MIRI_TEST_TARGET=i686-pc-windows-gnu run_tests
-    MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthreads-threadname libc-getentropy libc-getrandom libc-reallocarray libc-misc atomic env/var
+    MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple pthreads-threadname libc-getentropy libc-getrandom libc-misc atomic env/var
     MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
     MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings wasm
     MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings wasm
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 0374158ea56..de1acb13cbe 100644
--- a/src/tools/miri/tests/pass-dep/shims/libc-misc.rs
+++ b/src/tools/miri/tests/pass-dep/shims/libc-misc.rs
@@ -390,6 +390,19 @@ fn test_dlsym() {
     assert_eq!(errno, libc::EBADF);
 }
 
+#[cfg(not(target_os = "macos"))]
+fn test_reallocarray() {
+    unsafe {
+        let mut p = libc::reallocarray(std::ptr::null_mut(), 4096, 2);
+        assert!(!p.is_null());
+        libc::free(p);
+        p = libc::malloc(16);
+        let r = libc::reallocarray(p, 2, 32);
+        assert!(!r.is_null());
+        libc::free(r);
+    }
+}
+
 fn main() {
     test_posix_gettimeofday();
 
@@ -412,6 +425,10 @@ fn main() {
     test_memcpy();
     test_strcpy();
 
+    #[cfg(not(target_os = "macos"))] // reallocarray does not exist on macOS
+    test_reallocarray();
+
+    // These are Linux-specific
     #[cfg(target_os = "linux")]
     {
         test_posix_fadvise();
diff --git a/src/tools/miri/tests/pass-dep/shims/libc-reallocarray.rs b/src/tools/miri/tests/pass-dep/shims/libc-reallocarray.rs
deleted file mode 100644
index 29a3a590852..00000000000
--- a/src/tools/miri/tests/pass-dep/shims/libc-reallocarray.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-//@ignore-target-windows: no libc
-//@ignore-target-apple: no support (yet)
-
-use core::ptr;
-
-fn main() {
-    unsafe {
-        let mut p = libc::reallocarray(ptr::null_mut(), 4096, 2);
-        assert!(!p.is_null());
-        libc::free(p);
-        p = libc::malloc(16);
-        let r = libc::reallocarray(p, 2, 32);
-        assert!(!r.is_null());
-        libc::free(r);
-    }
-}