blob: 58dfd001da3627fd96f49922dd63078bc7e9cc78 [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
Berker Peksagce643912015-05-06 06:33:17 +030011from test.support.script_helper import assert_python_failure
Nick Coghlanc95ec3d2011-03-16 19:52:14 -040012
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
Antoine Pitrou89ba56d2011-03-19 19:54:01 +010020 @unittest.skip("these tests are too fragile")
Nick Coghlanc95ec3d2011-03-16 19:52:14 -040021 @test.support.cpython_only
22 def test_crashers_crash(self):
23 for fname in glob.glob(CRASHER_FILES):
24 if os.path.basename(fname) in infinite_loops:
25 continue
26 # Some "crashers" only trigger an exception rather than a
27 # segfault. Consider that an acceptable outcome.
Nick Coghlanf694a402011-03-17 11:04:34 -040028 if test.support.verbose:
29 print("Checking crasher:", fname)
Nick Coghlanc95ec3d2011-03-16 19:52:14 -040030 assert_python_failure(fname)
31
32
Zachary Ware38c707e2015-04-13 15:00:43 -050033def tearDownModule():
Nick Coghlanc95ec3d2011-03-16 19:52:14 -040034 test.support.reap_children()
35
36if __name__ == "__main__":
Zachary Ware38c707e2015-04-13 15:00:43 -050037 unittest.main()