Merge pull request #14857 from fjmolinas/pr_tests_pkg_wolfssl
tests/pkg_wolf*: add test scripts and cleanup
This commit is contained in:
commit
95d4a2e29f
@ -1,19 +1,5 @@
|
|||||||
include ../Makefile.tests_common
|
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
|
# Ensure there is enough stack space
|
||||||
CFLAGS += -DTHREAD_STACKSIZE_MAIN=THREAD_STACKSIZE_LARGE
|
CFLAGS += -DTHREAD_STACKSIZE_MAIN=THREAD_STACKSIZE_LARGE
|
||||||
|
|
||||||
|
|||||||
@ -49,20 +49,20 @@ int main(void)
|
|||||||
int stat;
|
int stat;
|
||||||
int ret;
|
int ret;
|
||||||
ed25519_key key;
|
ed25519_key key;
|
||||||
LOG(LOG_INFO, "You are running RIOT on a(n) %s board.\n", RIOT_BOARD);
|
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("This board features a(n) %s MCU.\n", RIOT_MCU);
|
||||||
wc_ed25519_init(&key);
|
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);
|
ret = wc_ed25519_import_public(ed_public_key, ED25519_KEY_SIZE, &key);
|
||||||
if (ret != 0) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
if ((wc_ed25519_verify_msg(msg_signature, ED25519_SIG_SIZE, msg, 12, &stat, &key) < 0) || (stat == 0)) {
|
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 {
|
} else {
|
||||||
LOG(LOG_INFO, "The signature is valid!\n");
|
LOG_INFO("The signature is valid!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
12
tests/pkg_wolfcrypt-ed25519-verify/tests/01-run.py
Executable file
12
tests/pkg_wolfcrypt-ed25519-verify/tests/01-run.py
Executable file
@ -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))
|
||||||
@ -1,23 +1,14 @@
|
|||||||
include ../Makefile.tests_common
|
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
|
# This is an optimized stack value based on testing, if you observe
|
||||||
# a segmentation fault please increase this stack size.
|
# a segmentation fault please increase this stack size.
|
||||||
CFLAGS += -DTHREAD_STACKSIZE_MAIN=2*THREAD_STACKSIZE_LARGE
|
CFLAGS += -DTHREAD_STACKSIZE_MAIN=2*THREAD_STACKSIZE_LARGE
|
||||||
|
|
||||||
# Change this to 0 show compiler invocation lines by default:
|
|
||||||
QUIET ?= 1
|
|
||||||
|
|
||||||
|
|
||||||
USEPKG += wolfssl
|
USEPKG += wolfssl
|
||||||
USEMODULE += wolfcrypt wolfcrypt-test wolfcrypt_sha512 wolfcrypt_curve25519 \
|
USEMODULE += wolfcrypt wolfcrypt-test wolfcrypt_sha512 \
|
||||||
wolfcrypt_ed25519 wolfcrypt_chacha wolfcrypt_poly1305 wolfcrypt_aes \
|
wolfcrypt_curve25519 wolfcrypt_ed25519 wolfcrypt_chacha \
|
||||||
wolfcrypt_ecc wolfcrypt_asn wolfcrypt_random
|
wolfcrypt_poly1305 wolfcrypt_aes wolfcrypt_ecc \
|
||||||
|
wolfcrypt_asn wolfcrypt_random
|
||||||
|
|
||||||
# Uncomment the following line to enable RSA tests
|
# Uncomment the following line to enable RSA tests
|
||||||
# (e.g. when enough resources are available on platform)
|
# (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
|
# Comment the following line to disable full-benchmark test
|
||||||
USEMODULE += wolfcrypt-benchmark
|
USEMODULE += wolfcrypt-benchmark
|
||||||
|
|
||||||
|
USEMODULE += xtimer
|
||||||
|
|
||||||
ifneq ($(BOARD),native)
|
ifneq ($(BOARD),native)
|
||||||
CFLAGS += -DBENCH_EMBEDDED
|
CFLAGS += -DBENCH_EMBEDDED
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
TEST_ON_CI_WHITELIST += native
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
* directory for more details.
|
* directory for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup examples
|
* @ingroup examples
|
||||||
* @{
|
* @{
|
||||||
@ -33,15 +32,17 @@
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
LOG(LOG_INFO, "wolfSSL Crypto Test!");
|
LOG_INFO("wolfSSL Crypto Test!\n");
|
||||||
/* Wait to work around a failing tests
|
/* Wait to work around a failing tests
|
||||||
* on platforms that don't have RTC synchronized
|
* on platforms that don't have RTC synchronized
|
||||||
*/
|
*/
|
||||||
xtimer_sleep(1);
|
xtimer_sleep(1);
|
||||||
wolfcrypt_test(NULL);
|
wolfcrypt_test(NULL);
|
||||||
#ifdef MODULE_WOLFCRYPT_BENCHMARK
|
#ifdef MODULE_WOLFCRYPT_BENCHMARK
|
||||||
LOG(LOG_INFO, "wolfSSL Benchmark!");
|
LOG_INFO("wolfSSL Benchmark!\n");
|
||||||
benchmark_test(NULL);
|
benchmark_test(NULL);
|
||||||
|
#else
|
||||||
|
LOG_INFO("wolfSSL Benchmark disabled\n");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
39
tests/pkg_wolfssl/tests/01-run.py
Executable file
39
tests/pkg_wolfssl/tests/01-run.py
Executable file
@ -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))
|
||||||
Loading…
x
Reference in New Issue
Block a user