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