1 /* Test the getentropy function.
2 Copyright 2020 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Paul Eggert. */
25 #include "signature.h"
26 SIGNATURE_CHECK (getentropy
, int, (void *, size_t));
34 main (int argc
, char *argv
[])
36 /* If this test fails, there's something wrong with the setup anyway. */
37 ASSERT (getentropy (buf
, sizeof buf
) == 0);
39 /* This test fails with probability 2**-2048. (Run it again if so. :-) */
40 ASSERT (memcmp (buf
, empty_buf
, sizeof buf
) != 0);
42 /* It is very unlikely that two calls to getentropy produce the same
48 ASSERT (getentropy (buf1
, sizeof (buf1
)) == 0);
49 ASSERT (getentropy (buf2
, sizeof (buf2
)) == 0);
50 ASSERT (memcmp (buf1
, buf2
, sizeof (buf1
)) != 0);