]> git.lizzy.rs Git - rust.git/blob - src/etc/check-sanitycheck.py
Unignore u128 test for stage 0,1
[rust.git] / src / etc / check-sanitycheck.py
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 subprocess
15 import sys
16 import functools
17
18 STATUS = 0
19
20 def 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
26 def 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
35 @only_on(['linux', 'darwin', 'freebsd', 'openbsd'])
36 def check_rlimit_core():
37     import resource
38     soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
39     if soft > 0:
40         error_unless_permitted('ALLOW_NONZERO_RLIMIT_CORE', """\
41 RLIMIT_CORE is set to a nonzero value (%d). During debuginfo, the test suite
42 will segfault many rustc's, creating many potentially large core files.
43 set ALLOW_NONZERO_RLIMIT_CORE to ignore this warning
44 """ % (soft))
45
46 @only_on(['win32'])
47 def 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, \
50 some tests may fail. Use `cmd /c "chcp 65001"` to setup UTF-8 code page.\n')
51
52 def main():
53     check_console_code_page()
54     check_rlimit_core()
55
56 if __name__ == '__main__':
57     main()
58     sys.exit(STATUS)