]> git.proxmox.com Git - rustc.git/blame - src/etc/check-sanitycheck.py
Imported Upstream version 1.2.0+dfsg1
[rustc.git] / src / etc / check-sanitycheck.py
CommitLineData
c34b1796
AL
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
13import os
62682a34 14import subprocess
c34b1796
AL
15import sys
16import functools
c34b1796
AL
17
18STATUS = 0
19
c34b1796
AL
20def error_unless_permitted(env_var, message):
21 global STATUS
22 if not os.getenv(env_var):
23 sys.stderr.write(message)
24 STATUS = 1
25
c34b1796
AL
26def only_on(platforms):
27 def decorator(func):
28 @functools.wraps(func)
29 def inner():
30 if any(map(lambda x: sys.platform.startswith(x), platforms)):
31 func()
32 return inner
33 return decorator
34
62682a34 35@only_on(['linux', 'darwin', 'freebsd', 'openbsd'])
c34b1796 36def check_rlimit_core():
d9579d0f 37 import resource
c34b1796
AL
38 soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
39 if soft > 0:
40 error_unless_permitted('ALLOW_NONZERO_RLIMIT_CORE', """\
41RLIMIT_CORE is set to a nonzero value (%d). During debuginfo, the test suite
42will segfault many rustc's, creating many potentially large core files.
43set ALLOW_NONZERO_RLIMIT_CORE to ignore this warning
44""" % (soft))
45
62682a34
SL
46@only_on(['win32'])
47def check_console_code_page():
48 if '65001' not in subprocess.check_output(['cmd', '/c', 'chcp']):
49 sys.stderr.write('Warning: the console output code page is not UTF-8, \
50some tests may fail. Use `cmd /c "chcp 65001"` to setup UTF-8 code page.\n')
c34b1796
AL
51
52def main():
62682a34 53 check_console_code_page()
c34b1796
AL
54 check_rlimit_core()
55
56if __name__ == '__main__':
57 main()
58 sys.exit(STATUS)