]> Savannah Git Hosting - gnulib.git/commitdiff
getentropy: Enhance tests.
authorBruno Haible <bruno@clisp.org>
Sun, 31 May 2020 18:13:27 +0000 (20:13 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 31 May 2020 18:18:31 +0000 (20:18 +0200)
* tests/test-getentropy.c (main): Add one more test.
* tests/test-unistd-c++.cc: Check the signature of getentropy.

ChangeLog
tests/test-getentropy.c
tests/test-unistd-c++.cc

index 141ed8a330a7decf868da65545fb0be6460e0951..0eb0ba8e511619190104d9792dc1aeb3870ec5cd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-31  Bruno Haible  <bruno@clisp.org>
+
+       getentropy: Enhance tests.
+       * tests/test-getentropy.c (main): Add one more test.
+       * tests/test-unistd-c++.cc: Check the signature of getentropy.
+
 2020-05-31  Bruno Haible  <bruno@clisp.org>
 
        getentropy: Work around a macOS and Solaris problem.
index 845c5dcaf02555520693b5a86a6633b7c4f22a2a..8659b6dbd060724bf8bdd81d706cda9e7a82051d 100644 (file)
@@ -39,5 +39,16 @@ main (int argc, char *argv[])
   /* This test fails with probability 2**-2048.  (Run it again if so. :-) */
   ASSERT (memcmp (buf, empty_buf, sizeof buf) != 0);
 
+  /* It is very unlikely that two calls to getentropy produce the same
+     results.  */
+  {
+    char buf1[8];
+    char buf2[8];
+
+    ASSERT (getentropy (buf1, sizeof (buf1)) == 0);
+    ASSERT (getentropy (buf2, sizeof (buf2)) == 0);
+    ASSERT (memcmp (buf1, buf2, sizeof (buf1)) != 0);
+  }
+
   return 0;
 }
index cf8d3fc1af0d0c3810fe6db66f43df8c6e9666db..6d4c8fbf13f19feeb949d9a36f1f038b68a41838 100644 (file)
@@ -94,6 +94,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::getdomainname, int, (char *, size_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::getdtablesize, int, (void));
 #endif
 
+#if GNULIB_TEST_GETENTROPY
+SIGNATURE_CHECK (GNULIB_NAMESPACE::getentropy, int, (void *, size_t));
+#endif
+
 #if GNULIB_TEST_GETGROUPS
 SIGNATURE_CHECK (GNULIB_NAMESPACE::getgroups, int, (int, gid_t *));
 #endif