diff --git a/.gitignore b/.gitignore index bc80d6f8..564703c6 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,9 @@ test/default/secretbox2 test/default/secretbox7 test/default/secretbox8 test/default/shorthash +test/default/sodium_core +test/default/sodium_utils +test/default/sodium_version test/default/stream test/default/stream2 test/default/stream3 diff --git a/test/default/Makefile.am b/test/default/Makefile.am index 12b4693f..9aa9d1e6 100644 --- a/test/default/Makefile.am +++ b/test/default/Makefile.am @@ -32,6 +32,9 @@ EXTRA_DIST = \ secretbox7.exp \ secretbox8.exp \ shorthash.exp \ + sodium_core.exp \ + sodium_utils.exp \ + sodium_version.exp \ stream.exp \ stream2.exp \ stream3.exp \ @@ -76,6 +79,9 @@ TESTS_TARGETS = \ secretbox7 \ secretbox8 \ shorthash \ + sodium_core \ + sodium_utils \ + sodium_version \ stream \ stream2 \ stream3 \ @@ -181,6 +187,15 @@ secretbox8_LDADD = $(TESTS_LDADD) shorthash_SOURCE = cmptest.h shorthash.c shorthash_LDADD = $(TESTS_LDADD) +sodium_core_SOURCE = cmptest.h sodium_core.c +sodium_core_LDADD = $(TESTS_LDADD) + +sodium_utils_SOURCE = cmptest.h sodium_utils.c +sodium_utils_LDADD = $(TESTS_LDADD) + +sodium_version_SOURCE = cmptest.h sodium_version.c +sodium_version_LDADD = $(TESTS_LDADD) + stream_SOURCE = cmptest.h stream.c stream_LDADD = $(TESTS_LDADD) diff --git a/test/default/sodium_core.c b/test/default/sodium_core.c new file mode 100644 index 00000000..7bdcca8f --- /dev/null +++ b/test/default/sodium_core.c @@ -0,0 +1,11 @@ +#include + +#define TEST_NAME "sodium_core" +#include "cmptest.h" + +int main(void) +{ + printf ("%d\n", sodium_init()); + + return 0; +} diff --git a/test/default/sodium_core.exp b/test/default/sodium_core.exp new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/test/default/sodium_core.exp @@ -0,0 +1 @@ +1 diff --git a/test/default/sodium_utils.c b/test/default/sodium_utils.c new file mode 100644 index 00000000..fae6b0f0 --- /dev/null +++ b/test/default/sodium_utils.c @@ -0,0 +1,24 @@ +#include +#include + +#define TEST_NAME "sodium_utils" +#include "cmptest.h" + +int main(void) +{ + char buf1[1000]; + char buf2[1000]; + + randombytes(buf1, sizeof buf1); + memcpy(buf2, buf1, sizeof buf2); + printf ("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1)); + sodium_memzero(buf1, 0U); + printf ("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1)); + sodium_memzero(buf1, sizeof buf1 / 2); + printf ("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1)); + printf ("%d\n", sodium_memcmp(buf1, buf2, 0U)); + sodium_memzero(buf2, sizeof buf2 / 2); + printf ("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1)); + + return 0; +} diff --git a/test/default/sodium_utils.exp b/test/default/sodium_utils.exp new file mode 100644 index 00000000..579bdc55 --- /dev/null +++ b/test/default/sodium_utils.exp @@ -0,0 +1,5 @@ +0 +0 +255 +0 +0 diff --git a/test/default/sodium_version.c b/test/default/sodium_version.c new file mode 100644 index 00000000..aff06276 --- /dev/null +++ b/test/default/sodium_version.c @@ -0,0 +1,13 @@ +#include + +#define TEST_NAME "sodium_version" +#include "cmptest.h" + +int main(void) +{ + printf ("%d\n", sodium_version_string() != NULL); + printf ("%d\n", sodium_library_version_major() > 0); + printf ("%d\n", sodium_library_version_minor() > 0); + + return 0; +} diff --git a/test/default/sodium_version.exp b/test/default/sodium_version.exp new file mode 100644 index 00000000..e8183f05 --- /dev/null +++ b/test/default/sodium_version.exp @@ -0,0 +1,3 @@ +1 +1 +1