From 583e5e334c00c464ee1bf8fbf93797b5de748ff4 Mon Sep 17 00:00:00 2001
From: Martine Lenders <m.lenders@fu-berlin.de>
Date: Thu, 4 Mar 2021 11:34:59 +0100
Subject: [PATCH] tests: use run_check_unittests() where appropriate

---
 tests/driver_ds1307/tests-with-config/01-run.py  | 13 ++++++++++---
 tests/gnrc_sixlowpan_frag_minfwd/tests/01-run.py |  8 ++------
 tests/gnrc_sixlowpan_frag_sfr/tests/01-run.py    |  8 ++------
 tests/pkg_libbase58/tests/01-run.py              |  8 ++------
 tests/suit_manifest/tests/01-run.py              |  4 ++--
 5 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/tests/driver_ds1307/tests-with-config/01-run.py b/tests/driver_ds1307/tests-with-config/01-run.py
index 87ecdb87ccd51..ccd5ab24b020b 100755
--- a/tests/driver_ds1307/tests-with-config/01-run.py
+++ b/tests/driver_ds1307/tests-with-config/01-run.py
@@ -7,12 +7,19 @@
 # directory for more details.
 
 import sys
-from testrunner import run
+
+import pexpect
+
+from testrunner import run, run_check_unittests
 
 
 def testfunc(child):
-    child.expect([r"OK \([0-9]+ tests\)",
-                  r"error: unable to initialize RTC \[I2C initialization error\]"])
+    res = child.expect([
+        r"error: unable to initialize RTC \[I2C initialization error\]",
+        pexpect.TIMEOUT,
+    ])
+    if res == 1:
+        run_check_unittests()
 
 
 if __name__ == "__main__":
diff --git a/tests/gnrc_sixlowpan_frag_minfwd/tests/01-run.py b/tests/gnrc_sixlowpan_frag_minfwd/tests/01-run.py
index 6d8b056e2d59e..2eac21932f001 100755
--- a/tests/gnrc_sixlowpan_frag_minfwd/tests/01-run.py
+++ b/tests/gnrc_sixlowpan_frag_minfwd/tests/01-run.py
@@ -8,12 +8,8 @@
 # directory for more details.
 
 import sys
-from testrunner import run
-
-
-def testfunc(child):
-    child.expect(r"OK \(\d+ tests\)")
+from testrunner import run_check_unittests
 
 
 if __name__ == "__main__":
-    sys.exit(run(testfunc))
+    sys.exit(run_check_unittests())
diff --git a/tests/gnrc_sixlowpan_frag_sfr/tests/01-run.py b/tests/gnrc_sixlowpan_frag_sfr/tests/01-run.py
index 6d8b056e2d59e..2eac21932f001 100755
--- a/tests/gnrc_sixlowpan_frag_sfr/tests/01-run.py
+++ b/tests/gnrc_sixlowpan_frag_sfr/tests/01-run.py
@@ -8,12 +8,8 @@
 # directory for more details.
 
 import sys
-from testrunner import run
-
-
-def testfunc(child):
-    child.expect(r"OK \(\d+ tests\)")
+from testrunner import run_check_unittests
 
 
 if __name__ == "__main__":
-    sys.exit(run(testfunc))
+    sys.exit(run_check_unittests())
diff --git a/tests/pkg_libbase58/tests/01-run.py b/tests/pkg_libbase58/tests/01-run.py
index 5ba9b468a2886..0f594d3256928 100755
--- a/tests/pkg_libbase58/tests/01-run.py
+++ b/tests/pkg_libbase58/tests/01-run.py
@@ -7,12 +7,8 @@
 # directory for more details.
 
 import sys
-from testrunner import run
-
-
-def testfunc(child):
-    child.expect(u"OK \\([0-9]+ tests\\)")
+from testrunner import run_check_unittests
 
 
 if __name__ == "__main__":
-    sys.exit(run(testfunc, timeout=120))
+    sys.exit(run_check_unittests(timeout=120))
diff --git a/tests/suit_manifest/tests/01-run.py b/tests/suit_manifest/tests/01-run.py
index 388f894852c22..22dd0aa9e08f2 100755
--- a/tests/suit_manifest/tests/01-run.py
+++ b/tests/suit_manifest/tests/01-run.py
@@ -8,7 +8,7 @@
 
 import os
 import sys
-from testrunner import run
+from testrunner import run, run_check_unittests
 
 
 def testfunc(child):
@@ -17,7 +17,7 @@ def testfunc(child):
     # 16 seconds on `samr21-xpro`
     # >50 seconds on `nrf51dk`
     timeout = 60 if board != 'native' else -1
-    child.expect(r"OK \(\d+ tests\)", timeout=timeout)
+    run_check_unittests(timeout=timeout)
 
 
 if __name__ == "__main__":