diff --git a/Makefile.am b/Makefile.am index 822cd2a7..4a608903 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,4 +6,5 @@ EXTRA_DIST = \ autogen.sh SUBDIRS = \ - src + src \ + test diff --git a/configure.ac b/configure.ac index 732b1b10..79e8077b 100644 --- a/configure.ac +++ b/configure.ac @@ -201,6 +201,7 @@ AC_CONFIG_FILES([Makefile src/Makefile src/libsodium/Makefile src/libsodium/include/Makefile - src/libsodium/include/sodium/version.h]) - + src/libsodium/include/sodium/version.h + test/Makefile + ]) AC_OUTPUT diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 00000000..4141182b --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,18 @@ + +AM_CPPFLAGS = \ + -I. \ + -I$(top_srcdir)/src/libsodium/include + +TESTS_TARGETS = \ + test-randombytes + +check_PROGRAMS = $(TESTS_TARGETS) + +TESTS = $(TESTS_TARGETS) + +TESTS_LDADD = $(top_srcdir)/src/libsodium/libsodium.la + +test_randombytes_SOURCES = test-randombytes.c +test_randombytes_LDADD = $(TESTS_LDADD) + +verify: check diff --git a/test/test-randombytes.c b/test/test-randombytes.c new file mode 100644 index 00000000..b4ff2774 --- /dev/null +++ b/test/test-randombytes.c @@ -0,0 +1,16 @@ +#include "sodium/randombytes.h" + +unsigned char x[65536]; +unsigned long long freq[256]; + +int main(void) +{ + unsigned long long i; + + randombytes(x,sizeof x); + for (i = 0;i < 256;++i) freq[i] = 0; + for (i = 0;i < sizeof x;++i) ++freq[255 & (int) x[i]]; + for (i = 0;i < 256;++i) if (!freq[i]) return 111; + + return 0; +}