2015-03-24 18:49:51 -05:00
|
|
|
#!/usr/bin/env python
|
2015-03-24 19:10:02 -05:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2015-03-24 18:49:51 -05:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import functools
|
|
|
|
|
|
|
|
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():
|
2015-03-24 19:14:45 -05:00
|
|
|
if any(map(lambda x: sys.platform.startswith(x), platforms)):
|
2015-03-24 18:49:51 -05:00
|
|
|
func()
|
|
|
|
return inner
|
|
|
|
return decorator
|
|
|
|
|
|
|
|
|
2015-03-24 19:14:29 -05:00
|
|
|
@only_on(('linux', 'darwin', 'freebsd', 'openbsd'))
|
2015-03-24 18:49:51 -05:00
|
|
|
def check_rlimit_core():
|
2015-05-10 04:08:48 -05:00
|
|
|
import resource
|
2015-03-24 18:49:51 -05:00
|
|
|
soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
|
|
|
|
if soft > 0:
|
2015-03-27 18:54:56 -05:00
|
|
|
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))
|
2015-03-24 18:49:51 -05:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
check_rlimit_core()
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
sys.exit(STATUS)
|