6 # The contents of this file are subject to the terms
7 # of the Common Development and Distribution License
8 # (the "License"). You may not use this file except
9 # in compliance with the License.
11 # You can obtain a copy of the license at
12 # src/OPENSOLARIS.LICENSE
13 # or http://www.opensolaris.org/os/licensing.
14 # See the License for the specific language governing
15 # permissions and limitations under the License.
17 # When distributing Covered Code, include this CDDL
18 # HEADER in each file and include the License file at
19 # usr/src/OPENSOLARIS.LICENSE. If applicable,
20 # add the following below this CDDL HEADER, with the
21 # fields enclosed by brackets "[]" replaced with your
22 # own identifying information: Portions Copyright [yyyy]
23 # [name of copyright owner]
29 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
30 # Use is subject to license terms.
35 echo "$0 [-l] [-h] <#-of-users> nodename [test match pattern]"
36 echo "-l : disable libinfo L1 cache"
37 echo "-h : Help. This option displays information on how to run the script. "
38 echo "[test match pattern] : This option runs only the test that is specified"
40 echo "You must have set up users, groups, and SACLs with od_account_create"
41 echo "with the same number of user accounts."
42 echo "Supply a pattern to match to run a subset of tests"
46 # default to libinfo cache enabled
49 while getopts "lh" OPT_LIST
52 l
) L1CACHE
="0";; # to run the libmicro tests with l1cache disabled
58 shift `expr $OPTIND - 1`
60 if [ $# -lt 2 -o $# -gt 3 ]; then
67 libmicro_version
=`$tattle -V`
69 case $libmicro_version in
73 echo "ERROR: libMicro version doesn't match 'bench' script version"
77 TMPROOT
=/private
/tmp
/libmicro.$$
78 VARROOT
=/private
/var
/tmp
/libmicro.$$
81 trap "rm -rf $TMPROOT $VARROOT && exit" 0 2
85 TDIR1
=$TMPROOT/0/1/2/3/4/5/6/7/8/9
86 TDIR2
=$TMPROOT/1/2/3/4/5/6/7/8/9/0
88 VDIR1
=$VARROOT/0/1/2/3/4/5/6/7/8/9
89 VDIR2
=$VARROOT/1/2/3/4/5/6/7/8/9/0
91 OPTS
="-E -C 200 -L -S -W"
93 dd if=/dev
/zero of
=$TFILE bs
=1024k count
=10 2>/dev
/null
94 dd if=/dev
/zero of
=$VFILE bs
=1024k count
=10 2>/dev
/null
95 mkdir -p $TDIR1 $TDIR2
96 mkdir -p $VDIR1 $VDIR2
99 /usr
/bin
/touch /private
/var
/tmp
/lmbench
102 # produce benchmark header for easier comparisons
106 if [ -f /usr
/sbin
/psrinfo
]; then
107 p_count
=`psrinfo|wc -l`
108 p_mhz
=`psrinfo -v | awk '/operates/{print $6 "MHz"; exit }'`
109 p_type
=`psrinfo -vp 2>/dev/null | awk '{if (NR == 3) {print $0; exit}}'`
110 p_ipaddr
=`getent hosts $hostname | awk '{print $1}'`
113 if [ -f /proc
/cpuinfo
]; then
114 p_count
=`egrep processor /proc/cpuinfo | wc -l`
115 p_mhz
=`awk -F: '/cpu MHz/{printf("%5.0f00Mhz\n",$2/100); exit}' /proc/cpuinfo`
116 p_type
=`awk -F: '/model name/{print $2; exit}' /proc/cpuinfo`
117 p_ipaddr
=`getent hosts $hostname | awk '{print $1}'`
119 ## Mac OS X specific stuff
120 # first, get ugly output, in case pretty output isn't available
122 p_count
=`sysctl -n hw.physicalcpu`
123 p_mhz
=`sysctl -n hw.cpufrequency`
124 p_type
=`sysctl -n hw.model`
126 if [ -x /usr
/sbin
/system_profiler
]; then
127 # <rdar://4655981> requires this hunk of work-around
128 # grep the XML for the characteristic we need. The key appears twice, so grep for the useful key (with 'string')
129 # use sed to strip off the <string></string> and the tabs in front of the string. So much work for so little result.
131 p_mhz
=`system_profiler -xml -detailLevel mini SPHardwareDataType | \
132 grep -A1 current_processor_speed | grep string | \
133 sed -E 's/<string>(.+)<\/string>/\1/' | sed 's- --g'`
134 p_type
=`system_profiler -xml -detailLevel mini SPHardwareDataType | \
135 grep -A1 cpu_type | grep string | \
136 sed -E 's/<string>(.+)<\/string>/\1/' | sed 's- --g'`
139 # look for en0 (usually ethernet) if that isn't there try en1 (usually wireless) else give up
140 p_ipaddr
=`ipconfig getpacket en0 | grep yiaddr | tr "= " "\n" | grep [0-9]`
141 if [ ! $p_ipaddr ]; then
142 p_ipaddr
=`ipconfig getpacket en1 | grep yiaddr | tr "= " "\n" | grep [0-9]`
143 elif [ ! $p_ipaddr ]; then
148 printf "\n\n!Libmicro_#: %30s\n" $libmicro_version
149 printf "!Options: %30s\n" "$OPTS"
150 printf "!Machine_name: %30s\n" "$hostname"
151 printf "!OS_name: %30s\n" `uname -s`
152 printf "!OS_release: %30s\n" `sw_vers -productVersion`
153 printf "!OS_build: %30.18s\n" "`sw_vers -buildVersion`"
154 printf "!Processor: %30s\n" `arch`
155 printf "!#CPUs: %30s\n" $p_count
156 printf "!CPU_MHz: %30s\n" "$p_mhz"
157 printf "!CPU_NAME: %30s\n" "$p_type"
158 printf "!IP_address: %30s\n" "$p_ipaddr"
159 printf "!Run_by: %30s\n" $LOGNAME
160 printf "!Date: %30s\n" "`date '+%D %R'`"
161 printf "!Compiler: %30s\n" `$tattle -c`
162 printf "!Compiler Ver.:%30s\n" "`$tattle -v`"
163 printf "!sizeof(long): %30s\n" `$tattle -s`
164 printf "!extra_CFLAGS: %30s\n" "`$tattle -f`"
165 printf "!TimerRes: %30s\n\n\n" "`$tattle -r`"
167 bin_dir
="$TMPROOT/bin"
170 cp bin
-*/exec_bin
$bin_dir/$A
172 cp .
/apple
/bin
-*/posix_spawn_bin
$bin_dir/$A
176 # We commonly want to adjust this script for the number of users
177 # and configuration of the accounts and configuration being tested.
183 UID_END
=`expr $UID_BASE + $NUSERS - 1`
189 GROUP_BASE
=od_test_group
191 # getaddrinfo on hosts:
196 # Everything below the while loop is input for the while loop if
197 # you have any tests which can't run in the while loop, put
198 # them above this comment
202 # $A contains the command, $B contains the arguments
203 # we echo blank lines and comments
204 # we skip anything which fails to match *$1* (useful if
205 # we only want to test one case, but a nasty hack)
215 if [ $newline -eq 1 ]
233 if [ ! -f $bin_dir/$A ]
235 cp bin
-*/$A $bin_dir/$A
240 (cd $TMPROOT && eval "bin/$A $B")
247 # -T <# threads> - exclusive!
249 # mbr_check_service_membership()
250 mbr_check_service_membership
$OPTS -N "mbr_check_service_membership" -s libMicro
-u ${USER_PREFIX} -r ${NUSERS}
251 mbr_check_service_membership
$OPTS -N "mbr_check_service_membership_t2" -T 2 -s libMicro
-u ${USER_PREFIX} -r ${NUSERS}
252 mbr_check_service_membership
$OPTS -N "mbr_check_service_membership_t4" -T 4 -s libMicro
-u ${USER_PREFIX} -r ${NUSERS}
253 mbr_check_service_membership
$OPTS -N "mbr_check_service_membership_p2" -P 2 -s libMicro
-u ${USER_PREFIX} -r ${NUSERS}
254 mbr_check_service_membership
$OPTS -N "mbr_check_service_membership_p4" -P 4 -s libMicro
-u ${USER_PREFIX} -r ${NUSERS}
257 getpwnam
$OPTS -N "getpwnam" -l ${L1CACHE} -r ${NUSERS} -u ${USER_PREFIX}
258 getpwnam
$OPTS -N "getpwnam_t2" -T 2 -l ${L1CACHE} -r ${NUSERS} -u ${USER_PREFIX}
259 getpwnam
$OPTS -N "getpwnam_p2" -P 2 -l ${L1CACHE} -r ${NUSERS} -u ${USER_PREFIX}
261 # mbr_check_membership()
262 mbr_check_membership
$OPTS -N "mbr_check_membership" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS}
263 mbr_check_membership
$OPTS -N "mbr_check_membership_t2" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS} -T 2
264 mbr_check_membership
$OPTS -N "mbr_check_membership_t4" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS} -T 4
265 mbr_check_membership
$OPTS -N "mbr_check_membership_p2" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS} -P 2
266 mbr_check_membership
$OPTS -N "mbr_check_membership_p4" -u ${UID_BASE}-${UID_END} -g ${GID_ALL_USERS}-${GID_NO_USERS} -P 4
269 getpwuid
$OPTS -N "getpwuid" -l ${L1CACHE} -u ${UID_BASE}-${UID_END}
270 getpwuid
$OPTS -N "getpwuid_t2" -l ${L1CACHE} -u ${UID_BASE}-${UID_END} -T 2
271 getpwuid
$OPTS -N "getpwuid_t4" -l ${L1CACHE} -u ${UID_BASE}-${UID_END} -T 4
272 getpwuid
$OPTS -N "getpwuid_p2" -l ${L1CACHE} -u ${UID_BASE}-${UID_END} -P 2
273 getpwuid
$OPTS -N "getpwuid_p4" -l ${L1CACHE} -u ${UID_BASE}-${UID_END} -P 4
276 getgrgid
$OPTS -N "getgrgid" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS}
277 getgrgid
$OPTS -N "getgrgid_t2" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS} -T 2
278 getgrgid
$OPTS -N "getgrgid_t4" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS} -T 4
279 getgrgid
$OPTS -N "getgrgid_p2" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS} -P 2
280 getgrgid
$OPTS -N "getgrgid_p4" -l ${L1CACHE} -g ${GID_ALL_USERS}-${GID_NO_USERS} -P 4
283 getpwent
$OPTS -N "getpwent" -l ${L1CACHE}
284 getpwent
$OPTS -N "getpwent_t2" -l ${L1CACHE} -T 2
285 getpwent
$OPTS -N "getpwent_t4" -l ${L1CACHE} -T 4
286 getpwent
$OPTS -N "getpwent_p2" -l ${L1CACHE} -P 2
287 getpwent
$OPTS -N "getpwent_p4" -l ${L1CACHE} -P 4
290 getgrent
$OPTS -N "getgrent" -l ${L1CACHE}
291 getgrent
$OPTS -N "getgrent_t2" -l ${L1CACHE} -T 2
292 getgrent
$OPTS -N "getgrent_t4" -l ${L1CACHE} -T 4
293 getgrent
$OPTS -N "getgrent_p2" -l ${L1CACHE} -P 2
294 getgrent
$OPTS -N "getgrent_p4" -l ${L1CACHE} -P 4
297 #getaddrinfo_host $OPTS -N "getaddrinfo_host" -r ${HOST_RANGE} -h ${HOST_BASE}%d
298 #getaddrinfo_host $OPTS -N "getaddrinfo_host_t2" -r ${HOST_RANGE} -h ${HOST_BASE}%d -T 2
299 #getaddrinfo_host $OPTS -N "getaddrinfo_host_t4" -r ${HOST_RANGE} -h ${HOST_BASE}%d -T 4
300 #getaddrinfo_host $OPTS -N "getaddrinfo_host_p2" -r ${HOST_RANGE} -h ${HOST_BASE}%d -P 2
301 #getaddrinfo_host $OPTS -N "getaddrinfo_host_p4" -r ${HOST_RANGE} -h ${HOST_BASE}%d -P 4
304 getaddrinfo_port
$OPTS -N "getaddrinfo_port" -l ${L1CACHE}
305 getaddrinfo_port
$OPTS -N "getaddrinfo_port_t2" -l ${L1CACHE} -T 2
306 getaddrinfo_port
$OPTS -N "getaddrinfo_port_t4" -l ${L1CACHE} -T 4
307 getaddrinfo_port
$OPTS -N "getaddrinfo_port_p2" -l ${L1CACHE} -P 2
308 getaddrinfo_port
$OPTS -N "getaddrinfo_port_p4" -l ${L1CACHE} -P 4
311 getgrnam
$OPTS -N "getgrnam" -l ${L1CACHE} -g ${GROUP_BASE} -r 2
312 getgrnam
$OPTS -N "getgrnam_t2" -l ${L1CACHE} -T 2 -g ${GROUP_BASE} -r 2
313 getgrnam
$OPTS -N "getgrnam_t4" -l ${L1CACHE} -T 4 -g ${GROUP_BASE} -r 2
314 getgrnam
$OPTS -N "getgrnam_p2" -l ${L1CACHE} -P 2 -g ${GROUP_BASE} -r 2
315 getgrnam
$OPTS -N "getgrnam_p4" -l ${L1CACHE} -P 4 -g ${GROUP_BASE} -r 2
317 # ODQueryCreateWithNode()
318 od_query_create_with_node
$OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u" -c 50 -r ${NUSERS} -t u
-B 50 -n ${NODENAME}
319 od_query_create_with_node
$OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u_t2" -T 2 -c 50 -r ${NUSERS} -t u
-B 50 -n ${NODENAME}
320 od_query_create_with_node
$OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u_t4" -T 4 -c 50 -r ${NUSERS} -t u
-B 50 -n ${NODENAME}
321 od_query_create_with_node
$OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u_p2" -P 2 -c 50 -r ${NUSERS} -t u
-B 50 -n ${NODENAME}
322 od_query_create_with_node
$OPTS -N "ODQueryCreateWithNode_cache_${NUSERS}u_p4" -P 4 -c 50 -r ${NUSERS} -t u
-B 50 -n ${NODENAME}