about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-09-11 14:06:27 +1000
committerGitHub <noreply@github.com>2025-09-11 14:06:27 +1000
commitcc51a7efeb50752b21b4b935a02ab5bba423e8bc (patch)
tree7d283c40c857088a0c23d72c08e9268c95490b83 /tests
parent602841dc8c4b9d58d663b4d8a23d91172c45274d (diff)
parentef95c63816bcc6f217601abf308b1b1561340731 (diff)
downloadrust-cc51a7efeb50752b21b4b935a02ab5bba423e8bc.tar.gz
rust-cc51a7efeb50752b21b4b935a02ab5bba423e8bc.zip
Rollup merge of #146335 - arielb1:dont-dump-core, r=nnethercote
disable core dumps for panic-uninitialized-zeroed

That test causes a large amount of crashes. If a system has a /proc/sys/kernel/core_pattern that uploads core dumps enabled, it will take a long time to complete. Set dumpable to 0 to avoid that.

Before:
```
$ time ./panic-uninitialized-zeroed

real    0m47.457s
user    0m0.023s
sys     0m0.021s
```

After:
```
$ ./panic-uninitialized-zeroed

real    0m0.029s
user    0m0.019s
sys     0m0.010s
```
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/intrinsics/panic-uninitialized-zeroed.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs
index cdf8aa85482..db2b4a6ad20 100644
--- a/tests/ui/intrinsics/panic-uninitialized-zeroed.rs
+++ b/tests/ui/intrinsics/panic-uninitialized-zeroed.rs
@@ -5,9 +5,10 @@
 //@ [strict]compile-flags: -Zstrict-init-checks
 //@ needs-subprocess
 //@ ignore-backends: gcc
+//@ edition:2024
 
 #![allow(deprecated, invalid_value)]
-#![feature(never_type)]
+#![feature(never_type, rustc_private)]
 
 use std::{
     mem::{self, MaybeUninit, ManuallyDrop},
@@ -15,6 +16,9 @@ use std::{
     num,
 };
 
+#[cfg(target_os = "linux")]
+extern crate libc;
+
 #[allow(dead_code)]
 struct Foo {
     x: u8,
@@ -108,6 +112,17 @@ fn test_panic_msg_only_if_strict<T>(op: impl (FnOnce() -> T) + 'static, msg: &st
 
 fn main() {
     unsafe {
+        #[cfg(target_os = "linux")]
+        {
+            // This test causes a large amount of crashes. If a system
+            // has a /proc/sys/kernel/core_pattern that uploads core dumps enabled,
+            // it will take a long time to complete. Set dumpable to 0 to avoid that.
+            if libc::prctl(libc::PR_SET_DUMPABLE, 0) < 0 {
+                let err = std::io::Error::last_os_error();
+                panic!("failed to disable core dumps {err:?}");
+            }
+        }
+
         // Uninhabited types
         test_panic_msg(
             || mem::uninitialized::<!>(),