summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorRami Ali <flowergrass@users.noreply.github.com>2016-12-29 13:12:06 +1100
committerDamien George <damien.p.george@gmail.com>2016-12-29 13:27:50 +1100
commitf397e1fdf0519a6770336c04904c4f0495e75496 (patch)
treedeea49fab545af2d36485acfe82afe0d1cf1a7dc /tests
parentc15ebf7c8c797af0dc7e601dbb70dbe3777d8ee6 (diff)
downloadmicropython-f397e1fdf0519a6770336c04904c4f0495e75496.tar.gz
micropython-f397e1fdf0519a6770336c04904c4f0495e75496.zip
tests/thread: Improve modthread.c test coverage.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run-tests2
-rw-r--r--tests/thread/thread_exc2.py10
-rw-r--r--tests/thread/thread_exc2.py.exp5
-rw-r--r--tests/thread/thread_start2.py7
4 files changed, 23 insertions, 1 deletions
diff --git a/tests/run-tests b/tests/run-tests
index d142c998cf..3bfa73e047 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -51,7 +51,7 @@ def convert_regex_escapes(line):
def run_micropython(pyb, args, test_file):
- special_tests = ('micropython/meminfo.py', 'basics/bytes_compare3.py')
+ special_tests = ('micropython/meminfo.py', 'basics/bytes_compare3.py', 'thread/thread_exc2.py')
is_special = False
if pyb is None:
# run on PC
diff --git a/tests/thread/thread_exc2.py b/tests/thread/thread_exc2.py
new file mode 100644
index 0000000000..35cb324412
--- /dev/null
+++ b/tests/thread/thread_exc2.py
@@ -0,0 +1,10 @@
+# test raising exception within thread which is not caught
+import utime
+import _thread
+
+def thread_entry():
+ raise ValueError
+
+_thread.start_new_thread(thread_entry, ())
+utime.sleep(1)
+print('done')
diff --git a/tests/thread/thread_exc2.py.exp b/tests/thread/thread_exc2.py.exp
new file mode 100644
index 0000000000..584bfab4de
--- /dev/null
+++ b/tests/thread/thread_exc2.py.exp
@@ -0,0 +1,5 @@
+Unhandled exception in thread started by <function thread_entry at 0x\[0-9a-f\]\+>
+Traceback (most recent call last):
+ File "thread/thread_exc2.py", line 6, in thread_entry
+ValueError:
+done
diff --git a/tests/thread/thread_start2.py b/tests/thread/thread_start2.py
index 4efa808eb9..d0913e37cd 100644
--- a/tests/thread/thread_start2.py
+++ b/tests/thread/thread_start2.py
@@ -16,4 +16,11 @@ _thread.start_new_thread(thread_entry, (10, 20), {'a2': 0, 'a3': 1})
# wait for thread to finish
time.sleep(1)
+
+# incorrect argument where dictionary is needed for keyword args
+try:
+ _thread.start_new_thread(thread_entry, (), ())
+except TypeError:
+ print('TypeError')
+
print('done')