Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / test / libc-tests / tests / random / getrandred.c
blobe2efa817d85551976466ea5cc0b93bfc347d2a4d
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2015 Joyent, Inc.
17 * Regression test for illumos#5843.
20 #include <string.h>
21 #include <stdlib.h>
22 #include <sys/random.h>
24 #define NTRIES 5
25 #define NOFF 128
26 #define NBYTES 223
28 int
29 main(void)
31 int i;
32 char buf[1024];
34 (void) memset(buf, 'a', sizeof (buf));
37 * Try to go ahead and corrupt ourselves NTRIES times.
39 for (i = 0; i < NTRIES; i++) {
40 (void) getrandom(buf + NOFF, NBYTES, 0);
43 for (i = 0; i < NOFF; i++) {
44 if (buf[i] != 'a')
45 abort();
48 for (i = NBYTES + NOFF; i < sizeof (buf); i++) {
49 if (buf[i] != 'a')
50 abort();
53 return (0);