summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-03-31 18:26:20 +0000
committerbors <bors@rust-lang.org>2015-03-31 18:26:20 +0000
commitd754722a04b99fdcae0fd97fa2a4395521145ef2 (patch)
tree41d2bff3aec8a949d71d74d566da27627996cabb /src
parent80bf31dd514055177b22c3dc66836d39eb5b1648 (diff)
parent4af204ddee0fbb61eddf9579ede9f0214c942ba0 (diff)
downloadrust-d754722a04b99fdcae0fd97fa2a4395521145ef2.tar.gz
rust-d754722a04b99fdcae0fd97fa2a4395521145ef2.zip
Auto merge of #23678 - richo:check-flightcheck, r=alexcrichton
Rationale for this, is that I lurked `ulimit -c unlimited` into my .profile to debug an unrelated crash, that I kept forgetting to set before hand. I then ran the test suite and discovered that I had 150 gigs of core dumps in `/cores`.

Very open to another approach, or to setting the limit to something higher than 0, but I think it would be nice if the build system tried to save you from yourself here.
Diffstat (limited to 'src')
-rw-r--r--src/etc/check-sanitycheck.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/etc/check-sanitycheck.py b/src/etc/check-sanitycheck.py
new file mode 100644
index 00000000000..0d9c430ec3a
--- /dev/null
+++ b/src/etc/check-sanitycheck.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+#
+# Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+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 any(map(lambda x: sys.platform.startswith(x), platforms)):
+                func()
+        return inner
+    return decorator
+
+
+@only_on(('linux', 'darwin', 'freebsd', 'openbsd'))
+def check_rlimit_core():
+    soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
+    if soft > 0:
+        error_unless_permitted('ALLOW_NONZERO_RLIMIT_CORE', """\
+RLIMIT_CORE is set to a nonzero value (%d). During debuginfo, the test suite
+will segfault many rustc's, creating many potentially large core files.
+set ALLOW_NONZERO_RLIMIT_CORE to ignore this warning
+""" % (soft))
+
+
+def main():
+    check_rlimit_core()
+
+if __name__ == '__main__':
+    main()
+    sys.exit(STATUS)