From 6f1b8fea25a03b93d1267969e3bd49172a27d943 Mon Sep 17 00:00:00 2001
From: Alexandre Abadie <alexandre.abadie@inria.fr>
Date: Fri, 10 Nov 2017 09:27:05 +0100
Subject: [PATCH] tests/pkg_micro-ecc-with-hwrng: migrate to testrunner

---
 tests/pkg_micro-ecc-with-hwrng/Makefile       |  3 +++
 tests/pkg_micro-ecc-with-hwrng/main.c         |  8 +++++---
 .../pkg_micro-ecc-with-hwrng/tests/01-run.py  | 19 +++++++++++++++++++
 3 files changed, 27 insertions(+), 3 deletions(-)
 create mode 100755 tests/pkg_micro-ecc-with-hwrng/tests/01-run.py

diff --git a/tests/pkg_micro-ecc-with-hwrng/Makefile b/tests/pkg_micro-ecc-with-hwrng/Makefile
index feae776785..061b3c36f4 100644
--- a/tests/pkg_micro-ecc-with-hwrng/Makefile
+++ b/tests/pkg_micro-ecc-with-hwrng/Makefile
@@ -8,3 +8,6 @@ USEPKG += micro-ecc
 CFLAGS += -DFEATURE_PERIPH_HWRNG
 
 include $(RIOTBASE)/Makefile.include
+
+test:
+	tests/01-run.py
diff --git a/tests/pkg_micro-ecc-with-hwrng/main.c b/tests/pkg_micro-ecc-with-hwrng/main.c
index 9113958695..325c9fcba1 100644
--- a/tests/pkg_micro-ecc-with-hwrng/main.c
+++ b/tests/pkg_micro-ecc-with-hwrng/main.c
@@ -113,10 +113,12 @@ int main(void)
 
     printf(" done with %d error(s)\n", errorc);
 
-    if (errorc == 0) {
-        return 0;
+    if (errorc) {
+        puts("FAILURE");
+        return 1;
     }
     else {
-        return 1;
+        puts("SUCCESS");
+        return 0;
     }
 }
diff --git a/tests/pkg_micro-ecc-with-hwrng/tests/01-run.py b/tests/pkg_micro-ecc-with-hwrng/tests/01-run.py
new file mode 100755
index 0000000000..7475da28f5
--- /dev/null
+++ b/tests/pkg_micro-ecc-with-hwrng/tests/01-run.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import math
+
+sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
+import testrunner
+
+
+def testfunc(child):
+    child.expect_exact('micro-ecc compiled!')
+    child.expect_exact('Testing 16 random private key pairs and signature '
+                       'using HWRNG')
+    child.expect_exact('................ done with 0 error(s)')
+    child.expect_exact('SUCCESS')
+
+if __name__ == "__main__":
+    sys.exit(testrunner.run(testfunc, timeout=60))
-- 
GitLab