19d12795Robert Mustacchi/*
29d12795Robert Mustacchi * This file and its contents are supplied under the terms of the
39d12795Robert Mustacchi * Common Development and Distribution License ("CDDL"), version 1.0.
49d12795Robert Mustacchi * You may only use this file in accordance with the terms of version
59d12795Robert Mustacchi * 1.0 of the CDDL.
69d12795Robert Mustacchi *
79d12795Robert Mustacchi * A full copy of the text of the CDDL should have accompanied this
89d12795Robert Mustacchi * source.  A copy of the CDDL is also available via the Internet at
99d12795Robert Mustacchi * http://www.illumos.org/license/CDDL.
109d12795Robert Mustacchi */
119d12795Robert Mustacchi
129d12795Robert Mustacchi/*
139d12795Robert Mustacchi * Copyright (c) 2015, Joyent, Inc.
149d12795Robert Mustacchi */
159d12795Robert Mustacchi
169d12795Robert Mustacchi/*
179d12795Robert Mustacchi * Basic tests for the arc4random(3C) family of functions. They should always
189d12795Robert Mustacchi * succeed, let's make sure these do.
199d12795Robert Mustacchi */
209d12795Robert Mustacchi
219d12795Robert Mustacchi#include <stdlib.h>
229d12795Robert Mustacchi#include <assert.h>
239d12795Robert Mustacchi#include <errno.h>
249d12795Robert Mustacchi
259d12795Robert Mustacchiint
269d12795Robert Mustacchimain(void)
279d12795Robert Mustacchi{
289d12795Robert Mustacchi	uint32_t ret;
299d12795Robert Mustacchi	uint8_t buf[32];
309d12795Robert Mustacchi
319d12795Robert Mustacchi	(void) arc4random();
329d12795Robert Mustacchi	ret = arc4random_uniform(100);
339d12795Robert Mustacchi	assert(ret < 100);
349d12795Robert Mustacchi	ret = arc4random_uniform(200);
359d12795Robert Mustacchi	assert(ret < 200);
369d12795Robert Mustacchi
379d12795Robert Mustacchi	arc4random_buf(buf, sizeof (buf));
389d12795Robert Mustacchi
399d12795Robert Mustacchi	return (0);
409d12795Robert Mustacchi}