Browse Source

tests: adapted to HWRNG interface changes

pr/gpio
Hauke Petersen 7 years ago
parent
commit
a95ec92633
  1. 4
      tests/periph_hwrng/Makefile
  2. 9
      tests/periph_hwrng/README.md
  3. 20
      tests/periph_hwrng/main.c
  4. 7
      tests/periph_random/README.md
  5. 2
      tests/pkg_micro-ecc/Makefile
  6. 6
      tests/pkg_micro-ecc/main.c

4
tests/periph_random/Makefile → tests/periph_hwrng/Makefile

@ -1,7 +1,7 @@
export APPLICATION = periph_random
export APPLICATION = periph_hwrng
include ../Makefile.tests_common
FEATURES_REQUIRED = periph_random
FEATURES_REQUIRED = periph_hwrng
USEMODULE += xtimer

9
tests/periph_hwrng/README.md

@ -0,0 +1,9 @@
Expected result
===============
This test outputs a sequence of random bytes, starting with one, then two and so
on, until 20 random bytes are printed. Then the application sleeps for a second
and starts over.
Background
==========
Test the functionality of a platforms HWRNG implementation.

20
tests/periph_random/main.c → tests/periph_hwrng/main.c

@ -22,19 +22,20 @@
#include <string.h>
#include "xtimer.h"
#include "periph/random.h"
#include "periph/hwrng.h"
#define LIMIT (20U)
int main(void)
{
char buf[LIMIT];
uint8_t buf[LIMIT];
puts("\nRandom number generator low-level driver test\n");
printf("This test will print from 1 to %i random bytes about every second\n\n", LIMIT);
puts("\nHWRNG peripheral driver test\n");
printf("This test will print from 1 to %i random bytes about every"
"second\n\n", LIMIT);
puts("Initializing Random Number Generator driver.\n");
random_init();
puts("Initializing the HWRNG driver.\n");
hwrng_init();
while (1) {
/* zero out buffer */
@ -43,12 +44,7 @@ int main(void)
/* create random numbers */
for (unsigned i = 1; i <= LIMIT; i++) {
printf("generating %u random byte(s)\n", i);
unsigned count = random_read(buf, i);
if (count != i) {
printf("Error generating random bytes, got %u instead of %u", count, i);
return 0;
}
hwrng_read(buf, i);
printf("Got:");
for (unsigned j = 0; j < i; j++) {

7
tests/periph_random/README.md

@ -1,7 +0,0 @@
Expected result
===============
This test outputs a sequence of random bytes, starting with one, then two and so on, until 20 random bytes are printed. Then the application sleeps for a second and starts over.
Background
==========
This test was introduced to test the implementation of the low-level random number generator driver. For most platforms the implementation is based on hardware CPU peripherals.

2
tests/pkg_micro-ecc/Makefile

@ -1,7 +1,7 @@
APPLICATION = micro-ecc
include ../Makefile.tests_common
FEATURES_REQUIRED = periph_random
FEATURES_REQUIRED = periph_hwrng
USEPKG += micro-ecc
include $(RIOTBASE)/Makefile.include

6
tests/pkg_micro-ecc/main.c

@ -37,7 +37,7 @@
#include <stdio.h>
#include <string.h>
#include "uECC.h"
#include "periph/random.h"
#include "periph/hwrng.h"
#define TESTROUNDS 16
@ -61,9 +61,7 @@ int main(void)
uint8_t l_sig[uECC_BYTES * 2];
/* initialize hardware random number generator */
random_init();
/* power off RNG to save energy */
random_poweroff();
hwrng_init();
printf("Testing %d random private key pairs and signature\n", TESTROUNDS);

Loading…
Cancel
Save