summaryrefslogtreecommitdiffstats
path: root/tests/run-make/dump-ice-to-disk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /tests/run-make/dump-ice-to-disk
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/run-make/dump-ice-to-disk')
-rw-r--r--tests/run-make/dump-ice-to-disk/Makefile10
-rw-r--r--tests/run-make/dump-ice-to-disk/check.sh58
-rw-r--r--tests/run-make/dump-ice-to-disk/src/lib.rs7
3 files changed, 75 insertions, 0 deletions
diff --git a/tests/run-make/dump-ice-to-disk/Makefile b/tests/run-make/dump-ice-to-disk/Makefile
new file mode 100644
index 000000000..23006fc09
--- /dev/null
+++ b/tests/run-make/dump-ice-to-disk/Makefile
@@ -0,0 +1,10 @@
+include ../tools.mk
+
+# ignore-windows
+
+export RUSTC := $(RUSTC_ORIGINAL)
+export LD_LIBRARY_PATH := $(HOST_RPATH_DIR)
+export TMPDIR := $(TMPDIR)
+
+all:
+ bash check.sh
diff --git a/tests/run-make/dump-ice-to-disk/check.sh b/tests/run-make/dump-ice-to-disk/check.sh
new file mode 100644
index 000000000..ab6f9ab60
--- /dev/null
+++ b/tests/run-make/dump-ice-to-disk/check.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# Default nightly behavior (write ICE to current directory)
+# FIXME(estebank): these are failing on CI, but passing locally.
+# $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default.log 2>&1
+# default=$(cat ./rustc-ice-*.txt | wc -l)
+# rm ./rustc-ice-*.txt
+
+# Explicit directory set
+export RUSTC_ICE=$TMPDIR
+$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default-set.log 2>&1
+default_set=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
+content=$(cat $TMPDIR/rustc-ice-*.txt)
+rm $TMPDIR/rustc-ice-*.txt
+RUST_BACKTRACE=short $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-short.log 2>&1
+short=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
+rm $TMPDIR/rustc-ice-*.txt
+RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-full.log 2>&1
+full=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
+rm $TMPDIR/rustc-ice-*.txt
+
+# Explicitly disabling ICE dump
+export RUSTC_ICE=0
+$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-disabled.log 2>&1
+should_be_empty_tmp=$(ls -l $TMPDIR/rustc-ice-*.txt 2>/dev/null | wc -l)
+should_be_empty_dot=$(ls -l ./rustc-ice-*.txt 2>/dev/null | wc -l)
+
+echo "#### ICE Dump content:"
+echo $content
+echo "#### default length:"
+echo $default
+echo "#### short length:"
+echo $short
+echo "#### default_set length:"
+echo $default_set
+echo "#### full length:"
+echo $full
+echo "#### should_be_empty_dot length:"
+echo $should_be_empty_dot
+echo "#### should_be_empty_tmp length:"
+echo $should_be_empty_tmp
+
+## Verify that a the ICE dump file is created in the appropriate directories, that
+## their lengths are the same regardless of other backtrace configuration options,
+## that the file is not created when asked to (RUSTC_ICE=0) and that the file
+## contains at least part of the expected content.
+if [ $short -eq $default_set ] &&
+ #[ $default -eq $short ] &&
+ [ $default_set -eq $full ] &&
+ [[ $content == *"thread 'rustc' panicked at "* ]] &&
+ [[ $content == *"stack backtrace:"* ]] &&
+ #[ $default -gt 0 ] &&
+ [ $should_be_empty_dot -eq 0 ] &&
+ [ $should_be_empty_tmp -eq 0 ]; then
+ exit 0
+else
+ exit 1
+fi
diff --git a/tests/run-make/dump-ice-to-disk/src/lib.rs b/tests/run-make/dump-ice-to-disk/src/lib.rs
new file mode 100644
index 000000000..b23b7f830
--- /dev/null
+++ b/tests/run-make/dump-ice-to-disk/src/lib.rs
@@ -0,0 +1,7 @@
+fn func(s: &str) {
+ println!("{}", s);
+}
+
+fn main() {
+ func(1);
+}