From 5ad27d4b8bb248954d98178e068a382599dadfa6 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 10 Apr 2018 14:42:42 +1000 Subject: tests: Move recursive tests to the tests/stress/ subdir. Keeping all the stress related tests in one place makes it easier to stress-test a given port, and to also not run such tests on ports that can't handle them. --- tests/misc/recursion.py | 7 ----- tests/misc/recursive_data.py | 13 -------- tests/misc/recursive_data.py.exp | 1 - tests/misc/recursive_iternext.py | 57 ---------------------------------- tests/misc/recursive_iternext.py.exp | 4 --- tests/run-tests | 3 -- tests/stress/recursion.py | 7 +++++ tests/stress/recursive_data.py | 13 ++++++++ tests/stress/recursive_data.py.exp | 1 + tests/stress/recursive_iternext.py | 57 ++++++++++++++++++++++++++++++++++ tests/stress/recursive_iternext.py.exp | 4 +++ 11 files changed, 82 insertions(+), 85 deletions(-) delete mode 100644 tests/misc/recursion.py delete mode 100644 tests/misc/recursive_data.py delete mode 100644 tests/misc/recursive_data.py.exp delete mode 100644 tests/misc/recursive_iternext.py delete mode 100644 tests/misc/recursive_iternext.py.exp create mode 100644 tests/stress/recursion.py create mode 100644 tests/stress/recursive_data.py create mode 100644 tests/stress/recursive_data.py.exp create mode 100644 tests/stress/recursive_iternext.py create mode 100644 tests/stress/recursive_iternext.py.exp diff --git a/tests/misc/recursion.py b/tests/misc/recursion.py deleted file mode 100644 index 227f48396..000000000 --- a/tests/misc/recursion.py +++ /dev/null @@ -1,7 +0,0 @@ -def foo(): - foo() - -try: - foo() -except RuntimeError: - print("RuntimeError") diff --git a/tests/misc/recursive_data.py b/tests/misc/recursive_data.py deleted file mode 100644 index 3b7fa5095..000000000 --- a/tests/misc/recursive_data.py +++ /dev/null @@ -1,13 +0,0 @@ -# This tests that printing recursive data structure doesn't lead to segfault. -try: - import uio as io -except ImportError: - print("SKIP") - raise SystemExit - -l = [1, 2, 3, None] -l[-1] = l -try: - print(l, file=io.StringIO()) -except RuntimeError: - print("RuntimeError") diff --git a/tests/misc/recursive_data.py.exp b/tests/misc/recursive_data.py.exp deleted file mode 100644 index 8a2b9bfdd..000000000 --- a/tests/misc/recursive_data.py.exp +++ /dev/null @@ -1 +0,0 @@ -RuntimeError diff --git a/tests/misc/recursive_iternext.py b/tests/misc/recursive_iternext.py deleted file mode 100644 index edb5a843f..000000000 --- a/tests/misc/recursive_iternext.py +++ /dev/null @@ -1,57 +0,0 @@ -# This tests that recursion with iternext doesn't lead to segfault. -try: - enumerate - filter - map - max - zip -except: - print("SKIP") - raise SystemExit - -# We need to pick an N that is large enough to hit the recursion -# limit, but not too large that we run out of heap memory. -try: - # large stack/heap, eg unix - [0] * 80000 - N = 2400 -except: - try: - # medium, eg pyboard - [0] * 10000 - N = 1000 - except: - # small, eg esp8266 - N = 100 - -try: - x = (1, 2) - for i in range(N): - x = enumerate(x) - tuple(x) -except RuntimeError: - print("RuntimeError") - -try: - x = (1, 2) - for i in range(N): - x = filter(None, x) - tuple(x) -except RuntimeError: - print("RuntimeError") - -try: - x = (1, 2) - for i in range(N): - x = map(max, x, ()) - tuple(x) -except RuntimeError: - print("RuntimeError") - -try: - x = (1, 2) - for i in range(N): - x = zip(x) - tuple(x) -except RuntimeError: - print("RuntimeError") diff --git a/tests/misc/recursive_iternext.py.exp b/tests/misc/recursive_iternext.py.exp deleted file mode 100644 index 80d1488a3..000000000 --- a/tests/misc/recursive_iternext.py.exp +++ /dev/null @@ -1,4 +0,0 @@ -RuntimeError -RuntimeError -RuntimeError -RuntimeError diff --git a/tests/run-tests b/tests/run-tests index 42037831d..71eab4905 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -312,9 +312,6 @@ def run_tests(pyb, tests, args, base_path="."): if args.target == 'wipy': skip_tests.add('misc/print_exception.py') # requires error reporting full - skip_tests.add('misc/recursion.py') # requires stack checking enabled - skip_tests.add('misc/recursive_data.py') # requires stack checking enabled - skip_tests.add('misc/recursive_iternext.py') # requires stack checking enabled skip_tests.update({'extmod/uctypes_%s.py' % t for t in 'bytearray le native_le ptr_le ptr_native_le sizeof sizeof_native array_assign_le array_assign_native_le'.split()}) # requires uctypes skip_tests.add('extmod/zlibd_decompress.py') # requires zlib skip_tests.add('extmod/uheapq1.py') # uheapq not supported by WiPy diff --git a/tests/stress/recursion.py b/tests/stress/recursion.py new file mode 100644 index 000000000..227f48396 --- /dev/null +++ b/tests/stress/recursion.py @@ -0,0 +1,7 @@ +def foo(): + foo() + +try: + foo() +except RuntimeError: + print("RuntimeError") diff --git a/tests/stress/recursive_data.py b/tests/stress/recursive_data.py new file mode 100644 index 000000000..3b7fa5095 --- /dev/null +++ b/tests/stress/recursive_data.py @@ -0,0 +1,13 @@ +# This tests that printing recursive data structure doesn't lead to segfault. +try: + import uio as io +except ImportError: + print("SKIP") + raise SystemExit + +l = [1, 2, 3, None] +l[-1] = l +try: + print(l, file=io.StringIO()) +except RuntimeError: + print("RuntimeError") diff --git a/tests/stress/recursive_data.py.exp b/tests/stress/recursive_data.py.exp new file mode 100644 index 000000000..8a2b9bfdd --- /dev/null +++ b/tests/stress/recursive_data.py.exp @@ -0,0 +1 @@ +RuntimeError diff --git a/tests/stress/recursive_iternext.py b/tests/stress/recursive_iternext.py new file mode 100644 index 000000000..edb5a843f --- /dev/null +++ b/tests/stress/recursive_iternext.py @@ -0,0 +1,57 @@ +# This tests that recursion with iternext doesn't lead to segfault. +try: + enumerate + filter + map + max + zip +except: + print("SKIP") + raise SystemExit + +# We need to pick an N that is large enough to hit the recursion +# limit, but not too large that we run out of heap memory. +try: + # large stack/heap, eg unix + [0] * 80000 + N = 2400 +except: + try: + # medium, eg pyboard + [0] * 10000 + N = 1000 + except: + # small, eg esp8266 + N = 100 + +try: + x = (1, 2) + for i in range(N): + x = enumerate(x) + tuple(x) +except RuntimeError: + print("RuntimeError") + +try: + x = (1, 2) + for i in range(N): + x = filter(None, x) + tuple(x) +except RuntimeError: + print("RuntimeError") + +try: + x = (1, 2) + for i in range(N): + x = map(max, x, ()) + tuple(x) +except RuntimeError: + print("RuntimeError") + +try: + x = (1, 2) + for i in range(N): + x = zip(x) + tuple(x) +except RuntimeError: + print("RuntimeError") diff --git a/tests/stress/recursive_iternext.py.exp b/tests/stress/recursive_iternext.py.exp new file mode 100644 index 000000000..80d1488a3 --- /dev/null +++ b/tests/stress/recursive_iternext.py.exp @@ -0,0 +1,4 @@ +RuntimeError +RuntimeError +RuntimeError +RuntimeError -- cgit v1.2.3