From 7a4615e4477518efdd6c0e67fa387121685018ce Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Tue, 24 Mar 2015 16:49:51 -0700 Subject: [PATCH 1/6] check: Warn users with nonzero RLIMIT_CORE --- mk/tests.mk | 7 +++++- src/etc/check-sanitycheck.py | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/etc/check-sanitycheck.py diff --git a/mk/tests.mk b/mk/tests.mk index e9f1baa8d4ef0..48ebe4e540e3d 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 0000000000000..1ac1c3fefb5ac --- /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) From c40ec080ffdc2222c69c5e0feed543b38c5f99ba Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Tue, 24 Mar 2015 17:10:02 -0700 Subject: [PATCH 2/6] check: Add license --- src/etc/check-sanitycheck.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/etc/check-sanitycheck.py b/src/etc/check-sanitycheck.py index 1ac1c3fefb5ac..f7da47556909c 100644 --- a/src/etc/check-sanitycheck.py +++ b/src/etc/check-sanitycheck.py @@ -1,4 +1,15 @@ #!/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 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + import os import sys import functools From 93fc804b85b856aa84455cdcee5f4ae51b51a25a Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Tue, 24 Mar 2015 17:14:29 -0700 Subject: [PATCH 3/6] check: Run the rlimit_core check on *BSD --- src/etc/check-sanitycheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/check-sanitycheck.py b/src/etc/check-sanitycheck.py index f7da47556909c..c5df15aa177f9 100644 --- a/src/etc/check-sanitycheck.py +++ b/src/etc/check-sanitycheck.py @@ -35,7 +35,7 @@ def inner(): return decorator -@only_on(('linux', 'darwin')) +@only_on(('linux', 'darwin', 'freebsd', 'openbsd')) def check_rlimit_core(): soft, hard = resource.getrlimit(resource.RLIMIT_CORE) if soft > 0: From e4f9ce8cbf9d5a110afb7274c393abb333e01a2b Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Tue, 24 Mar 2015 17:14:45 -0700 Subject: [PATCH 4/6] check: Fix the check for platform formatting --- src/etc/check-sanitycheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/check-sanitycheck.py b/src/etc/check-sanitycheck.py index c5df15aa177f9..cb34fa20531fa 100644 --- a/src/etc/check-sanitycheck.py +++ b/src/etc/check-sanitycheck.py @@ -29,7 +29,7 @@ def only_on(platforms): def decorator(func): @functools.wraps(func) def inner(): - if sys.platform in platforms: + if any(map(lambda x: sys.platform.startswith(x), platforms)): func() return inner return decorator From 146264c6ae057d6418b8c1063526183254b245ba Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Fri, 27 Mar 2015 16:54:46 -0700 Subject: [PATCH 5/6] check: Name the sentinal variable more sanely --- src/etc/check-sanitycheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/check-sanitycheck.py b/src/etc/check-sanitycheck.py index cb34fa20531fa..5822cc0259fef 100644 --- a/src/etc/check-sanitycheck.py +++ b/src/etc/check-sanitycheck.py @@ -39,7 +39,7 @@ def inner(): def check_rlimit_core(): soft, hard = resource.getrlimit(resource.RLIMIT_CORE) if soft > 0: - error_unless_permitted('ALLOW_NONZERO_ULIMIT', + error_unless_permitted('ALLOW_NONZERO_RLIMIT_CORE', ("The rust test suite will segfault many rustc's in the debuginfo phase.\n" "set ALLOW_NONZERO_ULIMIT to ignore this warning\n")) From 4af204ddee0fbb61eddf9579ede9f0214c942ba0 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Fri, 27 Mar 2015 16:54:56 -0700 Subject: [PATCH 6/6] check: Reword the warning to be more prescriptive --- src/etc/check-sanitycheck.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/etc/check-sanitycheck.py b/src/etc/check-sanitycheck.py index 5822cc0259fef..0d9c430ec3acd 100644 --- a/src/etc/check-sanitycheck.py +++ b/src/etc/check-sanitycheck.py @@ -39,9 +39,11 @@ def inner(): def check_rlimit_core(): soft, hard = resource.getrlimit(resource.RLIMIT_CORE) if soft > 0: - error_unless_permitted('ALLOW_NONZERO_RLIMIT_CORE', - ("The rust test suite will segfault many rustc's in the debuginfo phase.\n" - "set ALLOW_NONZERO_ULIMIT to ignore this warning\n")) + 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():