diff --git a/tests/pthread_cleanup/Makefile b/tests/pthread_cleanup/Makefile
index dc485fd43c..f6f6bffe96 100644
--- a/tests/pthread_cleanup/Makefile
+++ b/tests/pthread_cleanup/Makefile
@@ -7,3 +7,6 @@ BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove
USEMODULE += pthread
include $(RIOTBASE)/Makefile.include
+
+test:
+ tests/01-run.py
diff --git a/tests/pthread_cleanup/tests/01-run.py b/tests/pthread_cleanup/tests/01-run.py
new file mode 100755
index 0000000000..91d45f5f41
--- /dev/null
+++ b/tests/pthread_cleanup/tests/01-run.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
+import testrunner
+
+
+def testfunc(child):
+ child.expect('START')
+ for i in range(5):
+ child.expect_exact(''
+ .format(i + 1, ' /' if i == 4 else ''))
+
+ child.expect_exact('Cleanup: <5>')
+ child.expect_exact('')
+ child.expect_exact('')
+ for i in (3, 2, 1):
+ child.expect_exact('Cleanup: <{}>'.format(i))
+ child.expect_exact('Result: 1234')
+ child.expect('SUCCESS')
+
+
+if __name__ == "__main__":
+ sys.exit(testrunner.run(testfunc))
diff --git a/tests/pthread_cleanup/tests/01-test b/tests/pthread_cleanup/tests/01-test
deleted file mode 100755
index 6e7b30b030..0000000000
--- a/tests/pthread_cleanup/tests/01-test
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/env expect
-
-set timeout 5
-
-set pid [spawn make term]
-puts "-*- Spawened $pid -*-\n"
-
-set once 0
-set result 1
-while { $once == 0 } {
- set once 1
-
- expect {
- "Start." {}
- timeout { break }
- }
- expect {
- "" {}
- timeout { break }
- }
- expect {
- "" {}
- timeout { break }
- }
- expect {
- "" {}
- timeout { break }
- }
- expect {
- "" {}
- timeout { break }
- }
- expect {
- "" {}
- timeout { break }
- }
- expect {
- "" {}
- timeout { break }
- }
- expect {
- "Cleanup: <5>" {}
- timeout { break }
- }
- expect {
- "" {}
- timeout { break }
- }
- # Cleanup 4 has execute == 0.
- expect {
- "" {}
- timeout { break }
- }
- # pthread_exit is called here
- expect {
- "Cleanup: <3>" {}
- timeout { break }
- }
- expect {
- "Cleanup: <2>" {}
- timeout { break }
- }
- expect {
- "Cleanup: <1>" {}
- timeout { break }
- }
- expect {
- "Result: 1234" {}
- timeout { break }
- }
- expect {
- "Done." {}
- timeout { break }
- }
-
- set result 0
-}
-
-if { $result == 0 } {
- puts "\n-*- Test successful! -*-\n"
-} else {
- puts "\n-*- TEST HAD ERRORS! -*-\n"
-}
-spawn kill -9 $pid
-wait
-close
-exit $result