Commit 7809d576 authored by Philipp Schafft's avatar Philipp Schafft 🦁 Committed by Philipp Schafft
Browse files

Update: Added simple tests for PRNG

parent a8f3fe74
......@@ -10,6 +10,10 @@
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <igloo/tap.h>
#include <igloo/igloo.h>
#include <igloo/error.h>
......@@ -18,8 +22,22 @@
static igloo_ro_t g_instance;
static void dump(void)
{
char *buf;
if (igloo_ro_stringify(g_instance, &buf, igloo_RO_SY_DEFAULT) != igloo_ERROR_NONE)
return;
igloo_tap_diagnostic(buf);
free(buf);
}
int main (void) {
ssize_t res;
size_t iter;
unsigned char buf[16];
igloo_tap_init();
igloo_tap_test_success("igloo_initialize", igloo_initialize(&g_instance));
......@@ -28,8 +46,21 @@ int main (void) {
return 1;
}
dump();
igloo_tap_test_success("igloo_prng_auto_reseed", igloo_prng_auto_reseed(g_instance));
dump();
memset(buf, 0, sizeof(buf));
igloo_tap_test_success("igloo_prng_write", igloo_prng_write(g_instance, buf, sizeof(buf), sizeof(buf)*8));
for (iter = 0; iter < 16; iter++) {
dump();
res = igloo_prng_read(g_instance, buf, sizeof(buf));
igloo_tap_test("igloo_prng_read", res == (ssize_t)sizeof(buf));
}
igloo_tap_test_success("unref instance", igloo_ro_unref(&g_instance));
igloo_tap_fin();
return 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment