aboutsummaryrefslogtreecommitdiffstats
path: root/testing/rust/check-rustc
diff options
context:
space:
mode:
Diffstat (limited to 'testing/rust/check-rustc')
-rwxr-xr-xtesting/rust/check-rustc20
1 files changed, 20 insertions, 0 deletions
diff --git a/testing/rust/check-rustc b/testing/rust/check-rustc
index 867666e503..3a375005f2 100755
--- a/testing/rust/check-rustc
+++ b/testing/rust/check-rustc
@@ -34,6 +34,12 @@ assert_ok() {
"$1" || fail "$1 exited with status $?"
}
+assert_panic() {
+ local status=0
+ "$1" || status=$? && [ "$status" = 101 ] \
+ || fail "$1 exited with status $status, but expected 101"
+}
+
assert_pie() {
readelf -d "$1" | grep -Fw FLAGS_1 | grep -Fqw PIE || {
fail "$1 is not a PIE executable!"
@@ -83,4 +89,18 @@ assert_static hello_world
assert_pie hello_world
rm -f hello_world
+
+cat >> panic.rs <<-EOF
+ fn main() {
+ panic!("This should panic");
+ }
+EOF
+
+_rustc -C target-feature=-crt-static panic.rs
+assert_panic ./panic
+
+_rustc -C target-feature=+crt-static panic.rs
+assert_panic ./panic
+
+
[ "$failed" -eq 0 ] || die "$failed assertion(s) has failed"