Skip to content

Commit d754722

Browse files
committed
Auto merge of rust-lang#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.
2 parents 80bf31d + 4af204d commit d754722

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

mk/tests.mk

+6-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ $(foreach file,$(wildcard $(S)src/doc/trpl/*.md), \
166166
######################################################################
167167

168168
# The main testing target. Tests lots of stuff.
169-
check: cleantmptestlogs cleantestlibs all check-stage2 tidy
169+
check: check-sanitycheck cleantmptestlogs cleantestlibs all check-stage2 tidy
170170
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
171171

172172
# As above but don't bother running tidy.
@@ -193,6 +193,11 @@ check-docs: cleantestlibs cleantmptestlogs check-stage2-docs
193193
# Not run as part of the normal test suite, but tested by bors on checkin.
194194
check-secondary: check-build-compiletest check-build-lexer-verifier check-lexer check-pretty
195195

196+
.PHONY: check-sanitycheck
197+
198+
check-sanitycheck:
199+
$(Q)$(CFG_PYTHON) $(S)src/etc/check-sanitycheck.py
200+
196201
# check + check-secondary.
197202
#
198203
# Issue #17883: build check-secondary first so hidden dependencies in

src/etc/check-sanitycheck.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
4+
# file at the top-level directory of this distribution and at
5+
# http://rust-lang.org/COPYRIGHT.
6+
#
7+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10+
# option. This file may not be copied, modified, or distributed
11+
# except according to those terms.
12+
13+
import os
14+
import sys
15+
import functools
16+
import resource
17+
18+
STATUS = 0
19+
20+
21+
def error_unless_permitted(env_var, message):
22+
global STATUS
23+
if not os.getenv(env_var):
24+
sys.stderr.write(message)
25+
STATUS = 1
26+
27+
28+
def only_on(platforms):
29+
def decorator(func):
30+
@functools.wraps(func)
31+
def inner():
32+
if any(map(lambda x: sys.platform.startswith(x), platforms)):
33+
func()
34+
return inner
35+
return decorator
36+
37+
38+
@only_on(('linux', 'darwin', 'freebsd', 'openbsd'))
39+
def check_rlimit_core():
40+
soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
41+
if soft > 0:
42+
error_unless_permitted('ALLOW_NONZERO_RLIMIT_CORE', """\
43+
RLIMIT_CORE is set to a nonzero value (%d). During debuginfo, the test suite
44+
will segfault many rustc's, creating many potentially large core files.
45+
set ALLOW_NONZERO_RLIMIT_CORE to ignore this warning
46+
""" % (soft))
47+
48+
49+
def main():
50+
check_rlimit_core()
51+
52+
if __name__ == '__main__':
53+
main()
54+
sys.exit(STATUS)

0 commit comments

Comments
 (0)