xref: /illumos-gate/usr/src/test/libc-tests/tests/random/arc4key.ksh (revision 45ede40b2394db7967e59f19288fae9b62efd4aa)
1#!/usr/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright (c) 2015, Joyent, Inc.
15#
16
17#
18# The purpose of this test is to verify that we have actually gone
19# through and called the rekey functions in the implementation of the
20# arc4random code that we have. To do that, we look at the actual part
21# of the code that does generation. In this case, the function
22# arc4_rekey() which is a private function as part of libc.
23#
24
25set -o errexit
26
27arc_pname=$(basename $0)
28arc_root=$(dirname $0)/../..
29arc_bin=$arc_root/tests/random/arc4random_rekey
30arc_tmpfile=/tmp/$arc_pname.$$
31arc_count=
32
33rm -f $arc_tmpfile
34dtrace -n 'pid$target::arc4_rekey:entry{ @ = count(); }' -c $arc_bin \
35    -o $arc_tmpfile
36arc_count=$(cat $arc_tmpfile)
37[[ $arc_count -gt 1 ]]
38