diff --git a/tests/pkg_wolfcrypt-ed25519-verify/Makefile b/tests/pkg_wolfcrypt-ed25519-verify/Makefile index f6b8db76e1..e99e037c9b 100644 --- a/tests/pkg_wolfcrypt-ed25519-verify/Makefile +++ b/tests/pkg_wolfcrypt-ed25519-verify/Makefile @@ -1,19 +1,5 @@ include ../Makefile.tests_common -# If no BOARD is found in the environment, use this default: -BOARD ?= native - -# This has to be the absolute path to the RIOT base directory: -RIOTBASE ?= $(CURDIR)/../.. - -# Comment this out to disable code in RIOT that does safety checking -# which is not needed in a production environment but helps in the -# development process: -DEVELHELP ?= 1 - -# Change this to 0 show compiler invocation lines by default: -QUIET ?= 1 - # Ensure there is enough stack space CFLAGS += -DTHREAD_STACKSIZE_MAIN=THREAD_STACKSIZE_LARGE diff --git a/tests/pkg_wolfcrypt-ed25519-verify/main.c b/tests/pkg_wolfcrypt-ed25519-verify/main.c index a00fa4f17a..c53dc7364f 100644 --- a/tests/pkg_wolfcrypt-ed25519-verify/main.c +++ b/tests/pkg_wolfcrypt-ed25519-verify/main.c @@ -49,20 +49,20 @@ int main(void) int stat; int ret; ed25519_key key; - LOG(LOG_INFO, "You are running RIOT on a(n) %s board.\n", RIOT_BOARD); - LOG(LOG_INFO, "This board features a(n) %s MCU.\n", RIOT_MCU); + LOG_INFO("You are running RIOT on a(n) %s board.\n", RIOT_BOARD); + LOG_INFO("This board features a(n) %s MCU.\n", RIOT_MCU); wc_ed25519_init(&key); - LOG(LOG_INFO, "Starting ed25519 test."); + LOG_INFO("Starting ed25519 test.\n"); ret = wc_ed25519_import_public(ed_public_key, ED25519_KEY_SIZE, &key); if (ret != 0) { - LOG(LOG_ERROR, "Error importing public key for signature verification (%d)\n", ret); + LOG_ERROR("Error importing public key for signature verification (%d)\n", ret); return 1; } if ((wc_ed25519_verify_msg(msg_signature, ED25519_SIG_SIZE, msg, 12, &stat, &key) < 0) || (stat == 0)) { - LOG(LOG_WARNING, "The signature is not valid!\n"); + LOG_WARNING("The signature is not valid!\n"); } else { - LOG(LOG_INFO, "The signature is valid!\n"); + LOG_INFO("The signature is valid!\n"); } return 0; diff --git a/tests/pkg_wolfcrypt-ed25519-verify/tests/01-run.py b/tests/pkg_wolfcrypt-ed25519-verify/tests/01-run.py new file mode 100755 index 0000000000..e19d2900d6 --- /dev/null +++ b/tests/pkg_wolfcrypt-ed25519-verify/tests/01-run.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import sys +from testrunner import run + + +def testfunc(child): + child.expect_exact("The signature is valid!") + + +if __name__ == "__main__": + sys.exit(run(testfunc)) diff --git a/tests/pkg_wolfssl/Makefile b/tests/pkg_wolfssl/Makefile index e15f2263c8..07772e52c8 100644 --- a/tests/pkg_wolfssl/Makefile +++ b/tests/pkg_wolfssl/Makefile @@ -1,23 +1,14 @@ include ../Makefile.tests_common -# If no BOARD is found in the environment, use this default: -BOARD ?= native - -# This has to be the absolute path to the RIOT base directory: -RIOTBASE ?= $(CURDIR)/../.. - # This is an optimized stack value based on testing, if you observe # a segmentation fault please increase this stack size. CFLAGS += -DTHREAD_STACKSIZE_MAIN=2*THREAD_STACKSIZE_LARGE -# Change this to 0 show compiler invocation lines by default: -QUIET ?= 1 - - USEPKG += wolfssl -USEMODULE += wolfcrypt wolfcrypt-test wolfcrypt_sha512 wolfcrypt_curve25519 \ - wolfcrypt_ed25519 wolfcrypt_chacha wolfcrypt_poly1305 wolfcrypt_aes \ - wolfcrypt_ecc wolfcrypt_asn wolfcrypt_random +USEMODULE += wolfcrypt wolfcrypt-test wolfcrypt_sha512 \ + wolfcrypt_curve25519 wolfcrypt_ed25519 wolfcrypt_chacha \ + wolfcrypt_poly1305 wolfcrypt_aes wolfcrypt_ecc \ + wolfcrypt_asn wolfcrypt_random # Uncomment the following line to enable RSA tests # (e.g. when enough resources are available on platform) @@ -26,8 +17,12 @@ USEMODULE += wolfcrypt wolfcrypt-test wolfcrypt_sha512 wolfcrypt_curve25519 \ # Comment the following line to disable full-benchmark test USEMODULE += wolfcrypt-benchmark +USEMODULE += xtimer + ifneq ($(BOARD),native) CFLAGS += -DBENCH_EMBEDDED endif +TEST_ON_CI_WHITELIST += native + include $(RIOTBASE)/Makefile.include diff --git a/tests/pkg_wolfssl/main.c b/tests/pkg_wolfssl/main.c index 6b72a94434..017418de70 100644 --- a/tests/pkg_wolfssl/main.c +++ b/tests/pkg_wolfssl/main.c @@ -7,7 +7,6 @@ * directory for more details. */ - /** * @ingroup examples * @{ @@ -33,15 +32,17 @@ int main(void) { - LOG(LOG_INFO, "wolfSSL Crypto Test!"); + LOG_INFO("wolfSSL Crypto Test!\n"); /* Wait to work around a failing tests * on platforms that don't have RTC synchronized */ xtimer_sleep(1); wolfcrypt_test(NULL); #ifdef MODULE_WOLFCRYPT_BENCHMARK - LOG(LOG_INFO, "wolfSSL Benchmark!"); + LOG_INFO("wolfSSL Benchmark!\n"); benchmark_test(NULL); +#else + LOG_INFO("wolfSSL Benchmark disabled\n"); #endif return 0; } diff --git a/tests/pkg_wolfssl/tests/01-run.py b/tests/pkg_wolfssl/tests/01-run.py new file mode 100755 index 0000000000..42e609c5ca --- /dev/null +++ b/tests/pkg_wolfssl/tests/01-run.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +import os +import sys +from testrunner import run +from testrunner import TIMEOUT as DEFAULT_TIMEOUT + + +# native is the default platform for this test +BOARD = os.environ.get("BOARD", "native") +# Increase timeout on "real" hardware +# ED25519 takes +160s on samr21-xpro +# ED25519 takes +230s on nucleo-l073rz +TEST_TIMEOUT = 300 if BOARD != 'native' else DEFAULT_TIMEOUT +# ECDSA 256 takes +30s on samr21-xpro +BENCH_TIMEOUT = 30 if BOARD != 'native' else DEFAULT_TIMEOUT + + +def _wait_for_test(child): + return child.expect(["test passed!", "Test complete"], + timeout=TEST_TIMEOUT) + + +def _wait_for_bench(child): + return child.expect([r"MB\/s", r"ops\/sec", + "Benchmark complete", + "wolfSSL Benchmark disabled"], + timeout=BENCH_TIMEOUT) + + +def testfunc(child): + while _wait_for_test(child) == 0: + pass + while _wait_for_bench(child) <= 1: + pass + + +if __name__ == "__main__": + sys.exit(run(testfunc))