Skip to content

Commit c70c82d

Browse files
committed
Add run-make test for ICE dump
1 parent e6504df commit c70c82d

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
include ../tools.mk
2+
3+
# ignore-windows
4+
5+
export RUSTC := $(RUSTC_ORIGINAL)
6+
export TMPDIR := $(TMPDIR)
7+
8+
all:
9+
bash check.sh
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/sh
2+
3+
# Default nightly behavior (write ICE to current directory)
4+
$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default.log 2>&1
5+
content=$(cat ./rustc-ice-*.txt)
6+
default=$(cat ./rustc-ice-*.txt | wc -l)
7+
rm ./rustc-ice-*.txt
8+
9+
# Explicit directory set
10+
export RUSTC_ICE=$TMPDIR
11+
$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default-set.log 2>&1
12+
default_set=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
13+
rm $TMPDIR/rustc-ice-*.txt
14+
RUST_BACKTRACE=short $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-short.log 2>&1
15+
short=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
16+
rm $TMPDIR/rustc-ice-*.txt
17+
RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-full.log 2>&1
18+
full=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
19+
rm $TMPDIR/rustc-ice-*.txt
20+
21+
# Explicitly disabling ICE dump
22+
export RUSTC_ICE=0
23+
$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-disabled.log 2>&1
24+
should_be_empty_tmp=$(ls -l $TMPDIR/rustc-ice-*.txt | wc -l)
25+
should_be_empty_dot=$(ls -l ./rustc-ice-*.txt | wc -l)
26+
27+
echo "#### ICE Dump content:"
28+
echo $content
29+
echo "#### default length:"
30+
echo $default
31+
echo "#### short length:"
32+
echo $short
33+
echo "#### default_set length:"
34+
echo $default_set
35+
echo "#### full length:"
36+
echo $full
37+
echo "#### should_be_empty_dot length:"
38+
echo $should_be_empty_dot
39+
echo "#### should_be_empty_tmp length:"
40+
echo $should_be_empty_tmp
41+
42+
## Verify that a the ICE dump file is created in the appropriate directories, that
43+
## their lengths are the same regardless of other backtrace configuration options,
44+
## that the file is not created when asked to (RUSTC_ICE=0) and that the file
45+
## contains at least part of the expected content.
46+
if [ $default -eq $short ] &&
47+
[ $short -eq $default_set ] &&
48+
[ $default_set -eq $full ] &&
49+
[ $should_be_empty_dot -eq 0 ] &&
50+
[ $should_be_empty_tmp -eq 0 ] &&
51+
[[ $content == *"thread 'rustc' panicked at "* ]] &&
52+
[[ $content == *"stack backtrace:"* ]] &&
53+
[ $default -gt 0 ]; then
54+
exit 0
55+
else
56+
exit 1
57+
fi
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn func(s: &str) {
2+
println!("{}", s);
3+
}
4+
5+
fn main() {
6+
func(1);
7+
}

0 commit comments

Comments
 (0)