about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRicho Healey <richo@psych0tik.net>2015-03-24 16:49:51 -0700
committerRicho Healey <richo@psych0tik.net>2015-03-27 16:50:37 -0700
commit7a4615e4477518efdd6c0e67fa387121685018ce (patch)
treee355ee91c9cbd004335df83b11cf2248199e4d67
parent0c9de8140b8abdd2d0a83db93746c58e8bc0da2c (diff)
downloadrust-7a4615e4477518efdd6c0e67fa387121685018ce.tar.gz
rust-7a4615e4477518efdd6c0e67fa387121685018ce.zip
check: Warn users with nonzero RLIMIT_CORE
-rw-r--r--mk/tests.mk7
-rw-r--r--src/etc/check-sanitycheck.py41
2 files changed, 47 insertions, 1 deletions
diff --git a/mk/tests.mk b/mk/tests.mk
index e9f1baa8d4e..48ebe4e540e 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -166,7 +166,7 @@ $(foreach file,$(wildcard $(S)src/doc/trpl/*.md), \
 ######################################################################
 
 # The main testing target. Tests lots of stuff.
-check: cleantmptestlogs cleantestlibs all check-stage2 tidy
+check: check-sanitycheck cleantmptestlogs cleantestlibs all check-stage2 tidy
 	$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
 
 # As above but don't bother running tidy.
@@ -193,6 +193,11 @@ check-docs: cleantestlibs cleantmptestlogs check-stage2-docs
 # Not run as part of the normal test suite, but tested by bors on checkin.
 check-secondary: check-build-compiletest check-build-lexer-verifier check-lexer check-pretty
 
+.PHONY: check-sanitycheck
+
+check-sanitycheck:
+	$(Q)$(CFG_PYTHON) $(S)src/etc/check-sanitycheck.py
+
 # check + check-secondary.
 #
 # Issue #17883: build check-secondary first so hidden dependencies in
diff --git a/src/etc/check-sanitycheck.py b/src/etc/check-sanitycheck.py
new file mode 100644
index 00000000000..1ac1c3fefb5
--- /dev/null
+++ b/src/etc/check-sanitycheck.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+import os
+import sys
+import functools
+import resource
+
+STATUS = 0
+
+
+def error_unless_permitted(env_var, message):
+    global STATUS
+    if not os.getenv(env_var):
+        sys.stderr.write(message)
+        STATUS = 1
+
+
+def only_on(platforms):
+    def decorator(func):
+        @functools.wraps(func)
+        def inner():
+            if sys.platform in platforms:
+                func()
+        return inner
+    return decorator
+
+
+@only_on(('linux', 'darwin'))
+def check_rlimit_core():
+    soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
+    if soft > 0:
+        error_unless_permitted('ALLOW_NONZERO_ULIMIT',
+          ("The rust test suite will segfault many rustc's in the debuginfo phase.\n"
+           "set ALLOW_NONZERO_ULIMIT to ignore this warning\n"))
+
+
+def main():
+    check_rlimit_core()
+
+if __name__ == '__main__':
+    main()
+    sys.exit(STATUS)