Skip to content

Commit 7a4615e

Browse files
committed
check: Warn users with nonzero RLIMIT_CORE
1 parent 0c9de81 commit 7a4615e

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

mk/tests.mk

Lines changed: 6 additions & 1 deletion
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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
import functools
5+
import resource
6+
7+
STATUS = 0
8+
9+
10+
def error_unless_permitted(env_var, message):
11+
global STATUS
12+
if not os.getenv(env_var):
13+
sys.stderr.write(message)
14+
STATUS = 1
15+
16+
17+
def only_on(platforms):
18+
def decorator(func):
19+
@functools.wraps(func)
20+
def inner():
21+
if sys.platform in platforms:
22+
func()
23+
return inner
24+
return decorator
25+
26+
27+
@only_on(('linux', 'darwin'))
28+
def check_rlimit_core():
29+
soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
30+
if soft > 0:
31+
error_unless_permitted('ALLOW_NONZERO_ULIMIT',
32+
("The rust test suite will segfault many rustc's in the debuginfo phase.\n"
33+
"set ALLOW_NONZERO_ULIMIT to ignore this warning\n"))
34+
35+
36+
def main():
37+
check_rlimit_core()
38+
39+
if __name__ == '__main__':
40+
main()
41+
sys.exit(STATUS)

0 commit comments

Comments
 (0)