blob: ee612c2bc909debcfde76e6f25c7d1bfceca57dc [file] [log] [blame]
Nick Coghlanc95ec3d2011-03-16 19:52:14 -04001# Tests that the crashers in the Lib/test/crashers directory actually
2# do crash the interpreter as expected
3#
4# If a crasher is fixed, it should be moved elsewhere in the test suite to
5# ensure it continues to work correctly.
6
7import unittest
8import glob
9import os.path
10import test.support
11from test.script_helper import assert_python_failure
12
13CRASHER_DIR = os.path.join(os.path.dirname(__file__), "crashers")
14CRASHER_FILES = os.path.join(CRASHER_DIR, "*.py")
15
16infinite_loops = ["infinite_loop_re.py", "nasty_eq_vs_dict.py"]
17
18class CrasherTest(unittest.TestCase):
19
20 @test.support.cpython_only
21 def test_crashers_crash(self):
22 for fname in glob.glob(CRASHER_FILES):
23 if os.path.basename(fname) in infinite_loops:
24 continue
25 # Some "crashers" only trigger an exception rather than a
26 # segfault. Consider that an acceptable outcome.
27 assert_python_failure(fname)
28
29
30def test_main():
31 test.support.run_unittest(CrasherTest)
32 test.support.reap_children()
33
34if __name__ == "__main__":
35 test_main()